Jump to content

Texture not rendering correctly with blit function 1.14.4


Zuve

Recommended Posts

I'm trying to add on to existing GUI's via the GuiContainerEvent.DrawForeground event. Previously, I was doing the following:

mc.getTextureManager().bindTexture(searchBar);
Gui.drawTexturedModalRect(79, 4, 0, 0, 90, 12);

However, with 1.14, it seems the correct syntax would be:

GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(searchBar);
event.getGuiContainer().blit(79, 4, 0, 0, 90, 12);

The issue I'm encountering is that this new function does not seem to correctly render my texture. Linked is an imgur album with comparisons of what the texture is and what will be rendered. The texture is 90x12 pixels in all examples. I am confident the ResourceLocation is correct given that the texture clearly changes when the image is changed, but is still displayed incorrectly. Is it possible the parameter order has switched and I didn't realize it? Any advice is appreciated.

Link to comment
Share on other sites

4 hours ago, cleardragonf said:

RIGHT?! Please let me know as I to have a Post up about this...the only way i was able to get mine to work was by making it 256 * 256 which is counter countuitive

 

This is the way it was expected to be in older versions too, but you didnt have to use the method that required it to be 256x256. You'll notice that all Minecraft gui assets are 256x256.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

45 minutes ago, cleardragonf said:

yea...i notice that...but ContainerScreen in 1.14.3 functions the way most people are use to...ie custom size capabilities...

Yeah there are now many methods with different parameters. Could have been that those methods hadn't been mapped.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

just a heads up....found a way around the overlay issue. if you want...

public class customGUI {
    
    public static final Minecraft mc = Minecraft.getInstance();
    public static void drawModalRectWithCustomSizedTexture(double leftSideX, double rightSideX, double bottomY, double topY, ResourceLocation texture) {
          GlStateManager.disableDepthTest();
          GlStateManager.depthMask(false);
          GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
          GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
          GlStateManager.disableAlphaTest();
          mc.getTextureManager().bindTexture(texture);
          Tessellator tessellator = Tessellator.getInstance();
          BufferBuilder bufferbuilder = tessellator.getBuffer();
          bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
//botlef  bufferbuilder.pos(0.0D, (double)mc.mainWindow.getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex();
          bufferbuilder.pos(leftSideX, bottomY, -90.0D).tex(0.0D, 1.0D).endVertex();
          
//botr    bufferbuilder.pos((double)mc.mainWindow.getScaledWidth(), (double)mc.mainWindow.getScaledHeight(), -90.0D).tex(1.0D, 1.0D).endVertex();
          bufferbuilder.pos(rightSideX, bottomY, -90.0D).tex(1.0D, 1.0D).endVertex();
          
//topr      bufferbuilder.pos((double)mc.mainWindow.getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex();
          bufferbuilder.pos(rightSideX, topY, -90.0D).tex(1.0D, 0.0D).endVertex();
          
//topl    bufferbuilder.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex();
          bufferbuilder.pos(leftSideX, topY, -90.0D).tex(0.0D, 0.0D).endVertex();

          tessellator.draw();
          GlStateManager.depthMask(true);
          GlStateManager.enableDepthTest();
          GlStateManager.enableAlphaTest();
          GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}


 make this a class...then call it from where ever you want...works for me on a 128 *29 image.

Link to comment
Share on other sites

  • 8 months later...

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.