const sourceEquip = source.getComponent("minecraft:equippable");
const targetEquip = target.getComponent("minecraft:equippable");
if (sourceEquip && targetEquip) {
const slots = [
"EquipmentSlot.Mainhand",
"EquipmentSlot.Offhand",
"EquipmentSlot.Head",
"EquipmentSlot.Chest",
"EquipmentSlot.Legs",
"EquipmentSlot.Feet",
"EquipmentSlot.Body"
];
for (const slot of slots) {
const item = sourceEquip.getEquipment(slot);
if (item) {
targetEquip.setEquipment(slot, item);
}
}
}
#Why doesn't work
1 messages · Page 1 of 1 (latest)
For your information, equippable components getEquipment() is exclusive to the player.
The setEquipment() still work for all mobs tho.
the slots should be:
["Mainhand", "Offhand", "Head", "Chest", "Legs", "Feet"]
"body" is for saddle or wolf armor slot iirc
you can do EquipmentSlot.whatever if you imported EquipmentSlot, however you have the elements in the array as strings, dont make them strings.
also, EquipmentSlot.Body does not exist.