daafganggdg Posted August 31, 2014 Posted August 31, 2014 Hey, As the topic says I want to draw an items icon in my gui that it looks just like it actually is an item How do i do that? Quote
daafganggdg Posted August 31, 2014 Author Posted August 31, 2014 I found drawTexturedModelRectFromIcon and tried it with: this.drawTexturedModelRectFromIcon(100, 100, new ItemStack(Items.apple).getIconIndex(), 16, 16); but that's just painting a big fat "nul" I guess I'm using that ItemStack thing completly wrong? Quote
larsgerrits Posted August 31, 2014 Posted August 31, 2014 You need to bind the itemsheet first. Use this to bind the itemsheet: TextureManager manager = Minecraft.getMinecraft().renderEngine; manager.bindTexture(manager.getResourceLocation(1)); //RENDER ITEMS Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
daafganggdg Posted August 31, 2014 Author Posted August 31, 2014 me again Uhm so i want to delete a slot and draw the items texture over it, I have @Override public void mouseClicked(int x, int y, int z) { super.mouseClicked(x, y, z); if(y - guiTop > 30 && y - guiTop < 55 && x - guiLeft > 92 && x - guiLeft < 141) { tileEntity.onButtonClick(); } } in my gui and public void onButtonClick() { slots[0] = null; } in my tileEntity, however the slot actually becomes invisible, but when i ckick it it still seems to contain the ItemStack I guess thats because the Gui stuff where i call the method is client. Then how do I solve that problem? Quote
larsgerrits Posted September 1, 2014 Posted September 1, 2014 You need to send packets to tell the server a button was clicked, let the server decide if that was possible, and then set it to null. Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
daafganggdg Posted September 1, 2014 Author Posted September 1, 2014 You need to send packets to tell the server a button was clicked, let the server decide if that was possible, and then set it to null. Is there a good tutorial for packets? (never worked with that : Quote
imadnsn Posted September 1, 2014 Posted September 1, 2014 See SimpleNetworkWrapper tutorials in the Tutorials section of this forum's Modder Support Quote
daafganggdg Posted September 1, 2014 Author Posted September 1, 2014 Well, I came up with this: @EventHandler public static void preInit(FMLPreInitializationEvent event) { network = NetworkRegistry.INSTANCE.newSimpleChannel("MyChannel"); network.registerMessage(ClearSlotMessage.Handler.class, ClearSlotMessage.class, 0, Side.SERVER); } public class ClearSlotMessage implements IMessage{ public int x; public int y; public int z; public ClearSlotMessage(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } @Override public void fromBytes(ByteBuf buf) { } @Override public void toBytes(ByteBuf buf) { } public static class Handler implements IMessageHandler<ClearSlotMessage, IMessage> { @Override public IMessage onMessage(ClearSlotMessage message, MessageContext ctx) { TileEntityCutter entity = (TileEntityCutter) ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z); if(entity != null) { // entity. System.out.print("safasfasfasfasfafasfasfas"); } return null; } } } public void onButtonClick() { //the method in my tileEntity FM.network.sendToServer(new ClearSlotMessage(xCoord, yCoord, zCoord)); } I'm not sure how I use the methods fromByte and toByte (just make x y z binary?) And what is the "MyChannel"? Rest ok? Quote
larsgerrits Posted September 2, 2014 Posted September 2, 2014 You can use buf.writeInt(int) and int = buf.readInt() . For more complex stuff, like strings, you can use the ByteBufUtils class. The "MyChannel" is the channel it registers to. If two or more mods use the same channel, you get both messages (I think). You should probably prefix your channel name with your modid. Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Recommended Posts
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.