Jump to content

TileEntity passed to TileEntitySpecialRenderer does not contain full information


Recommended Posts

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!

Posted

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.

Posted

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!

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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