Posted December 27, 20213 yr i created a GUI and the screen is render and working perfectly, but why THE FUCK my button is like this HAHAHA https://imgur.com/a/ofhWSiW public class ResearcherScreen extends ContainerScreen<ResearcherContainer> { private final ResourceLocation GUI = new ResourceLocation(TotisMod.MOD_ID, "textures/gui/researcher_gui.png"); public ResearcherScreen(ResearcherContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); } private Button myButton; @Override public void init() { super.init(); buttons.clear(); myButton = addButton(new Button(66,66,103,50,new TranslationTextComponent("hola"),this::actionPerformed)); } public void actionPerformed(Button button) { if(button == myButton) { PlayerEntity player = Minecraft.getInstance().player; player.sendStatusMessage(new StringTextComponent("Button clicked"),false); } } @Override public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { this.renderBackground(matrixStack); super.render(matrixStack, mouseX, mouseY, partialTicks); this.renderHoveredTooltip(matrixStack, mouseX, mouseY); } @Override protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) { RenderSystem.color4f(1f, 1f, 1f, 1f); this.minecraft.getTextureManager().bindTexture(GUI); int i = this.guiLeft; int j = this.guiTop; this.blit(matrixStack, i, j, 0, 0, this.xSize, this.ySize); } }
December 27, 20213 yr Author 10 hours ago, diesieben07 said: Vanilla buttons only support a height of 20. now is showing correctly but is not printing anything in chat(before it worked and i only changed the height to 20 as you told me) public class ResearcherScreen extends ContainerScreen<ResearcherContainer> { private final ResourceLocation GUI = new ResourceLocation(TotisMod.MOD_ID, "textures/gui/researcher_gui.png"); public ResearcherScreen(ResearcherContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); } private Button myButton; @Override public void init() { super.init(); buttons.clear(); this.addButton(new Button(66,60,103,20,new StringTextComponent("hola"),this::actionPerformed)); } public void actionPerformed(Button button) { if(button == myButton) { PlayerEntity player = Minecraft.getInstance().player; player.sendStatusMessage(new StringTextComponent("Button clicked"),false); } } @Override public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { this.renderBackground(matrixStack); super.render(matrixStack, mouseX, mouseY, partialTicks); this.renderHoveredTooltip(matrixStack, mouseX, mouseY); } @Override protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) { RenderSystem.color4f(1f, 1f, 1f, 1f); this.minecraft.getTextureManager().bindTexture(GUI); int i = this.guiLeft; int j = this.guiTop; this.blit(matrixStack, i, j, 0, 0, this.xSize, this.ySize); } }
December 28, 20213 yr 5 hours ago, ElTotisPro50 said: if(button == myButton) You never assign anything to myButton. You changed this: 22 hours ago, ElTotisPro50 said: myButton = addButton Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.