Updated at 17 days ago

by mcpyproject

87

star

on GitHub

A open source Minecraft server written 100% in Python

Tags

What is McPy

McPy is a Python library that allows you to interact with a running Minecraft: Java Edition server using the Minecraft scripting interface. It makes it possible to control the game environment, create structures, interact with entities, and more, all from within Python scripts. It acts as a bridge between Python code and the Minecraft world.

How to use

To use McPy, you need to:

  1. Install McPy: This can be done using pip: pip install mcpy.

  2. Enable the Minecraft Scripting Interface: Ensure that the Minecraft: Java Edition server has the scripting interface enabled (probably via a plugin or mod, though the README doesn't go into detail).

  3. Import McPy in your Python script: import mcpy

  4. Connect to the server: The code example provides mc = mcpy.McPy() to create an McPy instance and connect to the local Minecraft server. You might need to specify the address and port if the server is not on the default localhost and port.

  5. Use McPy commands to interact with the world: The provided example mc.postToChat("Hello, Minecraft!") demonstrates how to send a message to the in-game chat. Other commands would control blocks, entities, etc. (the README gives only a basic example).

Key features

  • Python interface for Minecraft: Provides a simple and intuitive Python API to interact with a Minecraft server.
  • Remote Control: Allows you to control Minecraft remotely from your Python scripts.
  • Chat Integration: Send messages to the Minecraft chat from your scripts.
  • Basic examples: Provides example code to get you started quickly.

Use cases

  • Automated building: Create structures and landscapes automatically using Python scripts.
  • Educational purposes: Teach programming concepts using Minecraft as an engaging environment.
  • Game modification and scripting: Extend the functionality of Minecraft with custom scripts.
  • Server administration: Automate server tasks and manage the game world.
  • Experimentation: Rapidly test ideas and game mechanics.

FAQ

  • Q: How do I install McPy?
    • A: You can install it using pip: pip install mcpy.
  • Q: Does this work with Minecraft Bedrock Edition?
    • A: The README doesn't explicitly say, but given the mention of the "Minecraft Scripting Interface", and Java Edition, it seems likely this is designed for the Java Edition.
  • Q: What version of Minecraft is supported?
    • A: The README doesn't mention which versions are supported.
  • Q: How do I enable the Minecraft Scripting Interface?
    • A: The README does not go into detail about this. It likely involves using a server plugin or mod. Check the server's documentation for details on enabling the scripting interface.
  • Q: Can I control entities (mobs, players) with McPy?
    • A: The README only provides basic examples, but the implication is that you can control entities through the scripting interface. More complex interactions are possible but not explicitly shown in the basic README.

View More