Posted July 22, 20169 yr So I want to save the data for a TileEntity, just a couple integers and a boolean, first time trying with goals of success to save the data with NBT, but, should I use them? Or the new Capabilities system is the way to go for storing TileEntities data? Come and say hi at www.twitter.com/JoseluGames
July 22, 20169 yr No the Capabilities are for stuff thats similar to other tile entities and stuff that should be compatible with other mods (like Inventory, FluidTank , ...) Normal data (as you sayed some integer and booleans) are still stored in NBT with the writeToNBT() and readFromNBT() method
July 22, 20169 yr Author Got NBT setted up but they don't seem to work, this is my code for the TileEntity: http://pastebin.com/CLGnjvwV And the log when I load a world (System prints around lines 7-9 and 77-86): http://pastebin.com/ueuFZpFy Come and say hi at www.twitter.com/JoseluGames
July 22, 20169 yr If the TileEntity update packets are anything like they used to be pre-1.9, you need to pass 1 as the second parameter for an NBTTagCompound-based packet: // change 'this.getBlockMetadata()' to 1: return new SPacketUpdateTileEntity(this.pos, 1, tagCompound); http://i.imgur.com/NdrFdld.png[/img]
July 22, 20169 yr Author Changed to 1 and still not working Come and say hi at www.twitter.com/JoseluGames
July 22, 20169 yr What's strange is that your #getUpdatePacket method is not being called at all according to the log, and thus #onDataPacket is not, either... but #writeToNBT and #readFromNBT are both called... Can you show where you register your TileEntity and the related Block class? Perhaps some more context will help track down the issue. Another thing you can try if you haven't already is updating Forge - sometimes things get broken temporarily, and though I don't have any reason to believe that's the case here, it's worth a shot. http://i.imgur.com/NdrFdld.png[/img]
July 23, 20169 yr In 1.9.4+, you need to override TileEntity#getUpdateTag to write the data that needs syncing to a compound tag and return it. You should then override TileEntity#getUpdatePacket to use the compound tag returned by TileEntity#getUpdateTag . TileEntity#getUpdateTag is sent with the chunk data, TileEntity#getUpdatePacket is sent after that. 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 23, 20169 yr i cant get mine to work either, tried setting what you said overridden in my tile entity extended from TileEntity but writeInternal is set to private. or do i have to make my own TileEentity class. cant really find any examples of working code either, im just trying to store one item and every other part of my code works but this.
July 23, 20169 yr i cant get mine to work either, tried setting what you said overridden in my tile entity extended from TileEntity but writeInternal is set to private. or do i have to make my own TileEentity class. cant really find any examples of working code either, im just trying to store one item and every other part of my code works but this. Call super.getUpdateTag from your override of TileEntity#getUpdateTag . 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.
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.