使用 NBT 達成 Tooltip 提示
伺服器腳本
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);
}
});
原創2024/11/10小於 1 分鐘