Posted February 5, 201411 yr Hello! My situation is as follows: - I have a custom block with a TE that holds some data - It has a GUI that lets the player do some stuff that alters the TE's data (e.g. turn the block "on") - When the player edits the TE's data in the gui, I send a Packet250CustomPayload to the server to notify it of the changes - This works: The data gets updated on the server and on the client, I can see this because of some debugging output showing the values and whether or not the world object is remote[1] - When I save and close, the TE's data on the client side gets saved correctly (for reference, here is my NBT read/write code) Here's some other code that I think may be relevant: - Code responsible for handling button press and notifying server of TE changes - Packet Handler that handles the change-packets Now, here's the problem: When I load the map after saving and closing, the TE's data on the server's side has been reset. The way I see it, the server doesn't seem to call the writeToNBT()-method properly (or rather, at all). I thought that method was supposed to handle saving of data on both the server and client side, but apparently it's not? I hope someone knows what causes this, and how it can be solved. As always, if there is any other code you need, just say so and I'll post it. [1] The output looks like this, and is generated by this method: [pre]2014-02-05 18:01:21 [iNFO] [sTDOUT] [Molecular] The following is the entity's status: 2014-02-05 18:01:21 [iNFO] [sTDOUT] [Molecular] chargeCapacity = 10000 2014-02-05 18:01:21 [iNFO] [sTDOUT] [Molecular] currentCharge = 29 2014-02-05 18:01:21 [iNFO] [sTDOUT] [Molecular] breakdownSlots = 3 2014-02-05 18:01:21 [iNFO] [sTDOUT] [Molecular] chargeSlots = 1 2014-02-05 18:01:21 [iNFO] [sTDOUT] [Molecular] active = yes 2014-02-05 18:01:21 [iNFO] [sTDOUT] [Molecular] isRemote = no[/pre]
February 5, 201411 yr Did you override the onDataPacket and getDescriptionPacket methods in Tile entity?
February 5, 201411 yr Author I was lead to believe, by this Wiki-page, that method was only necessary if you required some kind of special handling of the packets (such as the given example, updating a GUI) and that it was something that was called on the client, not the server. Specifically, it says: "The flag specifies what should be done with the packet once it was received (for reference: NetClientHandler.handleTileEntityData), if it is set to 1, 2, 3 or 4 the TileEntity#readFromNBT() method for the tile entity (specified by the coordinates) is called with the nbt data. If the flag is something else, it will call TileEntity#onDataPacket(netManager, packet).". Since I send the packet with a 1 flag, I figured I didn't need the onDataPacket()-method. Apparently, that's incorrect. The server seems to sync up nicely now. Did you override the onDataPacket and getDescriptionPacket methods in Tile entity? Yes for the getDescriptionPacket()-method, no for onDataPacket(). Thanks for the help!
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.