BentoBoxWorld / BentoBox

Expandable Minecraft server plugin for island-type games like SkyBlock or AcidIsland.
https://bentobox.world
Eclipse Public License 2.0
329 stars 137 forks source link

Blueprints and PersistentDataContainer #2102

Open PancakeCatsss opened 1 year ago

PancakeCatsss commented 1 year ago

Is your feature request related to a problem?

So recently we wanted to add some loot chests to the islands that are generated using one of our plugins, however, we ran into an issue of the blueprints not saving the PersistentData attached to the chest that was placed.

Describe the solution you'd like.

Would be nice if possible for the blueprints to save this data attached to blocks that have PersistentDataContainers, I thought it would have already saved it since it saves text on signs, items in chests etc but it seems it does not.

Describe alternatives you've considered.

Don't really think there is another alternative,

Agreements

Other

No response

PancakeCatsss commented 1 year ago

Just a bit more information about this

Before saving the blueprint:

0, 82, -3 has the following block data: {z: -3, id: "minecraft:chest", y: 82, x: 0, Items: [], PublicBukkitValues: {"cclootchest:loot_table": "BASTION_TREASURE"}, CustomName: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"Loot Chest"}],"text":""}'}

After saving and using the blueprint:

0, 82, -3 has the following block data: {z: -3, id: "minecraft:chest", y: 82, x: 0, Items: []}

tastybento commented 1 year ago

That's good info. I was looking at trying to work out how to serialize all of that persistent data but it looks like it might already be serialized for us using the block data. Thanks.

tastybento commented 1 year ago

I've looked into this and it seems quite complex to store the PersistentDataContainer data and put it back onto a block. There was one person who described doing using NMS but all their quoted code has been removed from the pastebin where they put it. Unfortunately, it's not as simple as using the block data. It seems almost impossible to do it using Bukkit API. So, right now, I don't know how to do this, sorry.

Coincidentally, after studying the blueprint pasting code quite a bit, I see that we no longer use NMS to paste blocks and instead use the Bukkit API. This doesn't affect this ticket, but I thought we were using NMS to paste blocks, which we're not.