Introduction
15 minEverything you have built so far is empty.
You have made floors, towers, rooms and houses, and not one of them has anything living in it. Today your world gets inhabitants.
The spawn block
The Mobs drawer has a block that takes two things — a creature, and a place to put it:
spawn
cowat~0 ~1 ~0
That is all. The position works exactly like a fill corner: a world address for somewhere fixed, or a tilde offset for somewhere near you.
Mobs are not blocks
This is worth getting straight early, because it explains most of what goes wrong:
| Blocks | Mobs | |
|---|---|---|
| Placed with | fill, place | spawn |
| Stay where you put them | yes | no — they wander |
| Can be cloned | yes | no |
| Removed by | filling with air | not by filling |
A cow is not part of your building. It is a visitor standing inside it, and it will walk off if you let it.
So animals need somewhere to live
That is why this lesson comes after Lesson 8 and not before. A spawn block on its own gives you an animal in a field, and it wanders away within a minute.
A spawn block inside a pen you built gives you a farm.
The recipe for the rest of the lesson is always the same three steps:
fillthe walls of an enclosure,spawnthe animals inside it,- check the spawn position really is within the walls.
⚠️ Peaceful worlds have no monsters
In Lesson 1 you set Difficulty: Peaceful, and that has a consequence you need to know now.
Animals spawn perfectly well in Peaceful — cows, pigs, sheep, chickens, salmon, tropical fish. They are all you need today.
Monsters do not. A zombie or a skeleton spawned into a Peaceful world vanishes immediately. If you ever want them, the difficulty has to change in the world settings first — and there is a lesson later where you will want exactly that.
Warm-up — a zoo with no fences
Imagine a zoo that spent all its money on beautiful enclosures and then released the animals outside them.
That is what a spawn block without a pen does. The animal is real, the building is real, and they have nothing to do with each other. Today is about making the two line up.
What you will be able to do
- Spawn any animal at a position you choose.
- Spawn a whole herd with a loop instead of one block per animal.
- Build a pen and get the animals reliably inside it.
- Build a glass aquarium, fill it with water, and put fish in it.
Basic
20 minFollow along on your own computer. Everyone should finish this part with the same working build.
Step 1 — One cow
Press C and start a new chat command called cow. The spawn block is in the Mobs drawer.
Go into the world and type cow.
A cow appears two blocks in front of you. Note the ~1 — one block above your feet. Spawn a mob at ~0 and it starts off inside the ground, which it does not enjoy.
Step 2 — A whole herd
One cow, one block. Five cows should not be five blocks — you learned that in Lesson 3.
Type herd. Five cows appear at the same spot and immediately shove each other apart, which is exactly what real animals do.
Change the 5 to 20 and watch what a loop does to a field.
Step 3 — Build the pen first
Now the useful version. A pen is a hollow box with no roof — which is just a fill you already know how to write.
The second fill removes the lid, because hollow gives you a closed box and animals in a sealed crate is not farming.
Step 4 — Put the animals inside
Here is the part that goes wrong. The spawn position must be within the walls, not on them and not outside them.
The pen runs from ~0 to ~9, so its inside runs from ~1 to ~8. A spawn at ~5 ~1 ~5 is comfortably in the middle.
Challenge 1
15 minA pen that holds.
Build an enclosure and get the animals to stay in it.
- Press
Cand start a new chat command calledpigpen. - Build a pen 12 blocks by 12 and 3 blocks tall, open at the top, using relative positions so it appears where you stand.
- Spawn 8 pigs inside it, using a loop rather than eight spawn blocks.
- Work out the inside corners before you type the spawn position. A pen from
~0to~11is not open from~0to~11. - Go into the world, type
pigpen, then walk all the way round the outside and count the pigs.
It works if: eight pigs are inside the pen, none of them are standing in a wall or outside it, and they are all still there a minute later.
Challenge 2
20 minThe aquarium.
Glass, water and fish — in that order, and each one inside the last.
- Press
Cand start a new chat command calledaquarium. - Build a glass tank 10 by 10 and 8 blocks tall, hollow, where you are standing.
- Fill the inside of it with water. Think carefully about which corners that means.
- Spawn at least two different kinds of fish in it, several of each, using loops.
- Type
aquarium, then walk round it and look in through the glass.
If the whole thing collapses into a puddle, your water fill and your glass fill are using the same corners. Only one of them should touch the edge.
It works if: the tank holds its water, you can see fish of two kinds swimming about inside it through the glass, and none of them are stuck in the walls.
Challenge 3
25 minA farm worth visiting.
One pen is a pen. Several is a farm.
- Press
Cand start a new chat command calledfarm. - Build a farm with at least three separate enclosures, side by side, each holding a different animal.
- At least one enclosure must be a water tank with fish in it, and at least two must be land pens.
- Every animal must be spawned with a loop, and every pen must actually contain its animals.
- Work out the offsets so the pens sit beside each other without overlapping. Two fills that share a block will fight, and the later one wins.
- Type
farm, then walk the length of it.
It works if: three or more enclosures stand side by side with no gaps in their walls, each holds several animals of its own kind, the fish are in water and the land animals are not, and nothing has escaped.
Extra challenge
spare timeA zoo to order.
Let the visitor decide how big the farm is.
- Press
Cand start a new chat command calledzoo. - Click the (+) and rename the number to
herd. - Guard it, as in Lesson 6: fewer than 1 or more than 30 gets a message and no build.
- Otherwise build a pen and spawn exactly
herdanimals inside it, using the typed number to drive the loop. - Make the pen grow with the herd — a bigger number should give a bigger enclosure, not the same pen crammed with animals.
- Try
zoo 4, thenzoo 25, thenzoo 100, thenzooon its own.
Step 5 is the interesting part. If the pen is a fixed size, thirty animals stand on top of each other. The far corner of the fill has to be worked out from herd, exactly as the hall did in Lesson 7.
It works if: zoo 4 gives a small pen with four animals with room to spare, zoo 25 gives a visibly larger pen with twenty-five, and both zoo 100 and a bare zoo are refused with a message.