Jump to content

[1.14.4][SOLVED] draw texture overlay


Yanny7

Recommended Posts

Hi, I have problem to draw texture overlay over block side. I am not familiar with OpenGL so I tried to look into other projects/mc source code, but without success. Currently I have this code in TER:

 

    private ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/block/machine_top.png");

    @Override
    public void render(BoilerTile tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) {
        GlStateManager.pushMatrix();

        bindTexture(texture);

        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferbuilder = tessellator.getBuffer();

        bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);

        bufferbuilder.pos(x, y + 1.1, z + 1.0D).tex(0, 1).endVertex();
        bufferbuilder.pos(x + 1.0D, y + 1.1, z + 1.0D).tex(1, 1).endVertex();
        bufferbuilder.pos(x + 1.0D, y + 1.1, z).tex(1, 0).endVertex();
        bufferbuilder.pos(x, y + 1.1, z).tex(0, 0).endVertex();

        tessellator.draw();

        GlStateManager.popMatrix();
    }

 

Results in this (texture is too dark):

1066465082_Snmkaobrazovkyz2019-10-2117-15-38.png.b6829c5999e3c8b745f78153897c1c08.png

Can you please guide me how to draw texture overlay correctly?

Edited by Yanny7
Link to comment
Share on other sites

I got it working

 

    private ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/block/fluid_pipe.png");

    @Override
    public void render(BoilerTile tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) {
        GlStateManager.pushMatrix();
        GlStateManager.translated(x, y, z);

        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferbuilder = tessellator.getBuffer();

        bindTexture(texture);
        RenderHelper.disableStandardItemLighting();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.enableBlend();
        GlStateManager.disableCull();

        bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos(0, 1.1, 1).tex(0, 1).endVertex();
        bufferbuilder.pos(1, 1.1, 1).tex(1, 1).endVertex();
        bufferbuilder.pos(1, 1.1, 0).tex(1, 0).endVertex();
        bufferbuilder.pos(0, 1.1, 0).tex(0, 0).endVertex();

        tessellator.draw();

        GlStateManager.enableCull();
        GlStateManager.disableBlend();
        RenderHelper.enableStandardItemLighting();

        GlStateManager.popMatrix();
    }

 

and in Block class extends this:

    @Override
    public BlockRenderLayer getRenderLayer() {
        return BlockRenderLayer.CUTOUT_MIPPED;
    }

 

Link to comment
Share on other sites

  • Yanny7 changed the title to [1.14.4][SOLVED] draw texture overlay

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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