With the release of Forge 14.23.2.2638, a proper way to render items with GL was implemented. Using this system is much simpler than the old system, which required a TileEntity, and does not allow access to the ItemStack.
TileEntityItemStackRenderer allows you to render your item using public void renderByItem(ItemStack itemStackIn)
.
There is an overload that takes partialTicks as a parameter, but it is never called in vanilla.
In order to use a TEISR, the Item must first satisfy the condition that its model returns true for IBakedModel#isBuiltInRenderer
.
Once that returns true, the Item's TEISR will be accessed for rendering. If it does not have one, it will use the default TileEntityItemStackRenderer.instance
. For an example IBakedModel to use, see below.
To set the TEISR for an Item, use Item#setTileEntityItemStackRenderer
. Each Item can only ever provide one TEISR, and the getter is final so that mods do not return new instances each frame.
That's it, no additional setup is necessary to use a TEISR.
Thank you very much for this gist! 🙂
You can create your own subclass, but there is a much easier way. In your item/block model JSON, you simply
parent
frombuiltin/entity
and it will makeIBakedModel#isBuiltInRenderer
returntrue
.