When listening to the event and modifying the nbt of an item, it seems to reset after the event occurs.
Could i have some assistance on what is wrong?
From my testing it seems related to the noLoop part of my code. However as what im doing is changing NBT of an item, it is required otherwise a infinite loop occurs.
let noLoop = true;
PlayerEvents.inventoryChanged(e => {
noLoop = !noLoop;
if (noLoop) return;
let {item, item: {nbt: {itemModifier}}, player, level} = e;
if (itemModifier == undefined) {
// global.ModifierHandler.newModifier(item, level); // What i am to do, but to simplify i did the below
item.nbt.merge({"test": 1});
player.tell(item.nbt) // This Shows The change as actually happening, but changes do not reflect in game.
};
});
```First Image is what the base Nbt of the item is, second is the output of player.tell, and third is the final result of the item.