Skip to content

[1.12] Equipment

Insane96 edited this page Sep 17, 2023 · 4 revisions

You can change mobs equipment by using the object "equipment".

Simple Example

This example will make zombies have 15% chance to spawn with iron or diamond helmet, with iron begin more common than diamond.

{
    "mob_id": "minecraft:zombie",
    "equipment": {
        "head": {
            "chance": {
                "amount": 15
            },
            "items": [
                {
                    "id": "minecraft:iron_helmet",
                    "weight": 5
                },
                {
                    "id": "minecraft:diamond_helmet",
                    "weight": 2
                }
            ]
        }
    }
}

Equipment ("equipment")

That's a list of all the keys available for the attribute object, if (optional) is not present then the key is REQUIRED.

  • head/chest/legs/feets/main_hand/off_hand: the equipment slot
    • override_vanilla (optional): true if the equipment in the slot should be replaced (or removed) by one of the following items. E.g. Zombies can naturally spawn with armor, with this set to true, if a zombie spawns with armor or items in hand, those equipment can be replaced by the one in items or removed if chance doesn't match. Be aware that this may replace even other mods equipment changes. (defaults to false)
    • replace_only (optional): if true the equipment will be applied to the slot only if the mob spawned with something in that slot (defaults to false)
    • chance (Object): percentage chance to set an item to the above slot.
    • items: An array with all the possible items to apply to the above slot
      • id: the item id
      • data (optional): meta of the item (e.g. for stained glass colors or stone variants) (defaults to 0)
      • weight: determines how often this item will be chosen out of all the items in the array. Items with higher weights will be used more often (chance is this item weight ⁄ total of all considered items' weights)
      • weight_difficulty (optional): an Object with "easy", "normal" and "hard" that act as modifier for weight based on difficulty. Want more chance to get a diamond sword in hard? This is the tag for you!
      • drop_chance (optional): percentage chance for a mob to drop this item on death. This is affected by Looting as 1% increase per Looting level (defaults to vanilla drop chance)
      • dimension (optional): a list of dimension IDs where this item will be applied (if omitted the item will be applied no matter in what dimension)
      • biomes (optional): a list of biome IDs (if modded biomes the mod namespace must be specified, e.g. "traverse:autumnal_forest") where this item should be applied. (if omitted the item will be applied no matter in what biome)
      • enchantments (optional): an Array of the enchantments that will apply to the item
        • chance (Object): chance to apply this enchantment.
        • id: enchantment id or "random". With "random" a random enchantment will be choosen out of all the possible enchantments for the item (to get an enchanted book you need to have item id as "enchanted_book" and not as book).
        • level (optional): enchantment min and max level (min and max default to 1)
          • min: minimum level of the enchantment
          • max: maximum level of the enchantment (optional, if omitted will be equal to min)
      • attributes (optional): A list of Item Attributes, really similar to loot tables attributes.
      • nbt (optional): A string reppresenting custom NBT data given to the item (E.g. custom names, lore, etc.)

Example

In this examples Zombies have 10% chance to wear either a Leather Helmet (66%) or Diamond Helmet (33%) with chance modified by difficulty (in easy 80% for leather and 20% for diamond; in hard 53% for leather and 47% for diamond); 5% chance (increased by local difficulty) to get a Diamond Chestplate, only if the zombie spawns in the the Nether, that has 50% chance to have Protection IV, is named "Cool Chestplate", gives 10 more health to the wearer and has 50% chance to drop on Zombie's death.

{
    "mob_id": "minecraft:zombie",
    "equipment": {
        "head": {
            "chance": {
                "amount": 10
            },
            "items": [
                {
                    "id": "minecraft:leather_helmet",
                    "weight": 10,
                    "weight_difficulty": {
                        "easy": 2,
                        "normal": 0,
                        "hard": -2
                    }
                },
                {
                    "id": "minecraft:diamond_helmet",
                    "weight": 5,
                    "weight_difficulty": {
                        "easy": -2,
                        "normal": 0,
                        "hard": 2
                    }
                }
            ]
        },
        "chest": {
            "chance": {
                "amount": 5,
                "is_local_difficulty": true,
                "multiplier": 0.5
            },
            "items": [
                {
                    "id": "minecraft:diamond_chestplate",
                    "weight": 1,
                    "dimensions": [-1],
                    "drop_chance": 50,
                    "enchantments": [
                        {
                            "id": "minecraft:protection",
                            "level": {
                                "min": 4
                            },
                            "chance": {
                                "amount": 50
                            }
                        }
                    ],
                    "attributes": [
                        {
                            "modifier": "coolChestplateMoreHealth",
                            "attribute_name": "generic.maxHealth",
                            "operation": "addition",
                            "amount": {
                                "min": 10
                            }
                        }
                    ],
                    "nbt": "{display:{Name:\"Cool Chestplate\"}}"
                }
            ]
        }
    }
}
Clone this wiki locally