Jump to content

Draw rectangle on player screen


poopoodice

Recommended Posts

What I have:

    @SubscribeEvent
    public static void onRenderCrosshair(RenderGameOverlayEvent.Pre event)
    {
        if (event.getType() == RenderGameOverlayEvent.ElementType.CROSSHAIRS)
        {
            event.setCanceled(true);
          int screenHeight = event.getWindow().getScaledHeight();
          int screenWidth = event.getWindow().getScaledWidth();
          minecraft.getTextureManager().bindTexture(REC);
          Tessellator tessellator = Tessellator.getInstance();
          BufferBuilder bufferbuilder = tessellator.getBuffer();
          bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
          bufferbuilder.pos(screenWidth / 2.0D - 1, screenHeight / 2.0D, -90.0D).tex(0.0F, 1.0F).endVertex();
          bufferbuilder.pos(screenWidth / 2.0D - 1, screenHeight / - 5, -90.0D).tex(0.0F, 0.0F).endVertex();
          bufferbuilder.pos(screenWidth / 2.0D + 30, screenHeight /, -90.0D).tex(1.0F, 1.0F).endVertex();
          bufferbuilder.pos(screenWidth / 2.0D + 30, screenHeight / - 5, -90.0D).tex(1.0F, 0.0F).endVertex();
          tessellator.draw();
        }
    }

What it shows:

2020-05-19_22_19_19.png.94c85e86672e32eff1d1ab96ae4882bb.png

Any ideas? (the texture is a pure green 16x16 png file)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

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