Posted July 2, 20169 yr When I open my gui (using player.openGui() which calls the GuiHandler, that part works) I am trying to get the Tile Entity of the block that I'm aiming at. The GuiHandler recognizes that the Tile entity is an instance of my custom tile entity, however when I try to get data that's stored on the tile, I always get the default values of the tile, even if they're changed. My code: The GuiHandler @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if (player != null) { if (ID == Reference.Guis.ElevatorLarge.getID() && tile instanceof TileEntityElevator) { TileEntityElevator elevator = (TileEntityElevator) tile; logger.log(tile.getYUp()) //This line always gives 0, even if there is a value stored in the TileEntityElevator. return new GuiElevator(world, new BlockPos(x, y, z)); } } return null; } I hope this is enough information to find the problem... Thanks in advance!
July 2, 20169 yr The client and server have separate instances of your TileEntity . The server's data is only synced to the client if you include it in the update tag/packet. Override TileEntity#getUpdateTag to write the data that needs syncing to a compound tag and return it. Override TileEntity#getUpdatePacket to create and return an SPacketUpdateTileEntity using the compound tag returned by TileEntity#getUpdateTag . Override TileEntity#onDataPacket to read the TileEntity 's data from the packet's compound tag. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 2, 20169 yr Author Wow, that actually worked on the first time! Thanks a lot! I still have a few things I need to learn about client-server handling - what happens automatically and what doesn't (for example: this ) Thanks!
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.