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.

TileEntity passed to TileEntitySpecialRenderer does not contain full information

Featured Replies

Posted

I want to render my TileEntity in a special way, so when there is an Item in a specific slot I want to render a cube representing that item in the model. When checking for the item using the following function:

 

public boolean getHasItemInSlot(int slot) {

  return itemStacks[slot] != null && (itemStacks[slot].stackSize > 0);

}

 

it always returns false. Even when taking the coordinates from the tileEntity (which ARE valid) it ALWAYS returns false.

 

TileEntitySpecialRenderer class: https://github.com/rhbvkleef/requiredstuffz/blob/master/src/main/java/tk/yteditors/requiredstuffz/renderer/TileEntityOvenRenderer.java

TileEntity class: https://github.com/rhbvkleef/requiredstuffz/blob/master/src/main/java/tk/yteditors/requiredstuffz/tileEntity/TileEntityOven.java

Github repo: https://github.com/rhbvkleef/requiredstuffz

Check out my mod!

Do you have a container or something that puts the item in the tileentity?

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

If your inventory is not being access via a Container, then you must notify the client manually of any changes to your TileEntity's data state; this is most easily done by using the combination of your TE's read/write NBT methods (provided you implemented them correctly) and overriding getDescriptionPacket and onDataPacket:

@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}

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

 

If your TileEntity has a lot of data being saved to NBT, then you should consider only sending the information you require, e.g. writing only the one ItemStack to the tag compound being sent in the packet, and adjusting onDataPacket accordingly.

  • Author

Adding the functions onDataPacket and getDescriptionPacket and adding the code you showed into them, it still does not work, and I still get a FALSE return.

 

After adding some loggers, it looks like the functions onDataPacket and getDescriptionPacket are never called. After restarting the world, the model renders correctly.

Check out my mod!

  • Author

Since this tile-entity only has 2 slots, 2 integers and 1 boolean stored in NBT, I think it is fair to send all of these values to the client, since I am checking 1 slot and 1 boolean for the rendering. The block now renders properly as well :)

Check out my mod!

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.