Jump to content

[Solved][1.15.2] Misunderstanding of the new Render System


Recommended Posts


I tried to port my TileEntityRenderer from 1.12.2 to 1.15.2, i've almost rewrited all.
Objectively, I want to render the fluid contained in the TileEntity


First, here is the RenderType 

public static RenderType getPedestalRenderType(ResourceLocation resourceLocation) {
        RenderType.State state = RenderType.State.getBuilder()
                .texture(new TextureState(resourceLocation, false, false))

        return RenderType.makeType(SkillsStones.MOD_ID + ":pedestal_fluid", DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, 256, true, false, state);


And here is the TileEntityRenderer

    private static final float MIN_HEIGHT = 0.5625f;
    private static final float MAX_HEIGHT = 0.78125f;

    public void render(TileEntityNaturalTotemPedestal tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {

        float level = ((float) tileEntityIn.getFluidTank().getFluidAmount()) / (float) tileEntityIn.getFluidTank().getCapacity();
        if(!(level > 0)) return;

        Fluid fluid = tileEntityIn.getFluidTank().getFluid().getFluid();

        ResourceLocation resourceLocation;
        int color;
        if(fluid.getAttributes().getStillTexture() != null) {
            resourceLocation = fluid.getAttributes().getStillTexture();
            color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), fluid);
        } else if(fluid.getAttributes().getFlowingTexture() != null) {  // In case that Still Texture don't exist
            resourceLocation = fluid.getAttributes().getFlowingTexture();
            color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), fluid);
        } else { // In case that no texture exist
            resourceLocation = Fluids.WATER.getAttributes().getStillTexture();
            color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), Fluids.WATER);

        TextureAtlasSprite textureAtlasSprite = Minecraft.getInstance().getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE).apply(resourceLocation);

        float uMin = textureAtlasSprite.getMinU();
        float uMax = textureAtlasSprite.getMaxU();
        float vMin = textureAtlasSprite.getMinV();
        float vMax = textureAtlasSprite.getMaxV();

        float a = 1.0F;
        float r = (color >> 16 & 0xFF) / 255.0F;
        float g = (color >> 8 & 0xFF) / 255.0F;
        float b = (color & 0xFF) / 255.0F;

        Matrix4f matrix4f = matrixStackIn.getLast().getMatrix();

        float y = MIN_HEIGHT + (level) * (MAX_HEIGHT - MIN_HEIGHT);

        matrixStackIn.translate(0, y, 0);

        IVertexBuilder buffer = bufferIn.getBuffer(SSRenderType.getPedestalRenderType(resourceLocation));

        buffer.pos(matrix4f, 0, 0, 0).color(r, g, b, a).tex(uMin, vMin).endVertex();
        buffer.pos(matrix4f, 0, 0, 1).color(r, g, b, a).tex(uMin, vMax).endVertex();
        buffer.pos(matrix4f, 1, 0, 1).color(r, g, b, a).tex(uMax, vMax).endVertex();
        buffer.pos(matrix4f, 1, 0, 0).color(r, g, b, a).tex(uMax, vMin).endVertex();


    private static int getFluidColor(World world, BlockPos pos, Fluid fluid) {
        if(fluid.isEquivalentTo(Fluids.WATER)) {
            return BiomeColors.getWaterColor(world, pos);

        return fluid.getAttributes().getColor();


In this case, i've an error that tell me that texture doesn't exists (with an Java IO FileNotFound Exception)


When i hardcode the ResourceLocation value to "minecraft:textures/block/water_still.png"

It's working but the texture look weird (also, i've a weird smooth effect)



I don't know how I can properly render my fluid.


(Sorry for approximative English)
Thanks a lot.

Edited by Zeide
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.