Skip to content

Latest commit

 

History

History
108 lines (77 loc) · 2.69 KB

README.rst

File metadata and controls

108 lines (77 loc) · 2.69 KB

Minecraft - Stuff Library

An extension library of useful 'stuff' (aka classes) I have created for Minecraft: Pi Edition's API.

It provides functions for drawing lines, creating, moving and rotating shapes and a pretty cool turtle. Check out the documentation and examples.

shapes and lines in minecraft

Created by Martin O'Hanlon, @martinohanlon, stuffaboutco.de.

Install

Open a terminal and run the following commands:

sudo pip install minecraftstuff
sudo pip3 install minecraftstuff

Code

See the documentation for more information, but below is a summary.

MinecraftDrawing

from minecraftstuff import MinecraftDrawing
from mcpi.minecraft import Minecraft
from mcpi import block

#Connect to minecraft
mc = Minecraft.create()
# get the players position
pos = mc.player.getTilePos()

#Using the Minecraft Drawing API
mcdrawing = MinecraftDrawing(mc)

# draw a circle with a radius of 10 blocks
mcdrawing.drawCircle(pos.x, pos.y + 15, pos.z, 10, block.WOOD.id)

MinecraftShape

from minecraftstuff import MinecraftShape
from mcpi.minecraft import Minecraft
from mcpi import block
from time import sleep

#Connect to minecraft
mc = Minecraft.create()
# get the players position
pos = mc.player.getTilePos()

#Using the Minecraft Shape API
mcshape = MinecraftShape(mc, pos)

# create a stone cube
mcshape.setBlocks(-5, -5, -5, 5, 5, 5, block.STONE.id)

# move it around
for i in range(0,10):
    mcshape.moveBy(1,0,1)
    sleep(0.5)

MinecraftTurtle

from minecraftstuff import MinecraftTurtle
from mcpi.minecraft import Minecraft

#Connect to minecraft
mc = Minecraft.create()
# get the players position
pos = mc.player.getTilePos()

#Using the Minecraft Turtle
steve = MinecraftTurtle(mc, pos)

# draw a square
steve.forward(5)
steve.right(90)
steve.forward(5)
steve.right(90)
steve.forward(5)
steve.right(90)
steve.forward(5)