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'm creating a packet to handle the creation of an itemstack with an NBT tag so that the NBT is actually saved. The packet works one-way, as in I can send the itemstack and NBT tag to it and then append the tag, but I haven't worked out how to return the stack from the packet. How do I do this?

 

Here's the packet: https://github.com/Roboguy99/Chemistry/blob/master/src/main/java/roboguy99/chemistry/network/packet/CompoundCreate.java

And here's where I'm testing it from: https://github.com/Roboguy99/Chemistry/blob/master/src/main/java/roboguy99/chemistry/block/BlockCompoundAnalyser.java#L49

I have no idea what I'm doing.

It doesn't work like that.

 

You send packet (doesn't matter if client or server) - all you know is that you've sent it. The receiver might or might not receive it and even if it will - it might do nothing or it might return "response" packet.

 

You can't return anything from packet, packet makes act. Proper (and only) way to handle it is to have field that will be set by packet.

E.g: (total pseudo)

onMessage(...) {
   message.player.setItemStackSomethwere(message.itemStack);
//or
   world.setStackInSomeTile(x, y, z, slot, itemStack) // which will access Tile in x/y/z and try to set itemStack in some slot.
}

1.7.10 is no longer supported by forge, you are on your own.

  • Author

It doesn't work like that.

 

You send packet (doesn't matter if client or server) - all you know is that you've sent it. The receiver might or might not receive it and even if it will - it might do nothing or it might return "response" packet.

 

You can't return anything from packet, packet makes act. Proper (and only) way to handle it is to have field that will be set by packet.

E.g: (total pseudo)

onMessage(...) {
   message.player.setItemStackSomethwere(message.itemStack);
//or
   world.setStackInSomeTile(x, y, z, slot, itemStack) // which will access Tile in x/y/z and try to set itemStack in some slot.
}

 

So just to check, in other words I need another packet send to the client with the "return"?

 

I just actually read your reply properly. That makes sense.

 

Just to confirm now I've asked it, would a "return packet" actually work?

I have no idea what I'm doing.

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.