Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

  • 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.

  • 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.

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

  • 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 by bajtix

  • 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.