Deprecate and move fabric-rendering-registries-v1 into fabric-rendering-v1 (#1470)

* Deprecate and move fabric-rendering-registries-v1 into fabric-rendering-v1

* Make the event work again

* Use lambda for RegistrationHelper

* Checkstyle in rendererregistries

* Checkstyle for rendering-v1

* Remove mixins file

And add two `forRemoval`

* Raise EntityModelLayerRegistry out of experimental

And update javadoc

* Change INSTANCE to a static method in two registries

* Readd unwillingly removed annotation

* Disallow constructing API instances

* Added Environment and ApiStatus annotations

* Update testmod's entrypoint

Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com>

* Remove renderer-registries testmod

* Remove `var` usage

* Don't specify `forRemoval = true` in `@Deprecated`

* Inline old registry implementations in anonymous classes

Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com>
This commit is contained in:
altrisi 2021-08-24 18:43:44 +02:00 committed by GitHub
parent 8195aec1e2
commit 2a2a2c5485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 332 additions and 104 deletions

View file

@ -1,10 +1,7 @@
archivesBaseName = "fabric-renderer-registries-v1" archivesBaseName = "fabric-renderer-registries-v1"
version = getSubprojectVersion(project, "3.2.0") version = getSubprojectVersion(project, "3.2.0")
dependencies {
testmodImplementation project(path: ':fabric-lifecycle-events-v1', configuration: 'dev')
}
moduleDependencies(project, [ moduleDependencies(project, [
'fabric-api-base' 'fabric-api-base',
'fabric-rendering-v1'
]) ])

View file

@ -22,13 +22,19 @@ import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.fabricmc.fabric.impl.client.renderer.registry.BlockEntityRendererRegistryImpl;
/** /**
* Helper class for registering BlockEntityRenderers. * Helper class for registering BlockEntityRenderers.
*
* @deprecated This module has been moved into fabric-rendering-v1. Use {@link net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry} instead
*/ */
@Deprecated
public interface BlockEntityRendererRegistry { public interface BlockEntityRendererRegistry {
BlockEntityRendererRegistry INSTANCE = new BlockEntityRendererRegistryImpl(); BlockEntityRendererRegistry INSTANCE = new BlockEntityRendererRegistry() {
@Override
public <E extends BlockEntity> void register(BlockEntityType<E> blockEntityType, BlockEntityRendererFactory<? super E> blockEntityRendererFactory) {
net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry.register(blockEntityType, blockEntityRendererFactory);
}
};
/** /**
* Register a BlockEntityRenderer for a BlockEntityType. Can be called clientside before the world is rendered. * Register a BlockEntityRenderer for a BlockEntityType. Can be called clientside before the world is rendered.

View file

@ -16,25 +16,18 @@
package net.fabricmc.fabric.api.client.rendereregistry.v1; package net.fabricmc.fabric.api.client.rendereregistry.v1;
import java.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.EntityModelLayer; import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.impl.client.renderer.registry.EntityModelLayerImpl;
import net.fabricmc.fabric.mixin.client.renderer.registry.EntityModelLayersAccessor;
/** /**
* A helpers for registering entity model layers and providers for the layer's textured model data. * A helpers for registering entity model layers and providers for the layer's textured model data.
* *
* @deprecated Experimental feature, may be removed or changed without further notice: Snapshot feature. * @deprecated This module has been moved into fabric-rendering-v1. Use {@link net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.Experimental
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public final class EntityModelLayerRegistry { public final class EntityModelLayerRegistry {
/** /**
@ -44,21 +37,14 @@ public final class EntityModelLayerRegistry {
* @param provider the provider for the textured model data * @param provider the provider for the textured model data
*/ */
public static void registerModelLayer(EntityModelLayer modelLayer, TexturedModelDataProvider provider) { public static void registerModelLayer(EntityModelLayer modelLayer, TexturedModelDataProvider provider) {
Objects.requireNonNull(modelLayer, "EntityModelLayer cannot be null"); net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry.registerModelLayer(modelLayer, provider::createModelData);
Objects.requireNonNull(provider, "TexturedModelDataProvider cannot be null");
if (EntityModelLayerImpl.PROVIDERS.putIfAbsent(modelLayer, provider) != null) {
throw new IllegalArgumentException(String.format("Cannot replace registration for entity model layer \"%s\"", modelLayer));
}
EntityModelLayersAccessor.getLayers().add(modelLayer);
} }
private EntityModelLayerRegistry() { private EntityModelLayerRegistry() {
} }
@FunctionalInterface @FunctionalInterface
@ApiStatus.Experimental @Deprecated
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public interface TexturedModelDataProvider { public interface TexturedModelDataProvider {
/** /**

View file

@ -22,13 +22,19 @@ import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.fabricmc.fabric.impl.client.renderer.registry.EntityRendererRegistryImpl;
/** /**
* Helper class for registering EntityRenderers. * Helper class for registering EntityRenderers.
*
* @deprecated This module has been moved into fabric-rendering-v1. Use {@link net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry} instead
*/ */
@Deprecated
public interface EntityRendererRegistry { public interface EntityRendererRegistry {
EntityRendererRegistry INSTANCE = new EntityRendererRegistryImpl(); EntityRendererRegistry INSTANCE = new EntityRendererRegistry() {
@Override
public <T extends Entity> void register(EntityType<? extends T> entityType, EntityRendererFactory<T> factory) {
net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry.register(entityType, factory);
}
};
/** /**
* Register a BlockEntityRenderer for a BlockEntityType. Can be called clientside before the world is rendered. * Register a BlockEntityRenderer for a BlockEntityType. Can be called clientside before the world is rendered.

View file

@ -45,15 +45,14 @@ import net.fabricmc.fabric.api.event.EventFactory;
* } * }
* }); * });
* </pre></blockquote> * </pre></blockquote>
*
* @deprecated This module has been moved into fabric-rendering-v1. Use {@link net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback} instead
*/ */
@FunctionalInterface @FunctionalInterface
@Deprecated
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public interface LivingEntityFeatureRendererRegistrationCallback { public interface LivingEntityFeatureRendererRegistrationCallback {
Event<LivingEntityFeatureRendererRegistrationCallback> EVENT = EventFactory.createArrayBacked(LivingEntityFeatureRendererRegistrationCallback.class, callbacks -> (entityType, entityRenderer, registrationHelper, context) -> { Event<LivingEntityFeatureRendererRegistrationCallback> EVENT = createEvent();
for (LivingEntityFeatureRendererRegistrationCallback callback : callbacks) {
callback.registerRenderers(entityType, entityRenderer, registrationHelper, context);
}
});
/** /**
* Called when feature renderers may be registered. * Called when feature renderers may be registered.
@ -63,11 +62,26 @@ public interface LivingEntityFeatureRendererRegistrationCallback {
*/ */
void registerRenderers(EntityType<? extends LivingEntity> entityType, LivingEntityRenderer<?, ?> entityRenderer, RegistrationHelper registrationHelper, EntityRendererFactory.Context context); void registerRenderers(EntityType<? extends LivingEntity> entityType, LivingEntityRenderer<?, ?> entityRenderer, RegistrationHelper registrationHelper, EntityRendererFactory.Context context);
private static Event<LivingEntityFeatureRendererRegistrationCallback> createEvent() {
Event<LivingEntityFeatureRendererRegistrationCallback> event = EventFactory.createArrayBacked(LivingEntityFeatureRendererRegistrationCallback.class, callbacks -> (entityType, entityRenderer, registrationHelper, context) -> {
for (LivingEntityFeatureRendererRegistrationCallback callback : callbacks) {
callback.registerRenderers(entityType, entityRenderer, registrationHelper, context);
}
});
net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> {
LivingEntityFeatureRendererRegistrationCallback.EVENT.invoker().registerRenderers(entityType, entityRenderer, registrationHelper::register, context);
});
return event;
}
/** /**
* A delegate object used to help register feature renderers for an entity renderer. * A delegate object used to help register feature renderers for an entity renderer.
* *
* <p>This is not meant for implementation by users of the API. * <p>This is not meant for implementation by users of the API.
*
* @deprecated This module has been moved into fabric-rendering-v1. Use {@link net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback.RegistrationHelper} instead
*/ */
@Deprecated
interface RegistrationHelper { interface RegistrationHelper {
/** /**
* Adds a feature renderer to the entity renderer. * Adds a feature renderer to the entity renderer.

View file

@ -1,15 +0,0 @@
{
"required": true,
"package": "net.fabricmc.fabric.mixin.client.renderer.registry",
"compatibilityLevel": "JAVA_16",
"client": [
"EntityModelLayersAccessor",
"EntityModelsMixin",
"LivingEntityRendererAccessor",
"MixinBlockEntityRenderers",
"MixinEntityRenderers"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -18,13 +18,11 @@
"depends": { "depends": {
"fabricloader": ">=0.4.0", "fabricloader": ">=0.4.0",
"minecraft": ">=1.15-alpha.19.39.a", "minecraft": ">=1.15-alpha.19.39.a",
"fabric-api-base": "*" "fabric-api-base": "*",
"fabric-rendering-v1": "*"
}, },
"description": "Registries for entity and block renderers.", "description": "Registries for entity and block renderers.",
"mixins": [
"fabric-renderer-registries-v1.mixins.json"
],
"custom": { "custom": {
"fabric-api:module-lifecycle": "stable" "fabric-api:module-lifecycle": "deprecated"
} }
} }

View file

@ -1,16 +0,0 @@
{
"schemaVersion": 1,
"id": "fabric-renderer-registries-v1-testmod",
"name": "Fabric Render Registries (v1) Test Mod",
"version": "1.0.0",
"environment": "*",
"license": "Apache-2.0",
"depends": {
"fabric-item-api-v1": "*"
},
"entrypoints": {
"client": [
"net.fabricmc.fabric.test.renderer.registry.FeatureRendererTest"
]
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.api.client.rendering.v1;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.impl.client.rendering.BlockEntityRendererRegistryImpl;
/**
* Helper class for registering BlockEntityRenderers.
*/
@Environment(EnvType.CLIENT)
public final class BlockEntityRendererRegistry {
/**
* Register a BlockEntityRenderer for a BlockEntityType. Can be called clientside before the world is rendered.
*
* @param blockEntityType the {@link BlockEntityType} to register a renderer for
* @param blockEntityRendererFactory a {@link BlockEntityRendererFactory} that creates a {@link BlockEntityRenderer}, called
* when {@link BlockEntityRenderDispatcher} is initialized or immediately if the dispatcher
* class is already loaded
* @param <E> the {@link BlockEntity}
*/
public static <E extends BlockEntity> void register(BlockEntityType<E> blockEntityType, BlockEntityRendererFactory<? super E> blockEntityRendererFactory) {
BlockEntityRendererRegistryImpl.register(blockEntityType, blockEntityRendererFactory);
}
private BlockEntityRendererRegistry() {
}
}

View file

@ -0,0 +1,64 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.api.client.rendering.v1;
import java.util.Objects;
import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.impl.client.rendering.EntityModelLayerImpl;
import net.fabricmc.fabric.mixin.client.rendering.EntityModelLayersAccessor;
/**
* A helpers for registering entity model layers and providers for the layer's textured model data.
*/
@Environment(EnvType.CLIENT)
public final class EntityModelLayerRegistry {
/**
* Registers an entity model layer and registers a provider for a {@linkplain TexturedModelData}.
*
* @param modelLayer the entity model layer
* @param provider the provider for the textured model data
*/
public static void registerModelLayer(EntityModelLayer modelLayer, TexturedModelDataProvider provider) {
Objects.requireNonNull(modelLayer, "EntityModelLayer cannot be null");
Objects.requireNonNull(provider, "TexturedModelDataProvider cannot be null");
if (EntityModelLayerImpl.PROVIDERS.putIfAbsent(modelLayer, provider) != null) {
throw new IllegalArgumentException(String.format("Cannot replace registration for entity model layer \"%s\"", modelLayer));
}
EntityModelLayersAccessor.getLayers().add(modelLayer);
}
private EntityModelLayerRegistry() {
}
@FunctionalInterface
@Environment(EnvType.CLIENT)
public interface TexturedModelDataProvider {
/**
* Creates the textured model data for use in a {@link EntityModelLayer}.
*
* @return the textured model data for the entity model layer.
*/
TexturedModelData createModelData();
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.api.client.rendering.v1;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.impl.client.rendering.EntityRendererRegistryImpl;
/**
* Helper class for registering EntityRenderers.
*/
@Environment(EnvType.CLIENT)
public final class EntityRendererRegistry {
/**
* Register a BlockEntityRenderer for a BlockEntityType. Can be called clientside before the world is rendered.
*
* @param entityType the {@link EntityType} to register a renderer for
* @param entityRendererFactory a {@link EntityRendererFactory} that creates a {@link EntityRenderer}, called
* when {@link EntityRenderDispatcher} is initialized or immediately if the dispatcher
* class is already loaded
* @param <E> the {@link Entity}
*/
public static <E extends Entity> void register(EntityType<? extends E> entityType, EntityRendererFactory<E> entityRendererFactory) {
EntityRendererRegistryImpl.register(entityType, entityRendererFactory);
}
private EntityRendererRegistry() {
}
}

View file

@ -0,0 +1,83 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.api.client.rendering.v1;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.feature.Deadmau5FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
/**
* Called when {@link FeatureRenderer feature renderers} for a {@link LivingEntityRenderer living entity renderer} are registered.
*
* <p>Feature renderers are typically used for rendering additional objects on an entity, such as armor, an elytra or {@link Deadmau5FeatureRenderer Deadmau5's ears}.
* This callback lets developers add additional feature renderers for use in entity rendering.
* Listeners should filter out the specific entity renderer they want to hook into, usually through {@code instanceof} checks or filtering by entity type.
* Once listeners find a suitable entity renderer, they should register their feature renderer via the registration helper.
*
* <p>For example, to register a feature renderer for a player model, the example below may used:
* <blockquote><pre>
* LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper) -> {
* if (entityRenderer instanceof PlayerEntityModel) {
* registrationHelper.register(new MyFeatureRenderer((PlayerEntityModel) entityRenderer));
* }
* });
* </pre></blockquote>
*/
@FunctionalInterface
@Environment(EnvType.CLIENT)
public interface LivingEntityFeatureRendererRegistrationCallback {
Event<LivingEntityFeatureRendererRegistrationCallback> EVENT = EventFactory.createArrayBacked(LivingEntityFeatureRendererRegistrationCallback.class, callbacks -> (entityType, entityRenderer, registrationHelper, context) -> {
for (LivingEntityFeatureRendererRegistrationCallback callback : callbacks) {
callback.registerRenderers(entityType, entityRenderer, registrationHelper, context);
}
});
/**
* Called when feature renderers may be registered.
*
* @param entityType the entity type of the renderer
* @param entityRenderer the entity renderer
*/
void registerRenderers(EntityType<? extends LivingEntity> entityType, LivingEntityRenderer<?, ?> entityRenderer, RegistrationHelper registrationHelper, EntityRendererFactory.Context context);
/**
* A delegate object used to help register feature renderers for an entity renderer.
*
* <p>This is not meant for implementation by users of the API.
*/
@ApiStatus.NonExtendable
interface RegistrationHelper {
/**
* Adds a feature renderer to the entity renderer.
*
* @param featureRenderer the feature renderer
* @param <T> the type of entity
*/
<T extends LivingEntity> void register(FeatureRenderer<T, ? extends EntityModel<T>> featureRenderer);
}
}

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.impl.client.renderer.registry; package net.fabricmc.fabric.impl.client.rendering;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
@ -23,19 +23,19 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry; public final class BlockEntityRendererRegistryImpl {
private static final HashMap<BlockEntityType<?>, BlockEntityRendererFactory<?>> MAP = new HashMap<>();
private static BiConsumer<BlockEntityType<?>, BlockEntityRendererFactory<?>> handler = (type, function) -> MAP.put(type, function);
public class BlockEntityRendererRegistryImpl implements BlockEntityRendererRegistry { public static <E extends BlockEntity> void register(BlockEntityType<E> blockEntityType, BlockEntityRendererFactory<? super E> blockEntityRendererFactory) {
private static HashMap<BlockEntityType<?>, BlockEntityRendererFactory<?>> map = new HashMap<>();
private static BiConsumer<BlockEntityType<?>, BlockEntityRendererFactory<?>> handler = (type, function) -> map.put(type, function);
@Override
public <E extends BlockEntity> void register(BlockEntityType<E> blockEntityType, BlockEntityRendererFactory<? super E> blockEntityRendererFactory) {
handler.accept(blockEntityType, blockEntityRendererFactory); handler.accept(blockEntityType, blockEntityRendererFactory);
} }
public static void setup(BiConsumer<BlockEntityType<?>, BlockEntityRendererFactory<?>> vanillaHandler) { public static void setup(BiConsumer<BlockEntityType<?>, BlockEntityRendererFactory<?>> vanillaHandler) {
map.forEach(vanillaHandler); MAP.forEach(vanillaHandler);
handler = vanillaHandler; handler = vanillaHandler;
} }
private BlockEntityRendererRegistryImpl() {
}
} }

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.impl.client.renderer.registry; package net.fabricmc.fabric.impl.client.rendering;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -23,7 +23,7 @@ import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityModelLayerRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public final class EntityModelLayerImpl { public final class EntityModelLayerImpl {

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.impl.client.renderer.registry; package net.fabricmc.fabric.impl.client.rendering;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
@ -23,16 +23,14 @@ import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
/** /**
* Helper class for registering EntityRenderers. * Helper class for registering EntityRenderers.
*/ */
public final class EntityRendererRegistryImpl implements EntityRendererRegistry { public final class EntityRendererRegistryImpl {
private static HashMap<EntityType<?>, EntityRendererFactory<?>> map = new HashMap<>(); private static HashMap<EntityType<?>, EntityRendererFactory<?>> map = new HashMap<>();
private static BiConsumer<EntityType<?>, EntityRendererFactory<?>> handler = (type, function) -> map.put(type, function); private static BiConsumer<EntityType<?>, EntityRendererFactory<?>> handler = (type, function) -> map.put(type, function);
public <T extends Entity> void register(EntityType<? extends T> entityType, EntityRendererFactory<T> factory) { public static <T extends Entity> void register(EntityType<? extends T> entityType, EntityRendererFactory<T> factory) {
handler.accept(entityType, factory); handler.accept(entityType, factory);
} }
@ -40,4 +38,7 @@ public final class EntityRendererRegistryImpl implements EntityRendererRegistry
map.forEach(vanillaHandler); map.forEach(vanillaHandler);
handler = vanillaHandler; handler = vanillaHandler;
} }
private EntityRendererRegistryImpl() {
}
} }

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.impl.client.renderer.registry; package net.fabricmc.fabric.impl.client.rendering;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
@ -23,7 +23,7 @@ import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback; import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
public final class RegistrationHelperImpl implements LivingEntityFeatureRendererRegistrationCallback.RegistrationHelper { public final class RegistrationHelperImpl implements LivingEntityFeatureRendererRegistrationCallback.RegistrationHelper {
private final Function<FeatureRenderer<?, ?>, Boolean> delegate; private final Function<FeatureRenderer<?, ?>, Boolean> delegate;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.mixin.client.renderer.registry; package net.fabricmc.fabric.mixin.client.rendering;
import java.util.Set; import java.util.Set;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.mixin.client.renderer.registry; package net.fabricmc.fabric.mixin.client.rendering;
import java.util.Map; import java.util.Map;
@ -29,8 +29,8 @@ import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.EntityModelLayer; import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.render.entity.model.EntityModels; import net.minecraft.client.render.entity.model.EntityModels;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityModelLayerRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.impl.client.renderer.registry.EntityModelLayerImpl; import net.fabricmc.fabric.impl.client.rendering.EntityModelLayerImpl;
@Mixin(EntityModels.class) @Mixin(EntityModels.class)
abstract class EntityModelsMixin { abstract class EntityModelsMixin {

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.mixin.client.renderer.registry; package net.fabricmc.fabric.mixin.client.rendering;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker; import org.spongepowered.asm.mixin.gen.Invoker;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.mixin.client.renderer.registry; package net.fabricmc.fabric.mixin.client.rendering;
import java.util.Map; import java.util.Map;
@ -29,7 +29,7 @@ import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories; import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.fabricmc.fabric.impl.client.renderer.registry.BlockEntityRendererRegistryImpl; import net.fabricmc.fabric.impl.client.rendering.BlockEntityRendererRegistryImpl;
@Mixin(BlockEntityRendererFactories.class) @Mixin(BlockEntityRendererFactories.class)
public abstract class MixinBlockEntityRenderers { public abstract class MixinBlockEntityRenderers {

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.mixin.client.renderer.registry; package net.fabricmc.fabric.mixin.client.rendering;
import java.util.Map; import java.util.Map;
@ -36,9 +36,9 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback; import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.fabricmc.fabric.impl.client.renderer.registry.RegistrationHelperImpl; import net.fabricmc.fabric.impl.client.rendering.EntityRendererRegistryImpl;
import net.fabricmc.fabric.impl.client.renderer.registry.EntityRendererRegistryImpl; import net.fabricmc.fabric.impl.client.rendering.RegistrationHelperImpl;
@Mixin(EntityRenderers.class) @Mixin(EntityRenderers.class)
public abstract class MixinEntityRenderers { public abstract class MixinEntityRenderers {

View file

@ -8,7 +8,12 @@
"MixinBuiltinModelItemRenderer", "MixinBuiltinModelItemRenderer",
"MixinInGameHud", "MixinInGameHud",
"MixinItemColorMap", "MixinItemColorMap",
"MixinWorldRenderer" "MixinWorldRenderer",
"EntityModelLayersAccessor",
"EntityModelsMixin",
"LivingEntityRendererAccessor",
"MixinBlockEntityRenderers",
"MixinEntityRenderers"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.test.renderer.registry; package net.fabricmc.fabric.test.rendering.client;
import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.AbstractClientPlayerEntity;
@ -35,7 +35,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.decoration.ArmorStandEntity;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback; import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
/** /**
* This test exists solely for testing generics. * This test exists solely for testing generics.

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.test.renderer.registry; package net.fabricmc.fabric.test.rendering.client;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -33,7 +33,7 @@ import net.minecraft.entity.EntityType;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback; import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
public final class FeatureRendererTest implements ClientModInitializer { public final class FeatureRendererTest implements ClientModInitializer {
private static final Logger LOGGER = LogManager.getLogger(FeatureRendererTest.class); private static final Logger LOGGER = LogManager.getLogger(FeatureRendererTest.class);

View file

@ -11,7 +11,8 @@
"entrypoints": { "entrypoints": {
"client": [ "client": [
"net.fabricmc.fabric.test.rendering.client.WorldRenderEventsTests", "net.fabricmc.fabric.test.rendering.client.WorldRenderEventsTests",
"net.fabricmc.fabric.test.rendering.client.ArmorRenderingTests" "net.fabricmc.fabric.test.rendering.client.ArmorRenderingTests",
"net.fabricmc.fabric.test.rendering.client.FeatureRendererTest"
] ]
} }
} }