Jump to content

[1.12.2] Fluid data not saving when block is destroyed


Spyeedy

Recommended Posts

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 by Spyeedy

width=620 height=260http://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

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?

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

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.

width=620 height=260http://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

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?

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

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 by Spyeedy

width=620 height=260http://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

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?

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

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.

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

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.

image.thumb.png.295d3d3a0ccb87e430b2115a49ad58e9.png

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 by Spyeedy

width=620 height=260http://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

2 minutes ago, Spyeedy said:

stack's tag

I was talking about the TileEntity being desynced not the ItemStack.

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

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.

width=620 height=260http://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

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.

width=620 height=260http://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

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.

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

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());
	}

 

width=620 height=260http://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

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.

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.