TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • PyGame Zero
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Ras Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • Ferminal
    • Crypto Tracker
    • David Bowie
    • Lamp Prank >
      • TEST
    • Yoda FM
    • Retro Player
    • LED Pixel Art
    • TARDIS
    • Battleships
    • LED Board
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me
  • Random Hacks

What is it?


Minecraft pocket edition comes to the Raspberry Pi but it is more than just playing a computer game.  Programming with Python on the Raspberry Pi is a powerful and fun way to modify Minecraft games. Using a few lines of code you can take control of the player and then every block in the world.  This allows you to manipulate the entire world and how Steve interacts, think of the Matrix! (trailer here).

1. Getting Set Up


To get started, firstly download the Minecraft software for your Raspberry Pi.  Load yourPi and log in with your username and password, run the GUI, type in “startx”.  

In the LX Terminal type:
sudo apt-get update
sudo apt-get upgrade

wget https://s3.amazonaws.com/assets.minecraft.net/pi/minecraft-pi-0.1.1.tar.gz (all one the same line)

Or you can try:
wget http://goo.gl/o2aene -O mcpi.tar.gz --no-check-certificate

The next stage is to decompress the file with the code below,  type: 
tar -zxvf minecraft-pi-0.1.1.tar.gz

Then to run the game move to the Minecraft folder by typing: 
cd mcpi

You can type ls to list all the files in the mcpi folder
Then type: ./minecraft-pi

(Don't forget the dot before the /)


2. Let's Play


Picture
Getting started with hacking your Minecraft world is simple.  There are many websites and cheat-sheets available which have a wealth of ideas, hacks and instructions to get you started and keep you coding for a long time.

Your First Program


In the Minecraft world the players position is located at X, Y, and Z co-ordinates. The Y is the height in the world, X is how far left or right and Z is backward or forward.  This basic code will  import the Minecraft API and then set the X, Y, and Z position to 1, 24 and 1, then the setTilePos moves the player to that position in the world. You can teleport the player anywhere by changing the X, Y, and Z numbers, even sending Steve underground! 

In the LX Terminal type:
sudo idle

Then  type the following code:

from mcpi import minecraft
mc = minecraft.Minecraft.create()

x = 1
y = 24
z = 1
mc.player.setTilePos(x,y,z)


Once you have finished typing save the Python file into the home/pi folder.  Ensure that Minecraft is loaded up and then press F5 to run your code and teleport Steve.

Advanced Teleportation


Picture
Once the teleporting code was operational I considered building a teleporter within the game, this started off as blue blocks, then I wanted to place the player inside the device.  This was achieved by working out the x, y and z position of the middle of the teleporter, (can I call it a TARDIS from now on!), then sending the player to that position to place them inside the TARDIS.  But, with blue blocks it was too dark inside and you could not see anything, so I changed the blocks of the TARDIS to glass, hey presto a 'great glass elevator'.  

The rest of the code introduced a function to allow the player to teleport around the world by selecting their desired x, y and z location.  Once selected and entered, Steve was teleported to that location arriving in the in the TARDIS / elevator thingy machine.  Yeah works nearly as well as in Half Life 2!

Powered by Create your own unique website with customizable templates.