Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted
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)

Posted (edited)

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 by bajtix
Posted
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.

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



×
×
  • Create New...

Important Information

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