Spyeedy Posted August 12, 2019 Share Posted August 12, 2019 (edited) So, when my block is destroyed, the tile entity NBT data is saved to the dropped itemstack, and it saves the TileEntity's inventory successfully. But it doesn't seem to save the fluid data. https://gist.github.com/Spyeedy/00d51baab4ad10b1c694da42e09ce2ba Edited August 12, 2019 by Spyeedy Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 12, 2019 Share Posted August 12, 2019 12 minutes ago, Spyeedy said: So, when my block is destroyed, the tile entity NBT data is saved to the dropped itemstack, and it saves the TileEntity's inventory successfully. But it doesn't seem to save the fluid data. Ok first don't implement ITileEntityProvider it is legacy code. Override hasTileEntity(BlockState) and createTileEntity(World BlockState) Second how do you know that the fluid data isn't being transferred to the ItemStack? How did you test it? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Spyeedy Posted August 12, 2019 Author Share Posted August 12, 2019 27 minutes ago, Animefan8888 said: Ok first don't implement ITileEntityProvider it is legacy code. Override hasTileEntity(BlockState) and createTileEntity(World BlockState) Second how do you know that the fluid data isn't being transferred to the ItemStack? How did you test it? first: ah i see, ok, i'll change it when i get the fluid data missing solved. second: I dropped the item and used entitydata command to look at the item's data, it indeed has the fluid data inside. Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 12, 2019 Share Posted August 12, 2019 17 minutes ago, Spyeedy said: second: I dropped the item and used entitydata command to look at the item's data, it indeed has the fluid data inside. So there isnt a problem? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Spyeedy Posted August 12, 2019 Author Share Posted August 12, 2019 (edited) Just now, Animefan8888 said: So there isnt a problem? The problem is that when placing the block, the fluid data isn't intact, it's being reset, defaulted to 0. My apologies, my writing in the original post was incorrect. Edited August 12, 2019 by Spyeedy Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 12, 2019 Share Posted August 12, 2019 1 minute ago, Spyeedy said: The problem is that when placing the block, the fluid data isn't intact, it's being reset, defaulted to 0 How are you checking that is it possible that its just a client server desync? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Spyeedy Posted August 12, 2019 Author Share Posted August 12, 2019 2 minutes ago, Animefan8888 said: How are you checking that is it possible that its just a client server desync? uhh, i don't Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 12, 2019 Share Posted August 12, 2019 8 minutes ago, Spyeedy said: uhh, i don't You dont what? And I'm sorry; running on no sleep. Forming sentences is hard. I meant to say how did you check that it isnt copying the fluid data. Did you check to make sure it isnt a client server desync. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Spyeedy Posted August 12, 2019 Author Share Posted August 12, 2019 (edited) 2 minutes ago, Animefan8888 said: You dont what? And I'm sorry; running on no sleep. Forming sentences is hard. I meant to say how did you check that it isnt copying the fluid data. Did you check to make sure it isnt a client server desync. oh oops, i think i misunderstood your question there, but just now, i checked the stack's data when placing the block down, the nbt checks out fine on both server and client. I overrode the onBlockPlacedBy and used the ItemStack provided by the method, to retrieve the stack's tag and printed that. Edited code in the same gist: https://gist.github.com/Spyeedy/00d51baab4ad10b1c694da42e09ce2ba Edited August 12, 2019 by Spyeedy Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 12, 2019 Share Posted August 12, 2019 2 minutes ago, Spyeedy said: stack's tag I was talking about the TileEntity being desynced not the ItemStack. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Spyeedy Posted August 12, 2019 Author Share Posted August 12, 2019 hmm, printing inside TileEntity#readFromNBT yields this output, which seems to add Empty key to fluid data. Investigating into the FluidTank class shows that with Empty key, it will set the fluid's data to null, hence defaulting to no empty data. [23:14:14] [Client thread/INFO] [STDOUT]: [spyeedy.mods.privy.utilities.block.BlockRainCollector:onBlockPlacedBy:100]: {BlockEntityTag:{timer:23,maxTimer:100,id:"spyprivy:rain_collector",inventory:{Size:3,Items:[]},FluidTankWater:{FluidName:"water",Amount:440}},display:{Lore:["(+NBT)"]}} [23:14:14] [Server thread/INFO] [STDOUT]: [spyeedy.mods.privy.utilities.block.TileEntityRainCollector:readFromNBT:92]: {timer:23,maxTimer:100,x:914,y:4,z:-300,id:"spyprivy:rain_collector",inventory:{Size:3,Items:[]},FluidTankWater:{Empty:"",FluidName:"water",Amount:440}} [23:14:14] [Server thread/INFO] [STDOUT]: [spyeedy.mods.privy.utilities.block.BlockRainCollector:onBlockPlacedBy:100]: {BlockEntityTag:{timer:23,maxTimer:100,id:"spyprivy:rain_collector",inventory:{Size:3,Items:[]},FluidTankWater:{FluidName:"water",Amount:440}},display:{Lore:["(+NBT)"]}} [23:14:14] [Client thread/INFO] [STDOUT]: [spyeedy.mods.privy.utilities.block.TileEntityRainCollector:readFromNBT:92]: {timer:23,maxTimer:100,x:914,y:4,z:-300,id:"spyprivy:rain_collector",inventory:{Size:3,Items:[]},FluidTankWater:{Empty:""}} Hmm, why is the Empty key being added into the tag though? i'm not adding Empty on purpose. Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Spyeedy Posted August 12, 2019 Author Share Posted August 12, 2019 I suppose I should remove the Empty key before the NBT data is being read into the fluid tank data, to prevent the FluidTank class from resetting the data. Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 12, 2019 Share Posted August 12, 2019 2 minutes ago, Spyeedy said: I suppose I should remove the Empty key before the NBT data is being read into the fluid tank data, to prevent the FluidTank class from resetting the data. No you need to send a packet from the server to the client to sync the data. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Spyeedy Posted August 12, 2019 Author Share Posted August 12, 2019 17 minutes ago, Animefan8888 said: No you need to send a packet from the server to the client to sync the data. I'm already sending a packet tho @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { //handleUpdateTag(pkt.getNbtCompound()); readFromNBT(pkt.getNbtCompound()); } @Override public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(this.pos, 0, this.getUpdateTag()); } @Override public NBTTagCompound getUpdateTag() { return writeToNBT(super.getUpdateTag()); } Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 12, 2019 Share Posted August 12, 2019 42 minutes ago, Spyeedy said: I'm already sending a packet tho This only happens when there is a block state change. Or you tell it to update. It isnt automatic. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. 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.