While all of the normal NBT-data applies to all mobs, NPCs with inventories and gear have even more NBT tags that can apply.
Equipment[]
Also found on this page, all non-player entities have a standard set of non-named slots for equipment, from vanilla Minecraft.
In the legacy version (Minecraft 1.7.10) this is:
{Equipment: [{id: ____}, {id: ____}, {id: ____}, {id: ____}, {id: ____}]}
{} 0: The item being held in the mob's hand.
{} 1: Armor (Feet)
{} 2: Armor (Legs)
{} 3: Armor (Chest)
{} 4: Armor (Head)
In the renewed version (Minecraft 1.15, 1.16) the format is different, due to the addition of an off-hand for dual wielding - and there are separate arrays for armour and hand items:
{ArmorItems: [{id: ____}, {id: ____}, {id: ____}, {id: ____}]}
{} 0: Armor (Feet)
{} 1: Armor (Legs)
{} 2: Armor (Chest)
{} 3: Armor (Head)
{HandItems: [{id: ____}, {id: ____}]}
{} 0: Main hand (e.g. sword)
{} 1: Off-hand (e.g. shield)
The mod's NPCs use the four armour slots in the same way as vanilla.
However, held items are handled differently. The mod's NPCs use a more advanced system that allows them to switch between various held items, depending on their current activity - idle, melee, etc. This is detailed below.
Held Items[]
NPCs have a unique tag array, "NPCItemsInv"
, that keeps track of the items they should hold in different situations. For NPCs, the vanilla 'held item' slot is just a placeholder to display the current item; the NPC AI fills it with an item copied from NPCItemsInv
depending on the NPC's state.
Therefore, if an NPC is summoned with custom data in the vanilla 'held item' slot, it will be immediately replaced by the relevant item from NPCItemsInv
. If you wish to customise NPCs' held items, you must use this framework in your command.
Mevans showed how each specific type of item is assigned in this post.
In the {NPCItemsInv:[]}, there are 12 different fields that can be specified, these being
{NpcItemsInv:[{Slot:0, ____}, {Slot:1, ____}, {Slot:2, ____}, {Slot:3, ____}, {Slot:4, ____}, {Slot:5, ____}, {Slot:6, ____}, {Slot:7, ____}, {Slot:8, ____}, {Slot:9, ____}, {Slot:10, ____}, {Slot:11, ____}]}
Each of these assigns a different item to a different "slot" of an NPC
- Slot:0 - an NPC's Idle Item, what they hold while not in combat
- Slot:1 - an NPC's Melee Weapon, what they use for melee combat
- Slot:2 - an NPC's Ranged Weapon, what they use for ranged combat
- Slot:3 - an NPC's Spear Backup, what they use after their spear has been thrown
- Slot:4 - an NPC's Eating Backup, what they were holding before they started eating or drinking, and will restore when finished
- Slot:5 - an NPC's Idle Mounted Backup, what they hold while mounted
- Slot:6 - an NPC's Melee Mounted Weapon, what they attack with while mounted
- Slot:7 - an NPC's Replaced Idle Item, what they "remember" if you give an NPC custom gear
- Slot:8 - an NPC's Replaced Mounted Melee Weapon, what they "remember" if you give custom gear to a mounted NPC
- Slot:9 - an NPC's Replaced Mounted Ranged Weapon, what they "remember" if you give custom gear to a mounted archer
- Slot:10 - an NPC's Bombing Idle Item, what bombardiers hold in their off-hand
- Slot:11 - an NPC's Bomb, this specifies how strong the Orc Bomb is
Note that if you summon a Gondorian Baker with a bow in Slot 2, this will not automatically make him an archer. The slots are dependent on the type of NPC, not vice versa.
Replaced Items[]
With the new NPC format that allows players to replace NPCs' weapons and armour, there are 7 other NBT tags that can be applied to {HiredReplacedItems:[]} :
{HiredReplacedItems:[{Slot:0, ____}, {Slot:1, ____}, {Slot:2, ____}, {Slot:3, ____}, {Slot:4, ____}, {Slot:5, ____}, {Slot:6, ____}]}
These specify what an NPC has "underneath" player-given armour.
- {Slot:0} is the Helmet
- {Slot:1} is the Chestplate
- {Slot:2} is the Leggings
- {Slot:3} is the Boots
- {Slot:4} is the Melee Weapon
- {Slot:5} is the Orc Bomb
- {Slot:6} has no use yet, but will be for a Ranged Weapon
These are not very useful for custom commands, as the player has already given armour, but could possibly be used for role-play scenarios where a unit is "disguised" with another faction's armour.
Examples[]
This may all seem very confusing, but with a little practice, you could be creating your own well-equipped NPC. Here are a few explained examples to help break down parts of the NBT tag.
lotr_summon lotr.RohirrimArcher ~ ~ ~ {Equipment: [{}, {id:314}, {id:315}, {id:316}, {id:317}]}
This will summon a Rohirrim Archer, with nothing in his hand, wearing Golden Armour. Note that since Item IDs are not fixed, using the name is also acceptable, such as
lotr_summon lotr.RohirrimArcher ~ ~ ~ {Equipment: [{}, {minecraft:golden_helmet}, {minecraft:golden_chestplate}, {minecraft:golden_leggings}, {minecraft:golden_boots}]}
This makes it easier to understand, and can be copied from world to world.