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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Exception in thread "main" java.lang.IllegalStateException: Current Java is 1.8.0_271 but we require at least 17         at net.minecraftforge.bootstrap.shim.Main.main(Main.java:32) Never have successfully gotten a minecraft server up and running so I thought i'd try again. Instant unfixable issue.  
    • What MC version? What's the IP? Are any mods needed to be able to join?
    • Thank you for your answer ! Unfortunatly i have the same problem when i use setPos() public static int movingfunction(CommandContext<CommandSourceStack> context){ CommandSourceStack source = context.getSource(); if (!(source.getEntity() instanceof ServerPlayer)) { return 0; } ServerPlayer player = (ServerPlayer ) source.getEntity(); double moveSpeed = 0.5; for (int i =0; i<10000;i++) { LOGGER.info("running for the {} time", i); double x = player.getX() + player.getViewVector(1.0f).x * moveSpeed; double y = player.getY(); double z = player.getZ() + player.getViewVector(1.0f).z * moveSpeed ; Vec3 movementVec = new Vec3(x, y, z); LOGGER.info("x ={} y ={} z ={}", x, y, z); player.setPos( movementVec); } return 1; } With the logs i can see that x and z are increasing but once again my player is not moving. is there a function to use to sync the server and the client ? I also tried to use LocalPlayer instead of ServerPlayer but my code would stop when i got the object. Also i will change a bit the main topic but is there a way to similate key press ? i found KeyBinding.setKeyBindState on others post but it look like there is no more KeyBinding in 1.20   I found this code : KeyMapping.click(Minecraft.getInstance().options.keyUp.getKey()); But it doesn't seems to work   And i found this one : Minecraft.getInstance().options.keyUp.setDown(true); wich works but doesn't exactly do what i want , it doesn't release the key so for exemple i can't make him run. Minecraft.getInstance().options.keyUp.setDown(true); Minecraft.getInstance().options.keyUp.setDown(false); Minecraft.getInstance().options.keyUp.setDown(true); doesn't make him run
    • Add crash-reports with sites like https://paste.ee/ Maybe an issue with blur, essentials or cumulus_menus
  • Topics

×
×
  • Create New...

Important Information

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