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.
Step 1: 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))
Step 2: Use your new command!
Run the program and look to see what happens in Minecraft. You should see a block at your position.
Step 3: 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))
Step 4: 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))
Step 5: 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)
Step 6: Use your sandstorm command!
Run your program again. You should see a block of sand fall from the sky.
Step 7: 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)
Step 8
Run your program as to see what will happen in Minecraft. Watch out for sand!