Posted January 2, 20214 yr I am trying to send a NBT update to the client when a GUI button is clicked. I tried just setting the value, but it looks like it is only set for the client TileEntity, and not the server one. How can I send the value to the server? I've seen that Minecraft uses a custom packet for that, but I have no idea how to use them, and I don't understand the documetion.
January 2, 20214 yr Author I saw how it is made for the CommandBlockScreen, but I am not sure how to handle these packets. Also, the button just sends a TextField to the server, and it is checked again there - I just need to send two integers. I tried implementing it with SimpleChannels, but I saw that Minecraft uses a custom packet.
January 2, 20214 yr Author So.. how do I exactly handle it? And register it? I don't understand the docs, especially the "Registering Packets". I understand that the packet class should have functions for encoding and decoding the packets, but I don't really know how they should work.
January 2, 20214 yr Author INSTANCE.registerMessage(0, CSendNBTPacket.class ,CSendNBTPacket::encode, CSendNBTPacket::decode, CSendNBTPacket::ctx); public class CSendNBTPacket { public PacketBuffer encode(CSendNBTPacket packet) { return null; } public CSendNBTPacket decode(PacketBuffer buffer) { } public Supplier<NetworkEvent.Context> ctx() { return null; } } What am I doing wrong here? (ignoring the "return null;" part)
January 3, 20214 yr Author Okay, I think It might work now, but I still have no idea when to register them. Should it be done from the main mod class or is there a registry event for that? also, how do I make it actually handle it? I may be not experienced enough to understand it, but I don't think that just putting a "handle()" method will work. Edited January 3, 20214 yr by bajtix
January 3, 20214 yr Author 2 hours ago, diesieben07 said: Not sure what you mean by "make it handle it". If I understand correctly, the last parameter of the registerMessage() function is the method that handles the data, right? I'm not sure if I understood the documentation.
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.