mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-26 09:38:08 -05:00
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:
parent
8195aec1e2
commit
2a2a2c5485
25 changed files with 332 additions and 104 deletions
|
@ -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'
|
||||
])
|
||||
|
|
|
@ -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 <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.
|
||||
|
|
|
@ -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 {
|
||||
/**
|
||||
|
|
|
@ -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 <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.
|
||||
|
|
|
@ -45,15 +45,14 @@ import net.fabricmc.fabric.api.event.EventFactory;
|
|||
* }
|
||||
* });
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @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<LivingEntityFeatureRendererRegistrationCallback> EVENT = EventFactory.createArrayBacked(LivingEntityFeatureRendererRegistrationCallback.class, callbacks -> (entityType, entityRenderer, registrationHelper, context) -> {
|
||||
for (LivingEntityFeatureRendererRegistrationCallback callback : callbacks) {
|
||||
callback.registerRenderers(entityType, entityRenderer, registrationHelper, context);
|
||||
}
|
||||
});
|
||||
Event<LivingEntityFeatureRendererRegistrationCallback> EVENT = createEvent();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
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.
|
||||
*
|
||||
* <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 {
|
||||
/**
|
||||
* Adds a feature renderer to the entity renderer.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -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() {
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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() {
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<BlockEntityType<?>, BlockEntityRendererFactory<?>> MAP = new HashMap<>();
|
||||
private static BiConsumer<BlockEntityType<?>, BlockEntityRendererFactory<?>> handler = (type, function) -> MAP.put(type, function);
|
||||
|
||||
public class BlockEntityRendererRegistryImpl implements BlockEntityRendererRegistry {
|
||||
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) {
|
||||
public static <E extends BlockEntity> void register(BlockEntityType<E> blockEntityType, BlockEntityRendererFactory<? super E> blockEntityRendererFactory) {
|
||||
handler.accept(blockEntityType, blockEntityRendererFactory);
|
||||
}
|
||||
|
||||
public static void setup(BiConsumer<BlockEntityType<?>, BlockEntityRendererFactory<?>> vanillaHandler) {
|
||||
map.forEach(vanillaHandler);
|
||||
MAP.forEach(vanillaHandler);
|
||||
handler = vanillaHandler;
|
||||
}
|
||||
|
||||
private BlockEntityRendererRegistryImpl() {
|
||||
}
|
||||
}
|
|
@ -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 {
|
|
@ -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<EntityType<?>, EntityRendererFactory<?>> map = new HashMap<>();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -40,4 +38,7 @@ public final class EntityRendererRegistryImpl implements EntityRendererRegistry
|
|||
map.forEach(vanillaHandler);
|
||||
handler = vanillaHandler;
|
||||
}
|
||||
|
||||
private EntityRendererRegistryImpl() {
|
||||
}
|
||||
}
|
|
@ -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<FeatureRenderer<?, ?>, Boolean> delegate;
|
|
@ -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;
|
||||
|
|
@ -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 {
|
|
@ -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;
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -8,7 +8,12 @@
|
|||
"MixinBuiltinModelItemRenderer",
|
||||
"MixinInGameHud",
|
||||
"MixinItemColorMap",
|
||||
"MixinWorldRenderer"
|
||||
"MixinWorldRenderer",
|
||||
"EntityModelLayersAccessor",
|
||||
"EntityModelsMixin",
|
||||
"LivingEntityRendererAccessor",
|
||||
"MixinBlockEntityRenderers",
|
||||
"MixinEntityRenderers"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
@ -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.
|
|
@ -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);
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue