Interface ArmorRenderer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Armor renderers render worn armor items with custom code.
They may be used to render armor with special models or effects.
The renderers are registered with register(ArmorRenderer, ItemConvertible...)
.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
register
(ArmorRenderer renderer, ItemConvertible... items) Registers the armor renderer for the specified items.void
render
(MatrixStack matrices, VertexConsumerProvider vertexConsumers, ItemStack stack, BipedEntityRenderState bipedEntityRenderState, EquipmentSlot slot, int light, BipedEntityModel<BipedEntityRenderState> contextModel) Renders an armor part.static void
renderPart
(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, ItemStack stack, Model model, Identifier texture) Helper method for rendering a specific armor model, comes after setting visibility.default boolean
shouldRenderDefaultHeadItem
(LivingEntity entity, ItemStack stack) Checks whether an item stack equipped on the head should also be rendered as an item.
-
Method Details
-
register
Registers the armor renderer for the specified items.- Parameters:
renderer
- the rendereritems
- the items- Throws:
IllegalArgumentException
- if an item already has a registered armor rendererNullPointerException
- if either an item or the renderer is null
-
renderPart
static void renderPart(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, ItemStack stack, Model model, Identifier texture) Helper method for rendering a specific armor model, comes after setting visibility.This primarily handles applying glint and the correct
RenderLayer
- Parameters:
matrices
- the matrix stackvertexConsumers
- the vertex consumer providerlight
- packed lightmap coordinatesstack
- the item stack of the armor itemmodel
- the model to be renderedtexture
- the texture to be applied
-
render
void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, ItemStack stack, BipedEntityRenderState bipedEntityRenderState, EquipmentSlot slot, int light, BipedEntityModel<BipedEntityRenderState> contextModel) Renders an armor part.- Parameters:
matrices
- the matrix stackvertexConsumers
- the vertex consumer providerstack
- the item stack of the armor itembipedEntityRenderState
- the render state of the entityslot
- the equipment slot in which the armor stack is wornlight
- packed lightmap coordinatescontextModel
- the model provided byFeatureRenderer.getContextModel()
-
shouldRenderDefaultHeadItem
Checks whether an item stack equipped on the head should also be rendered as an item. By default, vanilla renders most items with their models (or special item renderers) around or on top of the entity's head, but this is often unwanted for custom equipment.This method only applies to items registered with this renderer.
Note that the item will never be rendered by vanilla code if it has an armor model defined by the
minecraft:equippable
component. This method cannot be used to overwrite that check to re-enable also rendering the item model. SeeArmorFeatureRenderer.hasModel(ItemStack, EquipmentSlot)
.- Parameters:
entity
- the equipping entitystack
- the item stack equipped on the head- Returns:
true
if the head item should be rendered,false
otherwise
-