Posted March 28, 20169 yr 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.
March 28, 20169 yr 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.
March 28, 20169 yr 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.