“Magic” Box…

Astrotutor has posted a script which he describes as “magic”… Here’s his words:

 

I’ve been trying to get creative with Python. Not as clever as a clock or rainbow but how about a magic trick!

This would work better if I could get the command mc.camera.getPos() to work but it’s still a bit of fun.

[…]
I still want to do a bit more to it yet, such as giving an option to see how it’s done.

For it to work stand Steve on a flat area of ground (not sand, ice or water). Hope you like it.

What it does is build a house around you — and then remove it.  I’d recommend running the snowbound_flatmap.py first to level things out then run this.

It’s hard to capture this in pictures – so you’ll have to try it out.  This is added to the github here and source is below.

 

# mcpipy.com retrieved from URL below, written by astrotutor
# http://www.minecraftforum.net/topic/1698103-camerasetpos-not-working-magic-trick/

import mcpi.minecraft as minecraft
import mcpi.block as block
import time as time

mc = minecraft.Minecraft.create()

# Find player position
playerPos = mc.player.getPos()

#Find block type below player
Block = mc.getBlock(playerPos.x, playerPos.y - 1, playerPos.z) 

# Set camera to above player position
mc.camera.setFollow()

# Build 1st wall across in front to right

length = 0
height = 0

while length < 5:

    mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 4)

    while height < 3:
        mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 4)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0

# Build second wall on right towards

length = 0
height = 0

while length < 4:
    mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 4)

    while height < 3:
        mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 4)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0

# Build third wall on left towards

length = 0
height = 0

while length < 4:
    mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2, 4)

    while height < 3:
        mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2 , 4)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0

# Build last wall behind to right

length = 0
height = 0

while length < 3:
    mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 4)

    while height < 3:
        mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 4)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0

# Build the roof

length = 1
width = 0

while length < 4:

    while width < 3:
        mc.setBlock(playerPos.x + 2 - length, playerPos.y + 2, playerPos.z - 1 + width, 5)
        time.sleep(0.2)
        width += 1

    length += 1
    width = 0

# Create void below house

length = 1
width = 0

while length < 4:

    while width < 3:
        mc.setBlock(playerPos.x + 2 - length, playerPos.y - 2, playerPos.z - 1 + width, 0)
        time.sleep(0.2)
        width += 1

    length += 1
    width = 0

length = 1
width = 0

while length < 4:

    while width < 3:
        mc.setBlock(playerPos.x + 2 - length, playerPos.y - 3, playerPos.z - 1 + width, 0)
        time.sleep(0.2)
        width += 1

    length += 1
    width = 0

# Remove the floor

length = 1
width = 0

while length < 4:

    while width < 3:
        mc.setBlock(playerPos.x + 2 - length, playerPos.y - 1, playerPos.z - 1 + width, 0)
        time.sleep(0.2)
        width += 1

    length += 1
    width = 0

# Build the floor



length = 1
width = 0

while length < 4:

    while width < 3:
        mc.setBlock(playerPos.x + 2 - length, playerPos.y - 1, playerPos.z - 1 + width, Block)
        time.sleep(0.2)
        width += 1

    length += 1
    width = 0

# Remove the roof

length = 1
width = 0

while length < 4:

    while width < 3:
        mc.setBlock(playerPos.x + 2 - length, playerPos.y + 2, playerPos.z - 1 + width, 0)
        time.sleep(0.2)
        width += 1

    length += 1
    width = 0

# Remove 1st wall across in front to right

length = 0
height = 0

while length < 5:

    mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 0)

    while height < 3:
        mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 0)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0

# Remove second wall on right towards

length = 0
height = 0

while length < 4:
    mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 0)

    while height < 3:
        mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 0)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0

# Remove third wall on left towards

length = 0
height = 0

while length < 4:
    mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2, 0)

    while height < 3:
        mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2 , 0)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0

# Remove last wall behind to right

length = 0
height = 0

while length < 3:
    mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 0)

    while height < 3:
        mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 0)
        time.sleep(0.2)
        height += 1

    length += 1
    height = 0 

 

 
Original Forum Post

Advertisements

One thought on ““Magic” Box…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s