Examples (1.20 and 1.21)
Sometimes it is best to explain things with examples. In this section we will present many examples that you can use as a basis to make your own rules:
Using areas for safe spawn
Using this in areas.json you can define a safe zone around spawn:
[
{
"dimension": "minecraft:overworld",
"name": "spawn",
"type": "box",
"x": 0,
"y": 60,
"z": 0,
"dimx": 50,
"dimy": 50,
"dimz": 50
}
]
And then in spawn.json:
[
{
"hostile": true,
"area": "spawn",
"when": "onjoin",
"result": "deny"
}
]
Phases for time control
Define a phase that is true if we are after day 10. You can then use this phase in all In Control rules:
[
{
"name": "after_day10",
"conditions": {
"mindaycount": 10
}
}
]
Define phases depending on a 10 day cycle and where in the cycle we are. These phases can then be used by spawner.json (for example) to spawn the correct creatures:
[
{
"name": "zombietime",
"conditions": {
"daycount": "repeat(10,0,1)"
}
},
{
"name": "creepertime",
"conditions": {
"daycount": "repeat(10,2,3)"
}
},
{
"name": "skeletontime",
"conditions": {
"daycount": "repeat(10,4,5)"
}
}
]
Spawns: allow only in plains biome
Here are some examples for spawn.json.
This example allows only spawns in plains biomes. All other spawns are prevented:
[
{
"biome": "minecraft:plains",
"result": "allow"
},
{
"result": "deny"
}
]
Spawn: prevent all hostile mob spawns but allow spawn eggs and summon
This example prevents all hostile mob spawns. We use 'onjoin' here which is a much stronger test that normally also prevents spawn eggs and summon from working. In this example we specifically allow those first:
[
{
"hostile": true,
"when": "onjoin",
"spawntype": ["mob_summoned", "spawn_egg"],
"result": "default"
},
{
"hostile": true,
"when": "onjoin",
"result": "deny"
}
]
Spawn: prevent too many zombies
Simple script to disable spawns of a particular type of mob if there are too many (not more then 10):
[
{
"mob": "minecraft:zombie",
"mincount": 10,
"result": "deny"
}
]
Prevent all zombies based on the total number of hostile mobs. i.e. no zombies spawn if there are already more then 50 hostile mobs:
[
{
"mob": "minecraft:zombie",
"mincount": {
"amount": 50,
"hostile": true
},
"result": "deny"
}
]
Just prevent all zombies. Nothing else is changed:
[
{
"mob": "minecraft:zombie",
"result": "deny"
}
]
Just prevent all zombies, even from spawners. This is a much stronger test. Nothing else is changed:
[
{
"mob": "minecraft:zombie",
"when": "onjoin",
"result": "deny"
}
]
Spawn: prevent all passive mobs in a dimension
This example prevents ALL passive mob spawns in a certain dimension:
[
{
"passive": true,
"dimension": "dimensionmod:funkydim",
"when": "onjoin",
"result": "deny"
}
]
Spawn: allow some specific mobs only
Only allow creepers, skeletons and passive mobs:
[
{
"mob": ["minecraft:creeper", "minecraft:skeleton"],
"result": "default"
},
{
"passive": true,
"result": "default"
},
{
"result": "deny"
}
]
Spawn: allow based on height
Disallow hostile mob spawns above 50. Below 50 only allow spawns on stone and cobblestone:
[
{
"minheight": 50,
"hostile": true,
"result": "deny"
},
{
"maxheight": 50,
"block": ["minecraft:stone", "minecraft:cobblestone"],
"result": "allow"
},
{
"result": "deny"
}
]
Spawn: beefed up mobs
Make all mobs on the surface very dangerous. Underground there is a small chance of spawning invisible but weak zombies. In addition, zombies and skeleton on the surface spawn with helmets, so they don't burn:
[
{
"mob": ["minecraft:skeleton","minecraft:zombie"],
"seesky": true,
"when": "finalize",
"result": "allow",
"healthmultiply": 2,
"damagemultiply": 2,
"speedmultiply": 2,
"armorhelmet": ["minecraft:iron_helmet", "minecraft:golden_helmet"]
},
{
"seesky": true,
"hostile": true,
"when": "finalize",
"result": "allow",
"healthmultiply": 2,
"damagemultiply": 2,
"speedmultiply": 2
},
{
"seesky": false,
"random": 0.1,
"when": "finalize",
"mob": "minecraft:zombie",
"result": "allow",
"healthmultiply": 0.5,
"potion": "minecraft:invisibility,10000,1"
}
]
Make all zombies slower but have more health:
[
{
"mob": "minecraft:zombie",
"result": "default",
"when": "finalize",
"healthmultiply": 2,
"nbt": {
"Attributes": [
{
"Base": 0.23,
"Modifiers": [
{
"Operation": 2,
"Amount": -0.5,
"Name": "effect.moveSlowdown 0"
}
],
"Name": "generic.movementSpeed"
}
]
}
}
]
Loot examples
Here are some examples for loot.json.
Make blazes only spawn blaze rods if they are killed by a player in a nether fortress. The amount of blazerods will be higher if the looting level is higher:
[
{
"mob": "minecraft:blaze",
"remove": "minecraft:blaze_rod"
},
{
"mob": "minecraft:blaze",
"structure": "Fortress",
"player": true,
"item": "minecraft:blaze_rod",
"itemcount": "2-3/3-4/4-6"
}
]
Let the wither only drop a netherstar if it is killed with a stick:
[
{
"mob": "minecraft:wither",
"remove": "minecraft:nether_star"
},
{
"mob": "minecraft:wither",
"player": true,
"helditem": "minecraft:stick",
"item": "minecraft:nether_star"
}
]
In this example zombies will drop an enchanted diamond sword:
{
"mob": "minecraft:zombie",
"player": true,
"item": "minecraft:diamond_sword",
"nbt": {
"ench": [
{
"lvl": 3,
"id": 22
}
]
}
}
Effect examples
Here are a few examples for effects.json:
This example makes the player get poison effect if they are outside in the overworld. They will be put on fire if they goe to the nether, and they will get the slowness effect if they are holding a stone tool:
[
{
"timeout": 20,
"dimension": "minecraft:overworld",
"seesky": true,
"potion": "minecraft:poison,21,1"
},
{
"timeout": 20,
"dimension": "minecraft:the_nether",
"fire": 20
},
{
"timeout": 20,
"helditem": [ "minecraft:stone_pickaxe", "minecraft:stone_axe", "minecraft:stone_shovel", "minecraft:stone_sword" ],
"potion": "minecraft:slowness,21,3"
}
]
In the following example the player will get hurt if they stand on an RFTools powercell that has a lot of energy in it:
[
{
"timeout": 10,
"block": {
"block": "rftoolspower:dimensionalcell_simple",
"energy": ">10000"
},
"damage": "minecraft:hot_floor=3"
}
]
With this example the player will be put on fire if they even look at lava:
[
{
"timeout": 10,
"blockoffset": {
"look": true
},
"block": "minecraft:lava",
"fire": 20
}
]
Break Events
Here are a few examples for breakevents.json:
This example prevents the player from breaking diamond ore with an iron pickaxe:
[
{
"playerhelditem": "minecraft:iron_pickaxe",
"block": "minecraft:diamond_ore",
"message": "You cannot mine this!",
"result": "deny"
}
]
In the next example diamond ore can only be broken with an undamaged pickaxe:
[
{
"playerhelditem": {
"item": "minecraft:iron_pickaxe",
"damage": ">=1"
},
"block": "minecraft:diamond_ore",
"message": "You cannot mine this!",
"result": "deny"
}
]
And in this example the pickaxe has to be enchanted with a specific enchantment:
[
{
"playerhelditem": {
"item": "minecraft:iron_pickaxe",
"nbt": [
{
"tag": "ench",
"contains": [
{
"tag": "id",
"value": 34
}
]
}
]
},
"block": "minecraft:diamond_ore",
"result": "allow"
},
{
"block": "minecraft:diamond_ore",
"message": "You cannot mine this!",
"result": "deny"
}
]
With 50% chance give an extra diamond when the player mines a diamond ore block:
[
{
"playerhelditem": {
"item": "minecraft:diamond_pickaxe"
},
"block": "minecraft:diamond_ore",
"random": 0.5,
"give": "minecraft:diamond",
"result": "allow"
}
]
Right Click examples
Here are a few examples for rightclicks.json:
In this example the player can only open chests with a stick in his or her hand:
[
{
"playerhelditem": "minecraft:stick",
"block": "minecraft:chest",
"result": "allow"
},
{
"block": "minecraft:chest",
"message": "The chest is locked!",
"result": "deny"
}
]
If we extend this example with another rule then we can also make sure that the chest can be opened without sticks provided the chest itself contains sufficient sticks:
[
{
"playerhelditem": "minecraft:stick",
"block": "minecraft:chest",
"result": "allow"
},
{
"block": {
"block": "minecraft:chest",
"contains": {
"item": "minecraft:stick",
"count": ">10"
}
},
"result": "allow"
},
{
"block": "minecraft:chest",
"message": "The chest is locked!",
"result": "deny"
}
]
Events: spawn chickens when a cow is killed
In this example we spawn a random amount of chickens when a cow is killed:
[
{
"on": "mob_killed",
"parameters": {
"mob": "minecraft:cow",
"player": true
},
"conditions": {
"dimension": "minecraft:overworld",
"random": 0.3
},
"spawn": {
"mob": "minecraft:chicken",
"mindistance": 3,
"maxdistance": 5,
"mincount": 2,
"maxcount": 3,
"attempts": 20
}
}
]
Events: spawn wither skeleton when diamond ore is broken
In this example we possibly spawn a wither skeleton when we break a diamond ore block:
[
{
"on": "block_broken",
"parameters": {
"block": {
"block": "minecraft:diamond_ore"
}
},
"conditions": {
"dimension": "minecraft:overworld",
"random": 0.3
},
"spawn": {
"mob": "minecraft:wither_skeleton",
"mindistance": 0,
"maxdistance": 2,
"attempts": 20,
"norestrictions": true
}
}
]
Spawner: spawn villagers in water
Spawns random villagers near the player in water.
Using groupdistance these villager groups will spawn near each other (only for 1.18 and higher):
[
{
"mob": "minecraft:villager",
"persecond": 0.5,
"attempts": 20,
"amount": {
"minimum": 2,
"maximum": 5,
"groupdistance": 3
},
"conditions": {
"dimension": "minecraft:overworld",
"inwater": true,
"mindist": 5,
"maxdist": 20,
"minheight": 45,
"maxheight": 175,
"maxthis": 20
}
}
]
Spawner: increase hostile mob spawns after day 20
In the following example we globally increase hostile mob spawns after day 20 (using phases).
First phases.json:
[
{
"name": "after_day20",
"conditions": {
"mindaycount": 20
}
}
]
Then spawner.json:
[
{
"phase": "after_day20",
"mobsfrombiome": "monster",
"persecond": 0.5,
"attempts": 20,
"amount": {
"minimum": 2,
"maximum": 5
},
"conditions": {
"dimension": "minecraft:overworld",
"maxhostile": 200
}
}
]
Spawner: advanced example, extra mobs in deserts
Here is a more advanced example where spawn.json and spawner.json are used together to get full control.
Let's say you want to spawn some extra mobs in deserts but otherwise keep vanilla spawn rates the same.
So first add a rule to spawner.json to add new spawns.
Basically we add skeletons and zombies with a maximum of 100 per mob (so maximum 100 skeletons and maximum 100 zombies):
[
{
"mob": ["minecraft:skeleton", "minecraft:zombie"],
"persecond": 0.5,
"attempts": 20,
"amount": {
"minimum": 2,
"maximum": 5
},
"conditions": {
"dimension": "minecraft:overworld",
"mindist": 25,
"maxdist": 100,
"minheight": 15,
"maxheight": 200,
"maxthis": 100
}
}
]
But we only want these extra mobs in deserts.
So you could do this in spawn.json:
[
{
"mob": ["minecraft:skeleton", "minecraft:zombie"],
"dimension": "minecraft:overworld",
"biome": "minecraft:desert",
"result": "default"
},
{
"mob": ["minecraft:skeleton", "minecraft:zombie"],
"dimension": "minecraft:overworld",
"result": "deny"
}
]
But that's not good.
These two rules will allow the zombies and skeletons to spawn in the desert, but they will get denies everywhere else.
We don't want to touch spawns of zombies and skeletons outside deserts.
So let's modify the rules in spawn.json:
[
{
"mob": ["minecraft:skeleton", "minecraft:zombie"],
"dimension": "minecraft:overworld",
"biome": "minecraft:desert",
"result": "default"
},
{
"mob": ["minecraft:skeleton", "minecraft:zombie"],
"dimension": "minecraft:overworld",
"incontrol": true,
"result": "deny"
}
]
Basically by adding "incontrol": true to the second rule we will only deny spawns outside deserts if they were spawned by In Control.
All normal mob spawns will stay normal.
Spawner: extra mobs in deserts on the surface but not in villages
This example is similar to the previous one, but we demonstrate the usage of the new 'and' and 'not' format. This is more optimized and
means we no longer need rules in spawn.json:
[
{
"mob": ["minecraft:skeleton", "minecraft:zombie"],
"persecond": 0.5,
"attempts": 20,
"amount": {
"minimum": 2,
"maximum": 5
},
"conditions": {
"dimension": "minecraft:overworld",
"mindist": 25,
"maxdist": 100,
"minheight": 15,
"maxheight": 200,
"maxthis": 100,
"and": {
"biome": "minecraft:desert",
"seesky": true
},
"not": {
"structuretags": "minecraft:village"
}
}
}
]
Getting Zombies to spawn more
This is commonly requested so I decided to add an example here. First you need to add a rule to spawner.json
to make them spawn more. This can be done with the following rule. This will make zombies spawn up to a maximum of 200.
Using 'norestrictions' should also make them spawn during daylight:
[
{
"mob": "minecraft:zombie",
"persecond": 0.5,
"attempts": 20,
"amount": {
"minimum": 2,
"maximum": 5
},
"conditions": {
"dimension": "minecraft:overworld",
"norestrictions": true,
"mindist": 25,
"maxdist": 100,
"minheight": 15,
"maxheight": 200,
"maxthis": 200
}
}
]
If needed you can then use rules in spawn.json to control when and how they spawn. For example,
let's make them spawn more on the surface and less in caves (but they can still spawn there). Let's
also say that we don't want to spawn any zombies in the first 5 days after starting the world. We have
to use "when": "onjoin" in these rules because norestrictions in spawner.json:
[
{
"mob": "minecraft:zombie",
"daycount": "lt(5)",
"when": "onjoin",
"result": "deny"
},
{
"mob": "minecraft:zombie",
"seesky": true,
"when": "onjoin",
"result": "default"
},
{
"mob": "minecraft:zombie",
"random": 0.8,
"when": "onjoin",
"result": "deny"
}
]
Note. If you remove norestrictions then you can also use the default position check for when but in that
case you should probably use the result allow instead of default to bypass mob specific restrictions.
Making a dangerous world after spawning a wither
As soon as a wither is spawned in the world we want to make the world more dangerous and start spawning wither skeletons.
First in spawn.json we detect if a wither is spawned and then we set the wither phase:
[
{
"mob": "minecraft:wither",
"when": "onjoin",
"setphase": "wither",
"result": "default"
}
]
Then in spawner.json we start spawning wither skeletons as soon as the wither phase is set:
[
{
"mob": "minecraft:wither_skeleton",
"persecond": 5,
"attempts": 20,
"phase": "wither",
"amount": {
"minimum": 1,
"maximum": 1
},
"conditions": {
"dimension": "minecraft:overworld",
"mindist": 20,
"maxdist": 90,
"minheight": -64,
"maxheight": 256,
"maxthis": 10
}
}
]
Changing what a spawner spawns
In this example we change zombie spawners so that they spawn chickens instead:
In spawn.json we add a rule for spawns from zombies and send out a custom event called chicken_instead.
We use deny_with_actions as a result because we want to deny the spawn but still call the custom event action.
{
"mob": "minecraft:zombie",
"spawner": true,
"customevent": "chicken_instead",
"when": "onjoin",
"result": "deny_with_actions"
}
In events.json we add a rule for the custom event chicken_instead and we spawn a chicken instead of a zombie:
{
"on": "custom",
"parameters": {
"name": "chicken_instead"
},
"conditions": {
"dimension": "minecraft:overworld"
},
"spawn": {
"mob": "minecraft:chicken",
"mindistance": 0,
"maxdistance": 2,
"mincount": 1,
"maxcount": 1,
"attempts": 20,
"norestrictions": true
}
}
Spawning wither skeletons as soon as too many diamond ore blocks are mined
First we define an event to count whenever a diamond ore block is broken. Add this to
events.json:
[
{
"on": "block_broken",
"parameters": {
"block": {
"block": "minecraft:diamond_ore"
}
},
"conditions": {
"dimension": "minecraft:overworld"
},
"number": {
"name": "diamonds",
"value": "+1"
}
}
]
Instead of this we could also have added a rule to breakevents.json to count the number of diamonds:
[
{
"block": "minecraft:diamond_ore",
"changenumber": "diamonds=+1"
}
]
Then in spawner.json we add spawning of wither skeletons as soon as the number is high enough:
[
{
"mob": "minecraft:wither_skeleton",
"number": {
"name": "diamonds",
"expression": "gt(100)"
},
"persecond": 1,
"attempts": 20,
"amount": {
"minimum": 1,
"maximum": 1
},
"conditions": {
"dimension": "minecraft:overworld",
"mindist": 20,
"maxdist": 90,
"minheight": -64,
"maxheight": 256,
"maxthis": 10
}
}
]
Scenario: Zombie apocalypse world
This example shows how to make a world where only zombies can spawn. For the first two days no zombies can spawn at all. After two days, zombies start spawning even on the sunlit surface (they get helmets so they don’t burn), but not inside player houses or other well‑lit places (we’ll use block light for that). After day 5 the zombies get stronger, and after day 10 they get even stronger. We’ll also set up a safe zone around world spawn that is always safe. Note that this is just an example. There are many more possibilities and options provided by this mod. Also if you have a mod that makes zombies not burn in daylight you don't even have to use the helmets.
We’ll use phases.json, areas.json, spawner.json and spawn.json.
- phases.json — keep track of time milestones we care about
These phases defined here keep track of the days that have passed. Keep in mind that In Control does NOT use the regular Minecraft time for this but instead counts the number of night->day transitions. Use the 'incontrol days' command to view and set this.
Because every phase uses 'mindaycount' as a condition it means that the 'after_day2' phase will also be active even if we are after day 5. That's something that has to be taken into account in the future rules.
The "safe_time" rule is the opposite of "after_day2" but it is used to make defining some rules easier. Not that 'maxdaycount' is not inclusive.
[
{
"name": "safe_time",
"conditions": {
"maxdaycount": 3
}
},
{
"name": "after_day2",
"conditions": {
"mindaycount": 2
}
},
{
"name": "after_day5",
"conditions": {
"mindaycount": 5
}
},
{
"name": "after_day10",
"conditions": {
"mindaycount": 10
}
}
]
- areas.json — define a safe zone around spawn
[
{
"dimension": "minecraft:overworld",
"name": "spawn_safe",
"type": "box",
"x": 0,
"y": 60,
"z": 0,
"dimx": 50,
"dimy": 40,
"dimz": 50
}
]
- spawner.json — actively spawn zombies on the surface in daylight
With spawner.json we spawn zombies unrestricted (due to the "norestrictions" tag). Note: the safe zone is enforced in spawn.json. If the 'after_day10' phase is active the second rule in spawner.json will also fire which will add up to the total amount of spawns and make zombies spawn faster and closer to the player. Note that the first rule will still be active then. Both rules will contribute to spawning zombies after day 10. The last rule is a special addition that also spawns even more zombies in mountains. This rule uses "and" for additional conditions that are not part of the regular "conditions" block. This is just example, remove or modify as needed.
[
{
"mob": "minecraft:zombie",
"persecond": 0.5,
"attempts": 20,
"amount": { "minimum": 1, "maximum": 3 },
"conditions": {
"dimension": "minecraft:overworld",
"norestrictions": true,
"mindist": 30,
"maxdist": 100,
"minheight": 10,
"maxheight": 200,
"maxthis": 100
}
},
{
"phase": "after_day10",
"mob": "minecraft:zombie",
"persecond": 1,
"attempts": 20,
"amount": { "minimum": 2, "maximum": 5 },
"conditions": {
"dimension": "minecraft:overworld",
"norestrictions": true,
"mindist": 20,
"maxdist": 100,
"minheight": 10,
"maxheight": 200,
"maxthis": 200
}
},
{
"mob": "minecraft:zombie",
"persecond": 1,
"attempts": 20,
"amount": { "minimum": 1, "maximum": 2 },
"conditions": {
"dimension": "minecraft:overworld",
"norestrictions": true,
"mindist": 20,
"maxdist": 50,
"minheight": 100,
"maxheight": 300,
"maxthis": 200,
"and": {
"biometags": "minecraft:is_mountain"
}
}
}
]
- spawn.json — enforce “only zombies”, delay the apocalypse 2 days, keep houses safe, and scale difficulty over time
Because spawner.json uses "norestrictions", we must use "when": "onjoin" for allow/deny positioning rules. "norestrictions" makes it so that regular rules in spawn.json don't fire. But they will fire with "onjoin" and "finalize". We use "when": "finalize" to equip helmets and to buff zombies based on phases.
The first four rules happen in "when": "onjoin" which means they happen first. If the fourth rule denies a spawn the "finalize" rules also will not happen.
- First rule will deny all hostile mob spawns in the safe zone.
- The second rule denies all zombie spawns for the safe time which is for the first two days.
- After day 2: allow zombies with block light 0 or 1. This will allow zombies to spawn at the surface during the day (because we only look at block light) and also in caves
- Then deny all hostile spawns
The rules after the first four are done in the 'finalize' phase and they will enhance whatever zombie ends up spawning depending on the current active phase. Remember that when the phase 'after_day10' is active, the phases 'after_day5' and 'after_day2' will also be active. For that reason we put the rule for 'after_day10' first so that the other rules will not get activated (rules are executed in order, first rule that matches will fire).
Note about the first "finalize" rule. This one gives a small boost to health to all zombies that spawn at night. Because it uses "continue": true this rule will also not stop execution of further rules. Which means that at night zombies will get that health boost in addition to the helmet and other boosts that are applied later.
Let's clarify "when" a bit ('onjoin' and 'finalize'). Every zombie that spawns will go through this file at least three times. The first time is called only for natural spawning ("when": "position") but we don't use that here. Note that because we use "norestrictions" in spawner.json the zombies that are spawn there will not even go through the 'position' setup). The second time is when the zombie is added to the world ("when": "onjoin"). Here is where we do the majority of the work checking if the spawn should go through or not. The final time is when the zombie has succesfullly been added to the world. Here we set up equipment and stats.
[
{
"hostile": true,
"area": "spawn_safe",
"when": "onjoin",
"result": "deny"
},
{
"mob": "minecraft:zombie",
"phase": "safe_time",
"when": "onjoin",
"result": "deny"
},
{
"mob": "minecraft:zombie",
"phase": "after_day2",
"maxlight": 1,
"when": "onjoin",
"result": "allow"
},
{
"hostile": true,
"when": "onjoin",
"result": "deny"
},
{
"mob": "minecraft:zombie",
"when": "finalize",
"mintime": 13000,
"maxtime": 23000,
"healthadd": 10,
"continue": true
},
{
"mob": "minecraft:zombie",
"phase": "after_day10",
"when": "finalize",
"result": "allow",
"healthmultiply": 3.0,
"damagemultiply": 2.5,
"speedmultiply": 1.3,
"armorhelmet": ["minecraft:iron_helmet", "minecraft:golden_helmet"]
},
{
"mob": "minecraft:zombie",
"phase": "after_day5",
"when": "finalize",
"result": "allow",
"healthmultiply": 2.0,
"damagemultiply": 1.5,
"speedmultiply": 1.15,
"armorhelmet": ["minecraft:iron_helmet", "minecraft:golden_helmet"]
},
{
"mob": "minecraft:zombie",
"when": "finalize",
"result": "allow",
"armorhelmet": ["minecraft:iron_helmet", "minecraft:golden_helmet"]
}
]