Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author

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;
    }

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.