JoseluGames Posted July 22, 2016 Share Posted July 22, 2016 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? Quote Come and say hi at www.twitter.com/JoseluGames Link to comment Share on other sites More sharing options...
feldim2425 Posted July 22, 2016 Share Posted July 22, 2016 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 Quote Link to comment Share on other sites More sharing options...
JoseluGames Posted July 22, 2016 Author Share Posted July 22, 2016 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 Quote Come and say hi at www.twitter.com/JoseluGames Link to comment Share on other sites More sharing options...
coolAlias Posted July 22, 2016 Share Posted July 22, 2016 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); Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
JoseluGames Posted July 22, 2016 Author Share Posted July 22, 2016 Changed to 1 and still not working Quote Come and say hi at www.twitter.com/JoseluGames Link to comment Share on other sites More sharing options...
coolAlias Posted July 22, 2016 Share Posted July 22, 2016 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. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
Choonster Posted July 23, 2016 Share Posted July 23, 2016 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. Quote 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. Link to comment Share on other sites More sharing options...
Zerahi Posted July 23, 2016 Share Posted July 23, 2016 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. Quote Link to comment Share on other sites More sharing options...
Choonster Posted July 23, 2016 Share Posted July 23, 2016 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 . Quote 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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.