TeachCraft Lesson 3

Blocks, Lava, and a Bird's Eye View

The next minecraft api function we are going to look at is mc.setBlock(x, y, z, block_id). X/Y/Z are the coordinates of the block you want to set, and block_id is the number representing the block (you can see all the numbers here).

In the example code on the right, we are getting the player's current position, setting a dirt block 50 units above their head, and then teleporting the player onto the dirt block.

This gives us a bird's eye view of the map, and can teleport us to safety rapidly if need be! Try it out!

Sample Code

Your Challenge: Walk in the lava without dying!

When you walk into lava, you will get set on fire. To avoid your character dying, you must find water to put out the fire...

Your Challenge: Write a script that when executed, spawns water over your head to save you from burning. To prove your script works, touch the lava to set yourself on fire, then spawn water to put out the fire.