diff --git a/fabric-renderer-registries-v1/build.gradle b/fabric-renderer-registries-v1/build.gradle index b6972df80..9d5e47236 100644 --- a/fabric-renderer-registries-v1/build.gradle +++ b/fabric-renderer-registries-v1/build.gradle @@ -1,10 +1,7 @@ archivesBaseName = "fabric-renderer-registries-v1" version = getSubprojectVersion(project, "3.2.0") -dependencies { - testmodImplementation project(path: ':fabric-lifecycle-events-v1', configuration: 'dev') -} - moduleDependencies(project, [ - 'fabric-api-base' + 'fabric-api-base', + 'fabric-rendering-v1' ]) diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/BlockEntityRendererRegistry.java b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/BlockEntityRendererRegistry.java index 88637fd41..1bcb447cf 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/BlockEntityRendererRegistry.java +++ b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/BlockEntityRendererRegistry.java @@ -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.BlockEntityRenderer; -import net.fabricmc.fabric.impl.client.renderer.registry.BlockEntityRendererRegistryImpl; - /** * 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 { - BlockEntityRendererRegistry INSTANCE = new BlockEntityRendererRegistryImpl(); + BlockEntityRendererRegistry INSTANCE = new BlockEntityRendererRegistry() { + @Override + public void register(BlockEntityType blockEntityType, BlockEntityRendererFactory 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. diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityModelLayerRegistry.java b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityModelLayerRegistry.java index c4553f54c..93fea8d45 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityModelLayerRegistry.java +++ b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityModelLayerRegistry.java @@ -16,25 +16,18 @@ 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.render.entity.model.EntityModelLayer; import net.fabricmc.api.EnvType; 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. * - * @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 -@ApiStatus.Experimental @Environment(EnvType.CLIENT) public final class EntityModelLayerRegistry { /** @@ -44,21 +37,14 @@ public final class EntityModelLayerRegistry { * @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); + net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry.registerModelLayer(modelLayer, provider::createModelData); } private EntityModelLayerRegistry() { } @FunctionalInterface - @ApiStatus.Experimental + @Deprecated @Environment(EnvType.CLIENT) public interface TexturedModelDataProvider { /** diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityRendererRegistry.java b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityRendererRegistry.java index bedff324a..d6ab759ac 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityRendererRegistry.java +++ b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/EntityRendererRegistry.java @@ -22,13 +22,19 @@ import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; -import net.fabricmc.fabric.impl.client.renderer.registry.EntityRendererRegistryImpl; - /** * 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 { - EntityRendererRegistry INSTANCE = new EntityRendererRegistryImpl(); + EntityRendererRegistry INSTANCE = new EntityRendererRegistry() { + @Override + public void register(EntityType entityType, EntityRendererFactory 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. diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/LivingEntityFeatureRendererRegistrationCallback.java b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/LivingEntityFeatureRendererRegistrationCallback.java index 7b662c034..5d216a8c3 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/LivingEntityFeatureRendererRegistrationCallback.java +++ b/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/api/client/rendereregistry/v1/LivingEntityFeatureRendererRegistrationCallback.java @@ -45,15 +45,14 @@ import net.fabricmc.fabric.api.event.EventFactory; * } * }); * + * + * @deprecated This module has been moved into fabric-rendering-v1. Use {@link net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback} instead */ @FunctionalInterface +@Deprecated @Environment(EnvType.CLIENT) public interface LivingEntityFeatureRendererRegistrationCallback { - Event EVENT = EventFactory.createArrayBacked(LivingEntityFeatureRendererRegistrationCallback.class, callbacks -> (entityType, entityRenderer, registrationHelper, context) -> { - for (LivingEntityFeatureRendererRegistrationCallback callback : callbacks) { - callback.registerRenderers(entityType, entityRenderer, registrationHelper, context); - } - }); + Event EVENT = createEvent(); /** * Called when feature renderers may be registered. @@ -63,11 +62,26 @@ public interface LivingEntityFeatureRendererRegistrationCallback { */ void registerRenderers(EntityType entityType, LivingEntityRenderer entityRenderer, RegistrationHelper registrationHelper, EntityRendererFactory.Context context); + private static Event createEvent() { + Event 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. * *

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 { /** * Adds a feature renderer to the entity renderer. diff --git a/fabric-renderer-registries-v1/src/main/resources/fabric-renderer-registries-v1.mixins.json b/fabric-renderer-registries-v1/src/main/resources/fabric-renderer-registries-v1.mixins.json deleted file mode 100644 index ff26cdcfc..000000000 --- a/fabric-renderer-registries-v1/src/main/resources/fabric-renderer-registries-v1.mixins.json +++ /dev/null @@ -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 - } -} diff --git a/fabric-renderer-registries-v1/src/main/resources/fabric.mod.json b/fabric-renderer-registries-v1/src/main/resources/fabric.mod.json index 2ed23dcb8..4fafae95c 100644 --- a/fabric-renderer-registries-v1/src/main/resources/fabric.mod.json +++ b/fabric-renderer-registries-v1/src/main/resources/fabric.mod.json @@ -18,13 +18,11 @@ "depends": { "fabricloader": ">=0.4.0", "minecraft": ">=1.15-alpha.19.39.a", - "fabric-api-base": "*" + "fabric-api-base": "*", + "fabric-rendering-v1": "*" }, "description": "Registries for entity and block renderers.", - "mixins": [ - "fabric-renderer-registries-v1.mixins.json" - ], "custom": { - "fabric-api:module-lifecycle": "stable" + "fabric-api:module-lifecycle": "deprecated" } } diff --git a/fabric-renderer-registries-v1/src/testmod/resources/fabric.mod.json b/fabric-renderer-registries-v1/src/testmod/resources/fabric.mod.json deleted file mode 100644 index a9bbee589..000000000 --- a/fabric-renderer-registries-v1/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -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" - ] - } -} diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BlockEntityRendererRegistry.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BlockEntityRendererRegistry.java new file mode 100644 index 000000000..f32598046 --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BlockEntityRendererRegistry.java @@ -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 the {@link BlockEntity} + */ + public static void register(BlockEntityType blockEntityType, BlockEntityRendererFactory blockEntityRendererFactory) { + BlockEntityRendererRegistryImpl.register(blockEntityType, blockEntityRendererFactory); + } + + private BlockEntityRendererRegistry() { + } +} diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/EntityModelLayerRegistry.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/EntityModelLayerRegistry.java new file mode 100644 index 000000000..19a824a93 --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/EntityModelLayerRegistry.java @@ -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(); + } +} diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/EntityRendererRegistry.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/EntityRendererRegistry.java new file mode 100644 index 000000000..c0a45a0a7 --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/EntityRendererRegistry.java @@ -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 the {@link Entity} + */ + public static void register(EntityType entityType, EntityRendererFactory entityRendererFactory) { + EntityRendererRegistryImpl.register(entityType, entityRendererFactory); + } + + private EntityRendererRegistry() { + } +} diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/LivingEntityFeatureRendererRegistrationCallback.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/LivingEntityFeatureRendererRegistrationCallback.java new file mode 100644 index 000000000..39f1d0412 --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/LivingEntityFeatureRendererRegistrationCallback.java @@ -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. + * + *

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. + * + *

For example, to register a feature renderer for a player model, the example below may used: + *

+ * LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper) -> {
+ * 	if (entityRenderer instanceof PlayerEntityModel) {
+ * 		registrationHelper.register(new MyFeatureRenderer((PlayerEntityModel) entityRenderer));
+ * 	}
+ * });
+ * 
+ */ +@FunctionalInterface +@Environment(EnvType.CLIENT) +public interface LivingEntityFeatureRendererRegistrationCallback { + Event 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 entityType, LivingEntityRenderer entityRenderer, RegistrationHelper registrationHelper, EntityRendererFactory.Context context); + + /** + * A delegate object used to help register feature renderers for an entity renderer. + * + *

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 the type of entity + */ + void register(FeatureRenderer> featureRenderer); + } +} diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/BlockEntityRendererRegistryImpl.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BlockEntityRendererRegistryImpl.java similarity index 65% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/BlockEntityRendererRegistryImpl.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BlockEntityRendererRegistryImpl.java index 972041acc..f68004271 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/BlockEntityRendererRegistryImpl.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BlockEntityRendererRegistryImpl.java @@ -14,7 +14,7 @@ * 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.function.BiConsumer; @@ -23,19 +23,19 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; 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, BlockEntityRendererFactory> MAP = new HashMap<>(); + private static BiConsumer, BlockEntityRendererFactory> handler = (type, function) -> MAP.put(type, function); -public class BlockEntityRendererRegistryImpl implements BlockEntityRendererRegistry { - private static HashMap, BlockEntityRendererFactory> map = new HashMap<>(); - private static BiConsumer, BlockEntityRendererFactory> handler = (type, function) -> map.put(type, function); - - @Override - public void register(BlockEntityType blockEntityType, BlockEntityRendererFactory blockEntityRendererFactory) { + public static void register(BlockEntityType blockEntityType, BlockEntityRendererFactory blockEntityRendererFactory) { handler.accept(blockEntityType, blockEntityRendererFactory); } public static void setup(BiConsumer, BlockEntityRendererFactory> vanillaHandler) { - map.forEach(vanillaHandler); + MAP.forEach(vanillaHandler); handler = vanillaHandler; } + + private BlockEntityRendererRegistryImpl() { + } } diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/EntityModelLayerImpl.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/EntityModelLayerImpl.java similarity index 87% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/EntityModelLayerImpl.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/EntityModelLayerImpl.java index c2bc300b1..a521749e4 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/EntityModelLayerImpl.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/EntityModelLayerImpl.java @@ -14,7 +14,7 @@ * 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.Map; @@ -23,7 +23,7 @@ import net.minecraft.client.render.entity.model.EntityModelLayer; import net.fabricmc.api.EnvType; 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) public final class EntityModelLayerImpl { diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/EntityRendererRegistryImpl.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/EntityRendererRegistryImpl.java similarity index 79% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/EntityRendererRegistryImpl.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/EntityRendererRegistryImpl.java index 0040bb70f..8697fae82 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/EntityRendererRegistryImpl.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/EntityRendererRegistryImpl.java @@ -14,7 +14,7 @@ * 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.function.BiConsumer; @@ -23,16 +23,14 @@ import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; -import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; - /** * Helper class for registering EntityRenderers. */ -public final class EntityRendererRegistryImpl implements EntityRendererRegistry { +public final class EntityRendererRegistryImpl { private static HashMap, EntityRendererFactory> map = new HashMap<>(); private static BiConsumer, EntityRendererFactory> handler = (type, function) -> map.put(type, function); - public void register(EntityType entityType, EntityRendererFactory factory) { + public static void register(EntityType entityType, EntityRendererFactory factory) { handler.accept(entityType, factory); } @@ -40,4 +38,7 @@ public final class EntityRendererRegistryImpl implements EntityRendererRegistry map.forEach(vanillaHandler); handler = vanillaHandler; } + + private EntityRendererRegistryImpl() { + } } diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/RegistrationHelperImpl.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/RegistrationHelperImpl.java similarity index 89% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/RegistrationHelperImpl.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/RegistrationHelperImpl.java index c8f0b1c26..974df9647 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/impl/client/renderer/registry/RegistrationHelperImpl.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/RegistrationHelperImpl.java @@ -14,7 +14,7 @@ * 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.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.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 { private final Function, Boolean> delegate; diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/EntityModelLayersAccessor.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/EntityModelLayersAccessor.java similarity index 94% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/EntityModelLayersAccessor.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/EntityModelLayersAccessor.java index a0bea64d2..6a9647692 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/EntityModelLayersAccessor.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/EntityModelLayersAccessor.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.client.renderer.registry; +package net.fabricmc.fabric.mixin.client.rendering; import java.util.Set; diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/EntityModelsMixin.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/EntityModelsMixin.java similarity index 89% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/EntityModelsMixin.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/EntityModelsMixin.java index 9d1627f12..faca291fb 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/EntityModelsMixin.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/EntityModelsMixin.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.client.renderer.registry; +package net.fabricmc.fabric.mixin.client.rendering; 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.EntityModels; -import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityModelLayerRegistry; -import net.fabricmc.fabric.impl.client.renderer.registry.EntityModelLayerImpl; +import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; +import net.fabricmc.fabric.impl.client.rendering.EntityModelLayerImpl; @Mixin(EntityModels.class) abstract class EntityModelsMixin { diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/LivingEntityRendererAccessor.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/LivingEntityRendererAccessor.java similarity index 95% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/LivingEntityRendererAccessor.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/LivingEntityRendererAccessor.java index 1b76f1df0..88fba9c03 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/LivingEntityRendererAccessor.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/LivingEntityRendererAccessor.java @@ -14,7 +14,7 @@ * 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.gen.Invoker; diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/MixinBlockEntityRenderers.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinBlockEntityRenderers.java similarity index 91% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/MixinBlockEntityRenderers.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinBlockEntityRenderers.java index 31cb70e48..8618d949c 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/MixinBlockEntityRenderers.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinBlockEntityRenderers.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.client.renderer.registry; +package net.fabricmc.fabric.mixin.client.rendering; 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.block.entity.BlockEntityType; -import net.fabricmc.fabric.impl.client.renderer.registry.BlockEntityRendererRegistryImpl; +import net.fabricmc.fabric.impl.client.rendering.BlockEntityRendererRegistryImpl; @Mixin(BlockEntityRendererFactories.class) public abstract class MixinBlockEntityRenderers { diff --git a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/MixinEntityRenderers.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinEntityRenderers.java similarity index 92% rename from fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/MixinEntityRenderers.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinEntityRenderers.java index 7efd4abbd..4d9bf9539 100644 --- a/fabric-renderer-registries-v1/src/main/java/net/fabricmc/fabric/mixin/client/renderer/registry/MixinEntityRenderers.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinEntityRenderers.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.client.renderer.registry; +package net.fabricmc.fabric.mixin.client.rendering; import java.util.Map; @@ -36,9 +36,9 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback; -import net.fabricmc.fabric.impl.client.renderer.registry.RegistrationHelperImpl; -import net.fabricmc.fabric.impl.client.renderer.registry.EntityRendererRegistryImpl; +import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback; +import net.fabricmc.fabric.impl.client.rendering.EntityRendererRegistryImpl; +import net.fabricmc.fabric.impl.client.rendering.RegistrationHelperImpl; @Mixin(EntityRenderers.class) public abstract class MixinEntityRenderers { diff --git a/fabric-rendering-v1/src/main/resources/fabric-rendering-v1.mixins.json b/fabric-rendering-v1/src/main/resources/fabric-rendering-v1.mixins.json index e794041a0..ec5d892bf 100644 --- a/fabric-rendering-v1/src/main/resources/fabric-rendering-v1.mixins.json +++ b/fabric-rendering-v1/src/main/resources/fabric-rendering-v1.mixins.json @@ -8,7 +8,12 @@ "MixinBuiltinModelItemRenderer", "MixinInGameHud", "MixinItemColorMap", - "MixinWorldRenderer" + "MixinWorldRenderer", + "EntityModelLayersAccessor", + "EntityModelsMixin", + "LivingEntityRendererAccessor", + "MixinBlockEntityRenderers", + "MixinEntityRenderers" ], "injectors": { "defaultRequire": 1 diff --git a/fabric-renderer-registries-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/registry/FeatureRendererGenericTests.java b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/client/FeatureRendererGenericTests.java similarity index 97% rename from fabric-renderer-registries-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/registry/FeatureRendererGenericTests.java rename to fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/client/FeatureRendererGenericTests.java index b7645c13c..170054ce2 100644 --- a/fabric-renderer-registries-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/registry/FeatureRendererGenericTests.java +++ b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/client/FeatureRendererGenericTests.java @@ -14,7 +14,7 @@ * 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.network.AbstractClientPlayerEntity; @@ -35,7 +35,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.decoration.ArmorStandEntity; 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. diff --git a/fabric-renderer-registries-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/registry/FeatureRendererTest.java b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/client/FeatureRendererTest.java similarity index 96% rename from fabric-renderer-registries-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/registry/FeatureRendererTest.java rename to fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/client/FeatureRendererTest.java index 4f978633c..0bb8d6065 100644 --- a/fabric-renderer-registries-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/registry/FeatureRendererTest.java +++ b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/client/FeatureRendererTest.java @@ -14,7 +14,7 @@ * 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.Logger; @@ -33,7 +33,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.util.registry.Registry; 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 { private static final Logger LOGGER = LogManager.getLogger(FeatureRendererTest.class); diff --git a/fabric-rendering-v1/src/testmod/resources/fabric.mod.json b/fabric-rendering-v1/src/testmod/resources/fabric.mod.json index c1eb0a5ed..f7e2de62a 100644 --- a/fabric-rendering-v1/src/testmod/resources/fabric.mod.json +++ b/fabric-rendering-v1/src/testmod/resources/fabric.mod.json @@ -11,7 +11,8 @@ "entrypoints": { "client": [ "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" ] } }