-
Notifications
You must be signed in to change notification settings - Fork 0
Item Renderers
Lyof429 edited this page Jun 9, 2026
·
1 revision
Main class to register custom rendering for items.
Registers a custom dynamic renderer for items.
Any ItemStack which satisfies @param condition will be affected.
This method is automatically called for any Item implementing IAddedRenderItem.
PoseStack will automatically be pushed and then popped.
// Define the texture somewhere else to avoid rendering lag
ResourceLocation TEXTURE = SolLib.MOD.makeID("textures/models/staff/glint.png");
// Renders an extra white dot on enchanted diamond swords
SolClientRegistries.Render.ITEM.register(stack -> stack.is(Items.DIAMOND_SWORD) && stack.isEnchanted(),
(stack, context, matrices, bufferSource, light, overlay) -> {
matrices.scale(1.005f, 1.005f, 1.005f);
matrices.translate(0, 0.995, 0.4975);
matrices.mulPose(Axis.XP.rotationDegrees(180));
MockItemRenderer.renderItem(matrices, bufferSource, light, TEXTURE);
});void render(ItemStack stack, ItemDisplayContext displayContext, PoseStack matrices, MultiBufferSource bufferSource, int packedLight, int packedOverlay);A functional interface for item rendering.
-
stackThe currently rendered ItemStack, for eventual extra checks or processing. -
displayContextThe currently used ItemDisplayContext. -
poseStackCurrently used PoseStack. -
bufferSourceCurrently used MultiBufferSource. -
packedLightThe light currently shed on the item. -
packedOverlayThe overlay currently shed on the item.
void render(ItemStack stack, ItemDisplayContext displayContext, PoseStack matrices, MultiBufferSource bufferSource, int packedLight, int packedOverlay);
boolean shouldAddRender(ItemStack stack);An extension of IItemRenderer with a built in rendering predicate.
Any Item implementing this will have their renderer automatically registered.
boolean shouldAddBarRender(ItemStack stack);
float getAddedBarFullness(ItemStack stack);
int getAddedBarColor(ItemStack stack);Any item implementing this will render a second durability bar.
- Will only be visible when
shouldAddBarRenderreturns true. - The bar's fullness is controlled by
getBarFullness, which should range from 0 (empty) to 1 (full). - The bar's color is controlled by
getAddedBarColor, which should return a packed int.