Sand Storm
Introduction
Want to throw some sand around? Make a small sand storm in this tutorial. You will learn to place a block of sand at a position and then use random positions to make sand appear anywhere near you.
Add sand
Add code to place a sand block (SAND
) at 10 blocks above your position (0, 10, 0)
.
# @highlight
blocks.place(SAND, pos(0, 10, 0))
Use your new command!
Run the program and look to see what happens in Minecraft. You should see a block at your position.
Random positions
Create a random position and store it in a variable named p
.
# @highlight
p = randpos(pos(0, 0, 0), pos(0, 0, 0))
blocks.place(SAND, pos(0, 10, 0))
From here to there
Edit the positions so that blocks are generated randomly in an area around the player,
from (-10, 10, -10)
to (10, 10, 10)
.
# @highlight
p = randpos(pos(-10, 10, -10), pos(10, 10, 10))
blocks.place(SAND, pos(0, 0, 0))
Use your variable
Use the variable p
in to place a block at the random position.
p = randpos(pos(-10, 10, -10), pos(10, 10, 10))
# @highlight
blocks.place(SAND, p)
Use your sandstorm command!
Run your program again. You should see a block of sand fall from the sky.
Repeat
Put the code inside a for loop to repeat it 100
times.
# @highlight
for i in range(100):
p = randpos(pos(-10, 10, -10), pos(10, 10, 10))
blocks.place(SAND, p)
Run your program!
Run your program as to see what will happen in Minecraft. Watch out for sand!