
Entity Snapshots NBT Synchronization Bug
Closed this issue ยท 1 comments
Skript/Server Version
[18:57:48 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[18:57:48 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[18:57:48 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[18:57:48 INFO]: [Skript] Server Version: 1.21.4-2416-51aafbc (MC: 1.21.4)
[18:57:48 INFO]: [Skript] Skript Version: 2.11.2 (skriptlang-github)
[18:57:48 INFO]: [Skript] Installed Skript Addons:
[18:57:48 INFO]: [Skript] - SkBee v3.11.3 (https://github.com/ShaneBeee/SkBee)
[18:57:48 INFO]: [Skript] Installed dependencies: None
Bug Description
I came across an error related to entity snapshots and nbt. I made an NPC Stick script for an RPG game project I'm making with a friend, and you can use it to spawn NPCs and configure them. Setting those configs modifies their custom NBT using SkBee. And then, I made it so that when you sneak-right click, you can copy the NPC to then paste it when spawning new ones (with a copy set, the stick has a glint), and you can sneak right-click the air to remove the copy to be able to copy another NPC.
Now that I'm done yapping about how this NPC stick works, it's time to get to WHAT THE SKRIPT happened that caused me to report a bug. When you paste an NPC... it spawns an exact replica of the original one that was copied, basically an entity snapshot. The problem is that both the original one and this pasted one SHARE their custom nbt. If I paste it more times, they will all share nbt. From what I've observed, entity snapshots of entities with custom nbt ALL share it equally along with the original entity. Initially, I saw that their health bars (from above their heads) displayed the exact same health, and then I did some testing and found that the entire custom nbt is synchronized between them.
Expected Behavior
The expected behavior was for each copy of the original NPC to have its own custom nbt instead of sharing it with the other copies plus the original NPC. If you damage one, only the damaged copy should decrease in health, but currently, all of them get damage.
Steps to Reproduce
If you're unable to replicate this, I'm afraid this is a lot more complicated than expected.
I can send the entire NPC Stick skript file for you to test, in that case.
- Make sure you have the same Skript and SkBee versions as me.
- Create a mob and set custom nbt for it.
- Introduce logic that changes that custom nbt value like in my case. I have a custom health system coded for the npcs, and damaging them cancels the event and subtracts the amount of damage dealt from the "hp" custom nbt tag.
- Create a variable storing the entity snapshot of that mob.
- Spawn that snapshot and damage it to lower the "hp" custom nbt tag.
- Both of them should've had their custom nbt tag modified.
Errors or Screenshots
No response
Other
Since this involves NBT which is added by SkBee, I knew I should've probably reported this bug on SkBee. But because of entity snapshots being the thing that caused this to happen, I am sending it here on Skript.
Agreement
- I have read the guidelines above and affirm I am following them with this report.