Skip to main content

Library for communicating with and controlling Minecraft servers via MCPQ plugin

Project description

Minecraft Protobuf Queries (MCPQ) Python Client Library

This library is designed to control a Minecraft Java Server, such as Spigot or Paper running the mcpq plugin, with Python.

This library is heavily inspired by MCPI (and its corresponding plugin RaspberryJuice) and attempts a more modern approach for communication between server and client that also works for more modern versions of Minecraft.

This library uses Protocol Buffers and the gRPC library and protocols to communicate with the plugin on the server.

Due to the use of the new type annotations Python 3.10+ is required!

Usage

After getting a server and compatible plugin setup and running, the only thing left to do is to install the python library:

pip3 install mcpq

Get coding!

from mcpq import Minecraft, Vec3

mc = Minecraft()  # connect to server on localhost

mc.postToChat("Hello Minecraft!")
pos = Vec3(0, 0, 0)  # origin of world, coordinates x, y and z = 0
block = mc.getBlock(pos)  # get block at origin
mc.setBlock("obsidian", pos)  # replace block with obsidian
mc.postToChat("Replaced", block, "with obsidian at", pos)

A good place to start is the turtle module:

from mcpq import Minecraft, Vec3
from mcpq.tools import Turtle

mc = Minecraft()  # connect to server on localhost
t = Turtle(mc)  # spawn turtle at player position
t.speed(10)

for i in range(4):
    t.fd(10).right(90)

Documentation

To learn everything about the library checkout the docs where the most recent version of the docs are available.

Only the most recent version of the docs is published. If you want to checkout older versions of the documentation, git checkout the branch or tag you want to see and use make show_docs to locally host the current docs at localhost:8000.

Versions

First off, to see which version of the plugin is compatible with which Minecraft version, checkout this Minecraft version table.

The three tuple major.minor.patch of the version refers to the following:

In other words, the first two numbers (major.minor) refer to the plugin version the library was written against.

E.g. the Python library version 1.0.X would require plugin version 1.0 or newer

This Python library should work for any newer versions of the plugin if everything works out and no breaking changes are introduced, at least across minor versions (see table). On the other hand, the library will most likely not work for older versions of the plugin, especially not across major versions.

TLDR; make sure the first 2 numbers (major.minor) of the library version are the same as the plugin's and choose the last number as high as possible.

Build Instructions

The library is currently published on PyPI. The package can be downloaded from there with pip3 install mcpq.

You can also install this package directly by using pip install git+https://github.com/mcpq/mcpq-python.git@<tag/branch> to install it directly from Github (git is required for this). If you cloned the repository already then pip install . can be used.

Building the library locally can be done by using python -m build, which will build the wheel and dist packages in dist/*. Afterwards the tar file can be installed with pip: pip install mcpq-0.0.0.tar.gz.

If you want to play around with the library itself you can also clone the repository as git submodule.

If you want to rebuild the protobuf files, for example, because you switched to a new major version of the protocol, first clone the proto submodule with git submodule update --init --recursive, then cd into the directory and git checkout <tag> the version you want to use. Afterwards you can use make proto to re-build the stubs.

License

LGPLv3

Note: The intent behind the chosen license, is to allow the licensed software to be used (as is) in any type of project, even commercial or closed-source ones. However, changes or modifications to the licensed software itself must be shared via the same license openly. Checkout this blog for an in-depth explanation.

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

mcpq-1.0.0.tar.gz (155.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpq-1.0.0-py3-none-any.whl (66.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcpq-1.0.0.tar.gz
  • Upload date:
  • Size: 155.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for mcpq-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fdbfd5324df076e3139963d921596921ad6d6b47b0b1efb42d7d40658fd617bc
MD5 b7a60eb920bdc0bec80bd2e8cb075251
BLAKE2b-256 dfa8c5ba94c944a5b2e7e4b9570a43b5e7e8b27c417dafb3f04347a1f7c5f05f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcpq-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 66.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for mcpq-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04875f149ba7e29da77a429456a479de552a0faef6588e284e2c68d41ef18ce7
MD5 96020b86959b5f9012c88996fbeb389e
BLAKE2b-256 ae8902b7d5757f04a4166503ef684303e7513ba54062aa5f0ced29b3ddeaefe0

See more details on using hashes here.

Supported by

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