Jump to content

Recommended Posts

Posted (edited)

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 by deerangle
solved!
Posted
@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.

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.