Skip to main content

A simple (educational) python library to interact with a minecraft server, offered in english and german. .

Project description

st_minecraft

(Eine deutsche Version dieser README ist in der Datei README_DE.md verfügbar. Beachten Sie, dass die englische Version die Hauptversion ist. Die deutsche Version könnte veraltet sein.)

Library for interacting with a Minecraft server through Python programs. This is the frontend part, which requires the use of our Server Plugin on the server side.

The library is designed to teach children the Python programming language playfully through interactions with Minecraft. It is not intended for production use!

We provide an english and a german version of the library.

Quick Example

import st_minecraft.en as mc
from st_minecraft.en.material import MaterialCollection

mc.connect("localhost")

while True:
  player = mc.get_player_by_name("YourPlayerName")
  mc.set_block(player.x, player.y - 1, player.z, MaterialCollection.Diamond_Block)
import st_minecraft.de as mc

mc.verbinden("localhost")

while True:
  spieler = mc.hole_spieler_durch_name("DeinSpielerName")
  mc.setze_block(spieler.x, spieler.y - 1, spieler.z, mc.MaterialSammlung.Stein)

If you're completely new to Python and programming: don't worry. Just follow the steps below and copy the example. You should see first results in a few minutes.

Available Interactions

  • Interact with players
    • fetch information about player (position, stats, inventory)
    • modify player position (incl. dimension and rotation)
    • modify player stats (xp, health, hunger)
    • give items
  • Interact with Blocks
    • Set Blocks
    • Fetch Blocks
  • Send and receive chat messages and execute commands
  • Spawn and edit entities (mobs, items, etc.)
  • Create and edit boss bars
  • Display titles

How to install

What You Need

  • A Minecraft Java Edition server with the appropriate server plugin running. More information can be found in the documentation of the Server Plugin. If the server has been set up for you, you need the IP and port.
  • Python 3.10 or newer on your computer. If not yet installed: download and install from https://www.python.org/downloads/.
    • Make sure to add Python to "PATH" during installation.
  • We also recommend using PyCharm, the free version without subscription is completely sufficient!

Installation with pip

(Optional) Using a virtual eenvironment

We recommend to us a venv: Windows:

py -m venv venv
venv\Scripts\Activate.ps1

Linux/MacOS:

python3 -m venv venv
venv/bin/activate

Installing the library

[!CAUTION] We will publish this package via pypi in the near future. For now you need to do a local install.

Download this repository.

Open your terminal (macOS/Linux) or command prompt/PowerShell (Windows) navigate to the folder you downloaded it to.

Install it using:

Windows

py -m pip install .

Linux / MacOS

python3 -m pip install .

Quickstart (copy & paste)

Examples of how to use the library can be found in demo/.

How the Library is Structured

The function names are available in german and english and kept beginner-friendly:

English examples

  • Blocks: set_block(...), get_block(...)
  • Players: get_player(...), set_player_position(...), set_player_health(...), set_player_hunger(...), set_player_xp_level(...), set_player_velocity(...)
  • Chat & Commands: send_to_chat(...), send_command(...)
  • Entities: spawn_entity(...), set_entity_name(...), set_entity_position(...), set_entity_ai(...)
  • Inventory: give_item(...), get_inventory(...)

Block and entity types come from the English enums MaterialCollection and EntityCollection (e.g., MaterialCollection.Melon, EntityCollection.Sheep).

German examples

  • Blocks: setze_block(...), hole_block(...)
  • Players: hole_spieler(...), spieler_position_setzen(...), spieler_leben_setzen(...), spieler_hunger_setzen(...), spieler_xp_level_setzen(...), spieler_geschwindigkeit_setzen(...)
  • Chat & Commands: sende_an_chat(...), sende_befehl(...)
  • Entities: erzeuge_entity(...), entity_name_setzen(...), entity_position_setzen(...), entity_ai_setzen(...)
  • Inventory: gebe_item(...), hole_inventar(...)

Block and entity types come from the German enums MaterialSammlung and EntitySammlung (e.g., MaterialSammlung.Melone, EntitySammlung.Schaf).

Troubleshooting

  • RuntimeError: "No connection to server. Please connect first."
    • First call connect(HOST). Check the servers IP and whether the server is running.
  • Timeout/No response from server
    • The server may not be reachable or the backend is not running. Also check IP and port.
  • I don't know my coordinates (x, y, z)
    • Stand at the desired location in the game and press F3 to see your position. Alternatively, start with small test coordinates near the spawn.

AI Disclaimer

  • Parts of the README and code have been translated using AI.
  • All content has been reviewed by humans before publication.
  • The logic itself was written by hand.

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

st_minecraft-1.1.1.tar.gz (66.1 kB view details)

Uploaded Source

Built Distribution

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

st_minecraft-1.1.1-py3-none-any.whl (65.5 kB view details)

Uploaded Python 3

File details

Details for the file st_minecraft-1.1.1.tar.gz.

File metadata

  • Download URL: st_minecraft-1.1.1.tar.gz
  • Upload date:
  • Size: 66.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for st_minecraft-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a4c2e7eec19547209bb319449b79ba842a071b66948f6494b00c00e6a24fb052
MD5 1af8e1fee8cc2c1217153f4131b1886c
BLAKE2b-256 6262030e9211ac9343172278c52ba7792530ea67be0726feecca63c3e05b50b7

See more details on using hashes here.

File details

Details for the file st_minecraft-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: st_minecraft-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 65.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for st_minecraft-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f591c75f196cef61c5bdf78179e54d38840075e9c7e0f4c91a8e920a534beb27
MD5 28c9f8494dfb3cde67ac4fbdb7f0dd6e
BLAKE2b-256 c93d635f6b06f2f3c339009abdcc263fd4efec8d66bfc4eb52f86bfc46b5bb43

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