Fabric API

Fabric API

108M Downloads

[Bug] BakedModelConsumer doesn't support FabricBakedModel

Phoupraw opened this issue ยท 1 comments

commented

The context:

var itemRenderer = MinecraftClient.getInstance().getItemRenderer();
ItemStack nestedStack = ... ;
var itemModel = (BakedModel & FabricBakedModel) itemRenderer.getModel(nestedStack, null, null, 0);

The code below can't render itemModel if it uses emitItemQuads to render:

context.bakedModelConsumer().accept(itemModel);

You should use the code below instead:

if (itemModel.isVanillaAdapter()) {
    context.bakedModelConsumer().accept(itemModel);
} else {
    itemModel.emitItemQuads(nestedStack, randomSupplier, context);
}
commented

BakedModelConsumer ignores emit*Quads by design. If you want to render a specific item model you should always cast to FabricBakedModel and call emitItemQuads.