BlockEntityWithoutLevelRenderer/1.18
BlockEntityWithoutLevelRenderer
is a class that allows custom usages of PoseStack
s and MultiBufferSource
s to render items.
Using BlockEntityWithoutLevelRenderer
BlockEntityWithoutLevelRenderer
allows you to render your item by extending the class and overriding BlockEntityWithoutLevelRenderer#renderByItem
.
In order to use a BEWLR, the Item must first return true for BakedModel#isCustomRenderer
. Once that returns true, the Item’s BEWLR will be accessed for rendering. If it does not have one, it will use the default ItemRenderer#getBlockEntityRenderer
.
To set the BEWLR for an Item, an anonymous instance of IItemRenderProperties
must be consumed within Item#initializeClient
. Within the anonymous instance, IItemRenderProperties#getItemStackRenderer
should be overridden to return the instance of your BEWLR:
// In your item class @Override public void initializeClient(Consumer<IItemRenderProperties> consumer) { consumer.accept(new IItemRenderProperties() { @Override public BlockEntityWithoutLevelRenderer getItemStackRenderer() { return myBEWLRInstance; } }); }
That’s it, no additional setup is necessary to use a BEWLR.
Important
If you need to access the TransformType
for rendering, you can store the one passed through BakedModel#handlePerspective
and use it during rendering. This method will always be called before BlockEntityWithoutLevelRenderer#renderByItem
.