Minecraft: PI – Place Blocks Under the Player

This script will place blocks under the player while walking around.

# Import the minecraft library
import mcpi.minecraft import Minecraft
import time

# connect to the minecraft client
mc = Minecraft.create()

# cobblestone
blockType = 4

# place blocks under the player
while True:
  pos = mc.player.getTilePos()
  height = mc.getHeight(pos.x, pos.y)
  mc.setBlock(pos.x, pos.y - 1, pos.z, blockType)
  time.sleep(0)

Minecraft: PI – Create Blocks

Devin picked up “Learn to Program with Minecraft” at the Pacific Science Center in Seattle.

After the first 3 chapters, Devin has the player teleporting and spawning a grid of melons.

# Import the minecraft library and refer with an easy alias
import mcpi.minecraft as minecraft

# connect to the minecraft client
mc = minecraft.Minecraft.create()

# example of using variables
x = 0
y = 0
z = 0
width = 3
height = 3
length = 3

# use the minecraft variable to interact with the player and set the position of the player
mc.player.setTilePos(x, y + 2 * height, z)

# assign the mellon to the blockType variable
blockType = 103

# set a specific type of block at a single location
#mc.setBlock(x, y, z, blockType)

# set a range of tiles
mc.setBlocks(x, y, z, x + width - 1, y + height - 1, z + length - 1, blockType)

# post to the minecraft chat window
msg = "melons boom!!!!!!!!!!!!!!!"
mc.postToChat(msg)

Minecraft in Unity 3D – One-Week Programming Challenge

Shane Beck creates Minecraft in Unity from scratch in a week while screen recording the whole thing.

[Too bad the author doesn’t think the source is good enough to post.]

Andrei Jifcovici wrote:

[BUILD MINECRAFT IN UNITY PART 1],

[BUILD MINECRAFT IN UNITY PART 2: VOXEL CREATION (A FAST AND INEFFICIENT APPROACH)],

[BUILD MINECRAFT IN UNITY PART 3. CLICKING FUNCTIONALITY (A FAST AND INEFFICIENT APPROACH)], and

[BUILD MINECRAFT IN UNITY PART 4: SIMPLE WORLD GENERATION (A FAST AND INEFFICIENT APPROACH)]

as a guide for building Minecraft in Unity.