Skip to main content

Minecraft Pi API

Project description

MinecraftPython

Sample Python scripts and notes for using the Python mcpi library for manipulating and working with Minecraft.
I use these scripts and the library to explore Python3.

Getting Started

You'll need a Minecraft setup that supports interaction via API.
This is most simply achieved with the Minecraft for Raspberry Pi, but can also work with full blown Minecraft Java Servers with the Raspberry Juice Server.

Details of setting up the server side are out of scope for these instructions, it is assumed you already have the server running and a game client connected.

  1. Clone down this repository.
git clone https://github.com/rdhuht/MinecraftPython.git
cd MinecraftPython
  1. Setup a Python virtual environment. Python3.x was used with these examples and is recommended. Install
python3.7 -m venv venv
  1. Install MinecraftPython
pip install MinecraftPython
  1. Verify all is working by running the following in an interpreter.
# use somebody else's code
from mcpi.minecraft import Minecraft

name = "Yourname"
# connect to minecraft
address = "MinecraftServerAddress"
mc = Minecraft.create(address)

# get the x,y,z (position)
entity_id = mc.getPlayerEntityId(name)
position = mc.entity.getPos()

# print position to screen
print("x: {}, y: {}, z: {}".format(position.x, position.y, position.z))

Resources and References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpi-1.0.0.tar.gz (96.2 kB view hashes)

Uploaded Source

Built Distribution

mpi-1.0.0-py3-none-any.whl (106.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page