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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file mpi-1.0.0.tar.gz.

File metadata

  • Download URL: mpi-1.0.0.tar.gz
  • Upload date:
  • Size: 96.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.0

File hashes

Hashes for mpi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c1f87d6c213ef9102607e0321a2b07bb673359135ce2de06116591b48b90eb4a
MD5 5a2e328e42a7c7e9f251ebed1671c294
BLAKE2b-256 86d1d039c0dea5058a946521b850ece030da650802078bee5c786bf54852164c

See more details on using hashes here.

File details

Details for the file mpi-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mpi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 106.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.0

File hashes

Hashes for mpi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8d1f7dda9a01fce4ef5d1d1f08321fd3775b24a1b46a8814eaeed33d7750a08
MD5 dc97fa5abea79e0842f51c1efd1a0afc
BLAKE2b-256 f6117e43ae1ecd213f45116371768bfd4437c0bbdfb880d0c680680e4cbb76b8

See more details on using hashes here.

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