Posted November 25, 20177 yr My TileEntity stores an Integer called "storedpower". This integer is loaded from NBT on game start, and written to NBT on the game save. when I read it from NBT, my integer only loads on the server side, and not on client side. Now, this TileEntity has a GUI, which can display this "storedpower" Integer. But since GUI is on the client, and the Integer is on the server, I cant get it to display the proper value. Now I am wondering, how I should go about syncing the client with the server, that I can display the proper value. I tried onDataPacket, but I can't quite understand how to use that properly. Side note: I only want to sync the data in TileEntity#readFromNBT. Edited November 25, 20177 yr by deerangle solved!
November 25, 20177 yr Author @Override public S35PacketUpdateTileEntity getDescriptionPacket() { NBTTagCompound tagCompound = new NBTTagCompound(); this.writeToNBT(tagCompound); S35PacketUpdateTileEntity pack = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tagCompound); return pack; } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } this did the trick!
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.