diff --git a/fabric-rendering-v1/build.gradle b/fabric-rendering-v1/build.gradle index d842b10da..63a6697e7 100644 --- a/fabric-rendering-v1/build.gradle +++ b/fabric-rendering-v1/build.gradle @@ -1,5 +1,5 @@ archivesBaseName = "fabric-rendering-v1" -version = getSubprojectVersion(project, "1.1.2") +version = getSubprojectVersion(project, "1.2.0") dependencies { compile project(path: ':fabric-api-base', configuration: 'dev') diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java index 22855a46b..61a5bba81 100644 --- a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java @@ -17,6 +17,7 @@ package net.fabricmc.fabric.api.client.rendering.v1; import net.minecraft.item.Item; +import net.minecraft.item.ItemConvertible; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -44,4 +45,16 @@ public interface BuiltinItemRendererRegistry { * @throws NullPointerException if either the item or the renderer is null */ void register(Item item, BuiltinItemRenderer renderer); + + /** + * Registers the renderer for the item. + * + *
Note that the item's JSON model must also extend {@code minecraft:builtin/entity}. + * + * @param item the item + * @param renderer the renderer + * @throws IllegalArgumentException if the item already has a registered renderer + * @throws NullPointerException if either the item or the renderer is null + */ + void register(ItemConvertible item, BuiltinItemRenderer renderer); } diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java index 348708a78..50cdfab79 100644 --- a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Objects; import net.minecraft.item.Item; +import net.minecraft.item.ItemConvertible; import net.minecraft.util.registry.Registry; import net.fabricmc.api.EnvType; @@ -49,6 +50,12 @@ public final class BuiltinItemRendererRegistryImpl implements BuiltinItemRendere RENDERERS.put(item, renderer); } + @Override + public void register(ItemConvertible item, BuiltinItemRenderer renderer) { + Objects.requireNonNull(item, "item is null"); + register(item.asItem(), renderer); + } + /* @Nullable */ public static BuiltinItemRenderer getRenderer(Item item) { return RENDERERS.get(item);