diff --git a/fabric-loot-tables-v1/src/main/java/net/fabricmc/fabric/api/loot/v1/FabricLootSupplierBuilder.java b/fabric-loot-tables-v1/src/main/java/net/fabricmc/fabric/api/loot/v1/FabricLootSupplierBuilder.java index 1a6ac6e12..56d2971a8 100644 --- a/fabric-loot-tables-v1/src/main/java/net/fabricmc/fabric/api/loot/v1/FabricLootSupplierBuilder.java +++ b/fabric-loot-tables-v1/src/main/java/net/fabricmc/fabric/api/loot/v1/FabricLootSupplierBuilder.java @@ -81,7 +81,7 @@ public class FabricLootSupplierBuilder extends LootTable.Builder { } /** - * Copies the pools and functions of theĀ {@code supplier} to this builder. + * Copies the pools and functions of the {@code supplier} to this builder. * If {@code copyType} is true, the {@link FabricLootSupplier#getType type} of the supplier is also copied. */ public FabricLootSupplierBuilder copyFrom(LootTable supplier, boolean copyType) { diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRenderer.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRenderer.java index f5add3e5f..7882df159 100644 --- a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRenderer.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRenderer.java @@ -18,6 +18,7 @@ package net.fabricmc.fabric.api.client.rendering.v1; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.fabricmc.api.EnvType; @@ -28,8 +29,11 @@ import net.fabricmc.api.Environment; * They allow using non-model rendering, such as BERs, for items. * *
An item with a builtin renderer must have a model extending {@code minecraft:builtin/entity}. - * The renderers are registered with {@link BuiltinItemRendererRegistry#register}. + * The renderers are registered with {@link BuiltinItemRendererRegistry#register(Item, BuiltinItemRenderer)}. + * + * @deprecated Please use {@link BuiltinItemRendererRegistry.DynamicItemRenderer} instead. */ +@Deprecated @Environment(EnvType.CLIENT) @FunctionalInterface public interface BuiltinItemRenderer { 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 61a5bba81..ee2863d49 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 @@ -16,15 +16,19 @@ package net.fabricmc.fabric.api.client.rendering.v1; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; +import net.minecraft.item.ItemStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.impl.client.rendering.BuiltinItemRendererRegistryImpl; /** - * This registry holds {@linkplain BuiltinItemRenderer builtin item renderers} for items. + * This registry holds {@linkplain DynamicItemRenderer builtin item renderers} for items. */ @Environment(EnvType.CLIENT) public interface BuiltinItemRendererRegistry { @@ -43,7 +47,9 @@ public interface BuiltinItemRendererRegistry { * @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 + * @deprecated Please use {@link BuiltinItemRendererRegistry#register(ItemConvertible, DynamicItemRenderer)} instead. */ + @Deprecated void register(Item item, BuiltinItemRenderer renderer); /** @@ -55,6 +61,43 @@ public interface BuiltinItemRendererRegistry { * @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 + * @deprecated Please use {@link BuiltinItemRendererRegistry#register(ItemConvertible, DynamicItemRenderer)} instead. */ + @Deprecated void register(ItemConvertible 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, DynamicItemRenderer renderer); + + /** + * Dynamic item renderers render items with custom code. + * They allow using non-model rendering, such as BERs, for items. + * + *
An item with a dynamic renderer must have a model extending {@code minecraft:builtin/entity}.
+ * The renderers are registered with {@link BuiltinItemRendererRegistry#register(ItemConvertible, DynamicItemRenderer)}.
+ */
+ @FunctionalInterface
+ @Environment(EnvType.CLIENT)
+ interface DynamicItemRenderer {
+ /**
+ * Renders an item stack.
+ *
+ * @param stack the rendered item stack
+ * @param mode the model transformation mode
+ * @param matrices the matrix stack
+ * @param vertexConsumers the vertex consumer provider
+ * @param light packed lightmap coordinates
+ * @param overlay the overlay UV passed to {@link net.minecraft.client.render.VertexConsumer#overlay(int)}
+ */
+ void render(ItemStack stack, ModelTransformation.Mode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay);
+ }
}
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 50cdfab79..ada9a560e 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
@@ -33,21 +33,15 @@ import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry;
public final class BuiltinItemRendererRegistryImpl implements BuiltinItemRendererRegistry {
public static final BuiltinItemRendererRegistryImpl INSTANCE = new BuiltinItemRendererRegistryImpl();
- private static final Map