Achieve tooltip functionality using nbt.
Server Script
global.armorSets = {
netherite: "Netherite Armor Set",
};
PlayerEvents.inventoryChanged((event) => {
const { item, player, slot } = event;
if (item.hasTag("forge:armors") && !item?.nbt?.armor_set) {
item.setNbt({ armor_set: "" });
}
for (let key of Object.keys(global.armorSets)) {
let setName = player.armorSlots.every((armor) =>
Utils.id(armor.id).path.startsWith(key)
)
? key
: "";
player.armorSlots.forEach((eachArmor) => {
if (!eachArmor.empty) eachArmor.setNbt({ armor_set: setName });
});
player.inventory.getStackInSlot(slot).setNbt({ armor_set: setName });
player.persistentData.putString("armor_set", setName);
}
});
Original2024/11/10Less than 1 minute