Frozen

Challenge

In the Raspberry Pi version of Minecraft we can ask for the player’s current position in the world and find out what kind of block they are standing on. Then we can automate changing the blocks in the world depending on where the player moves.

Write a program to change any blocks of water that the player stands on into ice. Make sure you only change water to ice, not every block.

Extensions

Example Solution


import mcpi.minecraft as minecraft
import time

water_block_id = 9
ice_block_id = 79

world = minecraft.Minecraft.create()

while True:
  time.sleep(0.2)

  pos = world.player.getPos()
  x = pos.x
  y = pos.y
  z = pos.z

  block_below_player = world.getBlock(x, y - 1, z)

  if block_below_player == water_block_id:
    world.setBlock(x, y - 1, z, ice_block_id)