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 have a TileEntity that I need to update from the GUI. I simply need to send an Integer from the client to the server-side TileEntity. I assume I need to use packets to do this, but I'm not sure how. My TileEntity can already handle packets:

 

     

        @Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
	readFromNBT(pkt.getNbtCompound());
}

 

which works fine. I guess I need to figure out how to send a packet to the tile entity from the GUI. I tried this:

 

        NBTTagCompound nbtTag = new NBTTagCompound();
        nbtTag.setInteger("MyInteger", myInteger);
S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(this.tileEntity.getPos(), 1, nbtTag);
this.mc.thePlayer.sendQueue.addToSendQueue(packet);

 

but this doesn't work. What is the best way to do this?

  • Author

Ok, I think I am close... but I am stuck on something. On the thread you linked is this message:

 

@Ives: That is more or less correct, but you don't need to send the coordinates of the TileEntity, as the server knows which TE the player is interacting with through the player's current Container. That also ensures that they cannot just change the values in any arbitrary TileEntity (prevents possible hacks).

If you have further questions, please open a new Thread.

 

On the packet handler, how can I access the current TileEntity/Container the player is interacting with without sending the coordinates through the packet? I assume is must be ctx.getServerHandler().playerEntity.something?

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.