Fabric API

Fabric API

152M Downloads

Unable to use translucent RenderLayer inside BlockEntityRenderer

IoaNNUwU opened this issue ยท 1 comments

commented

I'm working on my BlockEntityRenderer. I want to use custom model that isn't block or item inside BlockModelRenderer.render. Texture for this model is translucent (with semi-transparent pixels). But unfortunately when I put RenderLayer.getTranslucent() as second argument, model is invisible in-game.

If I put RenderLayer.getCutout() instead it shows in-game as intended - but all semi-transparency disappears.

BakedModel beam_overlay_model = bakedModelManager.getModel(Identifier.of("anomaly", "special/laser_beam_overlay"));

blockModelRenderer.render(
    matrices.peek(), vertexConsumers.getBuffer(RenderLayer.getTranslucent()), // <-- here
    null, beam_overlay_model,0xFFFFFF, 0xFFFFFF, 0xFFFFFF,
    LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV
);

I use Fabric 1.21.4 and register my models using:

ModelLoadingPlugin.register(pluginContext -> {
    pluginContext.addModels(Identifier.of("anomaly", "special/laser_beam_overlay"));
});
  • I found a way to specify that Block needs to be rendered translucent with BlockRenderLayerMap.INSTANCE.putBlock(block1, RenderLayer.getTranslucent()) but my model isn't block.

Is there a way to specify that Model needs to be rendered translucent? And what is the reason RenderLayer.getCutout() works, but RenderLayer.getTranslucent() doesn't?

commented

Turns out RenderLayer.getTranslucent() works for item models only. I was able to make translucent block model using RenderLayer.getTranslucentMovingBlock() render layer.

BakedModel beam_overlay_model = bakedModelManager.getModel(Identifier.of("anomaly", "special/laser_beam_overlay"));

blockModelRenderer.render(
    matrices.peek(), vertexConsumers.getBuffer(RenderLayer.getTranslucentMovingBlock()), // <-- here
    null, beam_overlay_model,0xFFFFFF, 0xFFFFFF, 0xFFFFFF,
    LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV
);