Spyeedy Posted August 12, 2019 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
Animefan8888 Posted August 12, 2019 Posted August 12, 2019 On 8/12/2019 at 1:13 PM, 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. Expand 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.
Spyeedy Posted August 12, 2019 Author Posted August 12, 2019 On 8/12/2019 at 1:27 PM, 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? Expand 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
Animefan8888 Posted August 12, 2019 Posted August 12, 2019 On 8/12/2019 at 1:58 PM, 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. Expand 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.
Spyeedy Posted August 12, 2019 Author Posted August 12, 2019 (edited) On 8/12/2019 at 2:16 PM, Animefan8888 said: So there isnt a problem? Expand 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
Animefan8888 Posted August 12, 2019 Posted August 12, 2019 On 8/12/2019 at 2:17 PM, Spyeedy said: The problem is that when placing the block, the fluid data isn't intact, it's being reset, defaulted to 0 Expand 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.
Spyeedy Posted August 12, 2019 Author Posted August 12, 2019 On 8/12/2019 at 2:19 PM, Animefan8888 said: How are you checking that is it possible that its just a client server desync? Expand 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
Animefan8888 Posted August 12, 2019 Posted August 12, 2019 On 8/12/2019 at 2:21 PM, Spyeedy said: uhh, i don't Expand 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.
Spyeedy Posted August 12, 2019 Author Posted August 12, 2019 (edited) On 8/12/2019 at 2:31 PM, 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. Expand 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
Animefan8888 Posted August 12, 2019 Posted August 12, 2019 On 8/12/2019 at 2:34 PM, Spyeedy said: stack's tag Expand 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.
Spyeedy Posted August 12, 2019 Author 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
Spyeedy Posted August 12, 2019 Author 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
Animefan8888 Posted August 12, 2019 Posted August 12, 2019 On 8/12/2019 at 3:22 PM, 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. Expand 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.
Spyeedy Posted August 12, 2019 Author Posted August 12, 2019 On 8/12/2019 at 3:25 PM, Animefan8888 said: No you need to send a packet from the server to the client to sync the data. Expand 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
Animefan8888 Posted August 12, 2019 Posted August 12, 2019 On 8/12/2019 at 3:44 PM, Spyeedy said: I'm already sending a packet tho Expand 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.
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.