Hey! I've made a datapack that mimics the behavior of the keepInventory gamerule, but making it per-player instead of a server-wide gamerule.
However, I'm having an issue in which the NBT data of the Player's Inventory list is getting lost when transferring it to a data storage. This issue is only occurring on Spigot servers and works perfectly fine in vanilla, both singleplayer and multiplayer.
To better explain the issue I'm having;
- When the Player dies, it generates a loottable using the method of replacing the default Player death loottable via a datapack and having it redirect to another loottable to generate the following item;
- A
minecraft:stone_buttonthat copies the NBT of the following directly from the player using the Item Modifier function;minecraft:copy_nbt.
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"name": "minecraft:stone_button",
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{pkiitem:0,inventory:1,Owner:[],Items:[],XpLevel:0,XpP:0.0f}"
},
{
"function": "minecraft:copy_nbt",
"source": {
"type": "context",
"target": "this"
},
"ops": [
{
"source": "UUID",
"target": "Owner",
"op": "replace"
},
{
"source": "Inventory",
"target": "Items",
"op": "replace"
},
{
"source": "XpLevel",
"target": "XpLevel",
"op": "replace"
},
{
"source": "XpP",
"target": "XpP",
"op": "replace"
}
]
},
{
"function": "minecraft:set_count",
"count": {
"value": 1,
"type": "minecraft:constant"
}
}
]
}
]
}
]
}
- To simplify what's happening in the loottable; it creates a
minecraft:stone_buttonand gives it the NBT;{pkiitem:0,inventory:1,Owner:[],Items:[],XpLevel:0,XpP:0.0f}. It then copies the NBT of the Player and puts it with the following; - UUID copied to Owner
- Inventory copied to Items
- XpLevel copied to XpLevel
- XpP copied to XpP
- The dropped
minecraft:stone_buttonis then detected by a looping function and preforms the following commands;
(NOTE: The droppedminecraft:stone_buttonis the "executer".)
data modify storage pki:data hold prepend value {Owner:[],Items:[],XpLevel:0,XpP:0.0f}
data modify storage pki:data hold[0].Owner set from entity @s Item.tag.Owner
data modify storage pki:data hold[0].Items[] set from entity @s Item.tag.Items[]
data modify storage pki:data hold[0].XpLevel set from entity @s Item.tag.XpLevel
data modify storage pki:data hold[0].XpP set from entity @s Item.tag.XpP
- It's transfering all the NBT it copied to a data storage, named
pki:data. It's putting the gathered data in a listing underholdinside the storage.
- Everything copies over properly EXPECT for
Items, which is left blank.
I can see where the issue is arising; it's when the NBT from the minecraft:stone_button is copied to pki:data, it basically disappears.
TD;LR
- I'm transfering an NBT string from an item to a data storage via a datapack, and it's deleting part of the data. The issue only occurs on Spigot and works perfectly fine in Vanilla, both singleplayer and multiplayer. I'm trying to find what the issue is or if I can use a different method to copy the NBT to prevent the issue.
Important Information
Server Details
- Spigot 1.20
Plugins; - floodgae Build#88
- geyser build#1453
Datapack
- MC 1.20+