|
| 1 | +--- |
| 2 | +title: Adding Mob Variants |
| 3 | +description: "Learn how to add custom mob variants with Minecraft datapacks" |
| 4 | +version: 1.21.8 |
| 5 | +--- |
| 6 | + |
| 7 | +# How to add custom mob variants |
| 8 | + |
| 9 | +By the end of this guide, you will be able to add your own naturally spawning mob variants, including custom spawn conditions. |
| 10 | + |
| 11 | +This will only work in 1.21.5+, as data-driven mob variants were added in the snapshot 25w04a. |
| 12 | +:::info |
| 13 | +This guide requires you |
| 14 | +to have at least a small understanding of datapacks. If you don't understand this guide, you can read the [Getting Started |
| 15 | +guide](/guide/getting-started). |
| 16 | +::: |
| 17 | + |
| 18 | +## Creating a cat variant |
| 19 | + |
| 20 | +### Setting up the datapack |
| 21 | + |
| 22 | +To start you will need a basic datapack, if you don't know how to make one, see the |
| 23 | +[Getting Started](/guide/getting-started) guide. |
| 24 | + |
| 25 | +Firstly, we are going to create the main cat variant file in the directory `data/<namespace>/cat_variant/`. |
| 26 | +You can name the file whatever you want, but it has to be in the `.json` file format. For the purposes of this tutorial, we're |
| 27 | +going to call it `example_cat.json`. Inside, we will put and configure these settings: |
| 28 | + |
| 29 | +```json:example_cat.json |
| 30 | +{ |
| 31 | + "asset_id": "example:entity/cat/example_cat", |
| 32 | + "spawn_conditions": [ |
| 33 | + { |
| 34 | + "priority": 0 |
| 35 | + } |
| 36 | + ] |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +This is a run-down of the fields in that file: |
| 41 | +- `asset_id`: The resource location of the paintings texture to use. In this example, `example:entity/cat/example_cat` directs to `assets/example/textures/entity/cat/example_cat.png`. |
| 42 | +- `spawn_conditions`: A list of spawn conditions, each with a priority. Right now we only have one, with a priority of 0. This means it will spawn like any other cat texture. |
| 43 | + |
| 44 | +### Settings up the resource pack |
| 45 | + |
| 46 | +Next we are going to add the actual texture file for the cat variant. This needs to be placed in `assets/<namespace>/textures/entity/cat/`, and match the name you specified in the `asset_id` field earlier. In this example that is `example_cat.png`. |
| 47 | + |
| 48 | +### Testing |
| 49 | + |
| 50 | +If you load the datapack and the resource pack, you should now be able to spawn your cat using `/summon minecraft:cat ~ ~ ~ {variant:"example:example_cat"}` |
| 51 | + |
| 52 | +:::warning |
| 53 | +For this to work, you will need to leave and rejoin the world, just using the `/reload` command won't do the trick here! |
| 54 | +::: |
| 55 | + |
| 56 | +## Adding more spawn conditions |
| 57 | + |
| 58 | +To add more spawn conditions, you can add more entries to the `spawn_conditions` field in the .json file you created earlier. |
| 59 | + |
| 60 | +```json:example_cat.json |
| 61 | +{ |
| 62 | + "asset_id": "example:entity/cat/custom", |
| 63 | + "spawn_conditions": [ |
| 64 | + { |
| 65 | + "condition": { |
| 66 | + "type": "minecraft:structure", |
| 67 | + "structures": "minecraft:village_snowy" |
| 68 | + }, |
| 69 | + "priority": 1 |
| 70 | + }, |
| 71 | + { |
| 72 | + "condition": { |
| 73 | + "type": "minecraft:biome", |
| 74 | + "biomes": "snowy_taiga" |
| 75 | + }, |
| 76 | + "priority": 1 |
| 77 | + }, |
| 78 | + { |
| 79 | + "priority": 0 |
| 80 | + } |
| 81 | + ] |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +This cat variant will spawn with a priority level of 1 if it spawns in a snowy village or a snowy taiga. If another cat variant were to meet its spawn conditions, the game would randomly select a variant. |
| 86 | + |
| 87 | +For more spawn conditions, see [this page](https://minecraft.wiki/w/Mob_variant_definitions#Spawn_condition) on the minecraft wiki. |
| 88 | + |
| 89 | +## Other mobs with variants |
| 90 | + |
| 91 | +You can also add variants for these mobs: |
| 92 | +- chicken |
| 93 | +- cow |
| 94 | +- frog |
| 95 | +- pig |
| 96 | +- wolf |
| 97 | + |
| 98 | +For example, if you wanted to add a frog variant, you would: |
| 99 | +1. Create a variant file in `data/<namespace>/frog_variant` |
| 100 | +2. Add something like the following to the file: |
| 101 | + |
| 102 | +```json:example_frog.json |
| 103 | +{ |
| 104 | + "asset_id": "example:entity/frog/example_frog", |
| 105 | + "spawn_conditions": [ |
| 106 | + { |
| 107 | + "priority": 0 |
| 108 | + } |
| 109 | + ] |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +3. Add the texture to `assets/<namespace>/textures/entity/frog/example_frog` |
| 114 | + |
| 115 | +## Mobs with additional fields |
| 116 | + |
| 117 | +If you want to add a chicken, cow, or pig variant, you'll also need to specify the `model` field, like this: |
| 118 | + |
| 119 | +```json:example_cow.json |
| 120 | +{ |
| 121 | + "asset_id": "example:entity/cow/example_cow", |
| 122 | + "model": "normal", |
| 123 | + "spawn_conditions": [ |
| 124 | + { |
| 125 | + "priority": 0 |
| 126 | + } |
| 127 | + ] |
| 128 | +} |
| 129 | +``` |
| 130 | + |
| 131 | +The `model` field can be `normal`, `cold` or `warm` for cows, and just `normal` or `cold` for chickens and pigs. |
| 132 | + |
| 133 | +If you want to add a wolf variant, you'll need to specify 3 textures, like this: |
| 134 | + |
| 135 | +```json:example_wolf.json |
| 136 | +{ |
| 137 | + "assets": { |
| 138 | + "angry": "example:entity/wolf/example_wolf_angry", |
| 139 | + "tame": "minecraft:entity/wolf/example_wolf_tame", |
| 140 | + "wild": "minecraft:entity/wolf/example_wolf" |
| 141 | + }, |
| 142 | + "spawn_conditions": [ |
| 143 | + { |
| 144 | + "priority": 0 |
| 145 | + } |
| 146 | + ] |
| 147 | +} |
| 148 | +``` |
| 149 | + |
| 150 | +It's worth noting that you can't add custom variants for some mobs like Horses and Rabbits. If it's not in the list mentioned earlier, then it can't be added using a datapack. |
0 commit comments