Posted May 10, 201411 yr I want to have a Gui with a purchasing function I get the item but when i use it it delete itself Code: public class GuiTraitorMenu extends GuiScreen { private GuiButton teleporter = new GuiButton(0, 150 , 60, 100, 20, "Teleporter 2G"); private GuiButton fakemedipack = new GuiButton(1, 150 , 100, 100, 20, "explodierender Erste Hilfe Set 3G"); public GuiTraitorMenu () { super(); } @Override public void drawScreen(int x, int y, float f) { drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(new ResourceLocation("minecrafttrouble:textures/gui/TraitorMenu.png")); drawTexturedModalRect((this.width - 256) / 2, (this.height - 256) *2, 0, 0, 256, 256); super.drawScreen(x, y, f); } @Override public void initGui() { this.buttonList.clear(); this.buttonList.add(teleporter); this.buttonList.add(fakemedipack); GoldCheck(); } public void actionPerformed(GuiButton button) { InventoryPlayer iv = this.mc.thePlayer.inventory; switch(button.id) { case 0: iv.addItemStackToInventory(new ItemStack(main.Teleporter)); iv.consumeInventoryItem(main.Gold);iv.consumeInventoryItem(main.Gold); GoldCheck(); case 1: iv.addItemStackToInventory(new ItemStack(main.FakeMediPack)); iv.consumeInventoryItem(main.Gold);iv.consumeInventoryItem(main.Gold);iv.consumeInventoryItem(main.Gold); GoldCheck(); break; default: } } @Override public boolean doesGuiPauseGame() { return false; } private boolean hasItemInt(Item item, int min) { InventoryPlayer iv = this.mc.thePlayer.inventory; int own = 0; for(int i = 0; i < iv.getSizeInventory(); i++) { if(iv.getStackInSlot(i) != null && iv.getStackInSlot(i).getItem() == item) { own = own + iv.getStackInSlot(i).stackSize; } } if(own >= min) { return true; } else { return false; } } private void GoldCheck() { if(hasItemInt(main.Muenze, 2)) { teleporter.enabled = true; } else { teleporter.enabled = false; } if(hasItemInt(main.Muenze, 3)) { fakemedipack.enabled = true; } else { fakemedipack.enabled = false; } } } Second Problem: if I max my Minecraft the Gui is normal but if it not about the whole screen it buggs the buttons are at the wrong position and i not see the whole Gui
May 10, 201411 yr Author The only one that i found was this: http://www.minecraftforge.net/wiki/Packet_Handling and this is a little bit old.
May 10, 201411 yr Author I registried the Netty Packet Handler now, but the example to Implementation not exist. How i can use it now?
May 10, 201411 yr Author I try to handle it out by myself. And for the tutorial: That's the right link for the example: https://github.com/SlimeKnights/TinkersConstruct/tree/master/src/main/java/tconstruct/util/network/packet
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.