Hello World with Raspberry Pi + Minecraft Pi Edition

Overview

--Minecraft Pi Edition running on Raspberry Pi + Raspbian environment Display Hello World using the Python library mcpi

This environment

What is Minecraft Pi Edition?

Minecraft Pi Edition is a free version of Minecraft developed for learning programming on the Raspberry Pi.

Install Minecraft Pi Edition and mcpi

It's probably installed on Raspbian from the beginning, but if you don't have it, install the minecraft-pi package with the apt or apt-get command.

$ sudo apt install minecraft-pi
Loading the package list...Done
Creating a dependency tree
Reading status information...Done
minecraft-pi is already the latest version(0.1.1-6)is.

I think that the Python mcpi package (Minecraft Pi Edition API Python Library) is also installed, but if it is not there, install it with the pip command.

$ sudo pip install mcpi
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: mcpi in /usr/lib/python2.7/dist-packages (0.1.1)
$ pip show mcpi
Name: mcpi
Version: 0.1.1
Summary: API for Minecraft Pi
Home-page: http://pi.minecraft.net/
Author: Mojang
Author-email: UNKNOWN
License: UNKNOWN
Location: /usr/lib/python2.7/dist-packages
Requires: 
Required-by: 

Show Hello World in Minecraft World

Launch Minecraft Pi Edition and

minecraft-pi-edition-1.png

Create a world and enter it.

minecraft-pi-edition-2.png

Save the following source code and

hello-minecraft.py


from mcpi import minecraft
import mcpi.block as block

mc = minecraft.Minecraft.create("localhost")
pos = mc.player.getPos()
basex = int(pos.x) + 0
basey = int(pos.y) + 6
basez = int(pos.z) + 0

data = [
  "#  # ### #   #    ##   #   #  ##  ###  #   ### ",
  "#  # #   #   #   #  #  # # # #  # #  # #   #  #",
  "#### ### #   #   #  #  # # # #  # ###  #   #  #",
  "#  # #   #   #   #  #  # # # #  # # #  #   #  #",
  "#  # ### ### ###  ##    # #   ##  #  # ### ### "
]

for y, line in enumerate(data):
  for x, c in enumerate(line):
    if c == "#":
      mc.setBlock(basex + x, basey - y, basez, block.DIAMOND_BLOCK.id)

When you run

$ python hello-minecraft.py

HELLO WORLD with diamond blocks appears.

minecraft-pi-edition-3.png

Reference material

Recommended Posts

Hello World with Raspberry Pi + Minecraft Pi Edition
Getting Started with Heroku-Viewing Hello World in Python Django with Raspberry PI 3
GPGPU with Raspberry Pi
hello world with ctypes
Hello, World with Docker
DigitalSignage with Raspberry Pi
Hello world with flask
I tried L-Chika with Raspberry Pi 4 (Python edition)
Mutter plants with Raspberry Pi
Hello World with Flask + Hamlish
Until hello world with zappa
USB boot with Raspberry Pi 4 Model B (3) LVM edition
Python starting with Hello world!
[Raspberry Pi] Stepping motor control with Raspberry Pi
Use vl53l0x with Raspberry Pi (python)
Servo motor control with Raspberry Pi
Hello, world! With virtual CAN communication
Introduction to TensorFlow --Hello World Edition
Serial communication with Raspberry Pi + PySerial
OS setup with Raspberry Pi Imager
[Note] Hello world output with python
Try L Chika with raspberry pi
VPN server construction with Raspberry Pi
Hello World! By QPython with Braincrash
Try moving 3 servos with Raspberry Pi
Using a webcam with Raspberry Pi
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
Hello world
Pet monitoring with Rekognition and Raspberry pi
Raspberry Pi Security Infrared Camera (Python Edition)
Build a Tensorflow environment with Raspberry Pi [2020]
Get BITCOIN LTP information with Raspberry PI
Operate Minecraft Pi Edition from your PC
Try fishing for smelt with Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Improved motion sensor made with Raspberry Pi
Try Object detection with Raspberry Pi 4 + Coral
Power SG-90 servo motor with raspberry pi
Working with sensors on Mathematica on Raspberry Pi
Use PIR motion sensor with raspberry Pi
Make a wash-drying timer with a Raspberry Pi
Infer Custom Vision model with Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
Create a car meter with raspberry pi
Hello World! By QPython with Brainfu * k
Inkbird IBS-TH1 value logged with Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
[I touched the Raspberry Pi (1)] I summarized the basic operations of Minecraft Pi Edition (2015.5.23 pre-release)
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
Hello World and face detection with OpenCV 4.3 + Python
Hello World with gRPC / go in Docker environment
Discord bot with python raspberry pi zero with [Notes]
Media programming with Raspberry Pi (preparation for audio)
Hello world with full features of Go language
Pymacs hello world
Block and draw images in Minecraft Pi Edition
Say hello to the world with Python with IntelliJ
Hello World with nginx + uwsgi + python on EC2
Raspberry Pi backup
Enjoy electronic work with GPIO on Raspberry Pi
MQTT RC car with Arduino and Raspberry Pi