Skip to main content

Minecraft command emulator library

Project description

mcemu

A lightweight, programmatic, and interactive Minecraft Command Emulator designed as a standalone Python library and REPL environment. It simulates a virtual Minecraft environment, allowing you to test, debug, and execute complex command sequences and .mcfunction files without needing to launch the game!

🚀 Features

  • Interactive REPL Environment: Start the engine right from your terminal and type commands in real time. Features colored syntax feedback, auto-suggestions, and deep typo detection.
  • .mcfunction & Macros Support: Load and execute function files, complete with support for scheduling, ticking, and dynamic NBT macro arguments via regex substitution (e.g., /function namespace:test {a: 42} matching $(a)).
  • Security Control: Includes a rigorous allow_functions engine configuration to restrict potentially malicious local file system access when evaluating untrusted text.
  • Robust Entity Management: Create and manage players and entities dynamically within a simulated world, complete with inventory, nbt properties, and active effects tracking.
  • Scoreboard Simulation: A fully-featured programmatic scoreboard that replicates the in-game behavior for mathematical operations and player tracking.
  • Command Dispatcher: An exact replica of the Minecraft command-tree parsing structure, enabling you to powerfully chain execute subcommands seamlessly.
  • Vast Command Library: Emulates over 60 native Minecraft commands directly out of the box, cleanly modularized for easy extendability.

📦 Installation

To install mcemu directly from PyPI (once published):

pip install mcemu

If you are developing locally, clone the repository and install it in editable mode with development dependencies:

git clone https://github.com/OguzhanUmutlu/mcemu.git
cd mcemu
pip install -e .[dev]

🎮 Usage

Once installed, mcemu exposes a powerful command-line interface. Simply open your terminal and type:

mcemu

Supported Commands

The emulator currently supports an extensive array of commands, grouped intuitively in the backend but accessible seamlessly:

Entities & Players: summon, kill, tp, teleport, damage, ride, spectate, xp, experience, clear, give, item, effect, enchant Data & Logic: data, execute, function, return, schedule, scoreboard, tag, attribute, advancement, recipe World Manipulation: setblock, fill, clone, time, weather, difficulty, gamerule, seed, worldborder, spawnpoint, setworldspawn Administration: op, deop, ban, pardon, ban-ip, pardon-ip, whitelist, kick, stop, save-all, save-on, save-off, reload, debug, jfr, perf, publish, stopwatch Chat & Visuals: say, tell, msg, w, me, teammsg, tellraw (with ANSI JSON Component parsing!), title, tm, bossbar, particle, playsound, stopsound, dialog, team, setidletimeout, forceload, datapack, list, transfer

Special REPL Commands

The interactive console also provides helpful emulator-specific utilities:

  • entities: Prints all tracked entities, inventories, and effects.
  • scores: Prints the current scoreboard dictionary.
  • toggleblocks: Enables or disables actual block data storage in memory (useful for large /fill commands).
  • getblock <x> <y> <z>: Returns the stored blockstate at a coordinate.
  • returncode: Prints the integer return value of the last evaluated command to prevent clutter.
  • reset: Completely resets the internal environment memory map.
  • exit: Shuts down the emulator.

Example Interaction

mcemu> scoreboard objectives add kills dummy

mcemu> give @p minecraft:diamond_sword{Enchantments:[{id:"minecraft:sharpness",lvl:5}]} 1

mcemu> effect give @p minecraft:speed 100 2 true

mcemu> entities
- Dev (minecraft:player) at (0.0, 0.0, 0.0) tags: set()
  inventory: {'inventory.0': {'id': 'minecraft:diamond_sword', 'count': 1, 'nbt': '{Enchantments:[{id:"minecraft:sharpness",lvl:5}]}'}}
  effects: {'minecraft:speed': {'duration': 2000, 'amplifier': 2, 'hideParticles': True}}

mcemu> toggleblocks
Block tracking enabled.

mcemu> setblock 0 0 0 minecraft:stone
mcemu> getblock 0 0 0
Block at 0 0 0: minecraft:stone

🧪 Testing

To run the built-in test suite locally, use the provided script:

./run_tests.sh

This automatically sets up a virtual environment and runs pytest across the package.

📄 License

This project is licensed under the MIT License. See the LICENSE file for more details.

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

mcemu-0.2.2.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

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

mcemu-0.2.2-py3-none-any.whl (54.9 kB view details)

Uploaded Python 3

File details

Details for the file mcemu-0.2.2.tar.gz.

File metadata

  • Download URL: mcemu-0.2.2.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mcemu-0.2.2.tar.gz
Algorithm Hash digest
SHA256 54946ce783c945169b0ce05f1f76b6ceebf302262d6e18cb1a70a1e441606fe6
MD5 4ac8fa257cf6266902f44924e50d0c4a
BLAKE2b-256 446b0611333c39172a5d5d0611284245290799ad665a6734ebad31605a522cd2

See more details on using hashes here.

File details

Details for the file mcemu-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: mcemu-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 54.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mcemu-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 334552da8882312cee1fa873b5689f7eeb057b28f103716ea5052314eb0fea8d
MD5 de7f1bc09e6d4a7d1a829fb5e195de5f
BLAKE2b-256 cd2f945318fbb00fe87249f7314ef9e0b170b739e5372fc830838c0977ca09e9

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