CraftingTable.py
No reviews yet
CraftingTable.py is a Fabric mod that enables Python scripts to control and interact with Minecraft events and commands in an intuitive, event-driven way.
Provides a framework or library for other mods to use.
Fabric is a mod loader for versions 1.14+ of Minecraft, particularly popular for client side and optimization mods.
Community voices
Reviews
Click once to include, again to exclude, again to clear
No reviews yet. Be the first to review this project!
Get it on
Available Platforms
Compatibility
Supported Environments
About
Project Details
For authors
Embed Badge
If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.
Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.
Identifiers
Platform IDs
About
Description
CraftingTable.py
CraftingTable.py is a Fabric mod that allows you to control Minecraft using Python scripts in an event-driven way. Inspired by discord.py, it lets you handle server events asynchronously and execute commands directly from Python.
⚠️ Note: This is an early development version (v0.0.2). Many features will be added in the future.
🔄 Upgrading from v0.0.1?
Significant changes have been made to the event system and library files. Please read the Migration Guide (Scroll down this page or visit GitHub) before updating to ensure your scripts continue to work.
Requirements
To use CraftingTable.py, the following software is required:
- Fabric Loader: 0.17.2 or higher
- Fabric API: 0.97.3 or higher
- Java: 17 or higher
- Python: 3.11 recommended (other versions may also work) Make sure these dependencies are installed before running the mod.
Event System
Events are now registered using the @mc.event decorator. This replaces the old function-naming convention for better flexibility and control.
Basic Syntax
@mc.event("event_name", priority=1)
async def your_function_name(parameters):
...
event_name: The name of the Minecraft event to listen for.priority(Optional): An integer defining the execution order.
Available Events
| Event Name | Description | Parameters |
|---|---|---|
"player_join" |
Triggered when a player joins | player — player name (str) |
"player_leave" |
Triggered when a player leaves | player — player name (str) |
"chat" |
Triggered when a chat message is sent | message — message content (str) type — message details (str) player — player name (str) |
"item_use" |
Triggered when a player uses an item | world — world type (str) item_id — item ID (str) count — item count (int) player — player name (str) hand — main hand or off-hand (str) nbt — NBT data (str, optional, set to None if the item has no NBT) |
Provided Functions and Variables
| Function / Variable | Description |
|---|---|
mc.cmd(command: str) |
Executes a server command in real-time. Example: mc.cmd("give player minecraft:apple 5") |
mc.log(message: str) |
Prints a message to the server log. Example: mc.log("Player joined") |
Administration Commands
- /ctpy reload: Reloads your
mod.pyand applies changes immediately. - Note: If you add a decorator for an event that was not present when the game started, a full game restart is required to register the listener on the Fabric side.
Getting Started
After first launching the mod, the following files are generated in your Minecraft game directory:
config/craftingtablepy/
├─ mod.py ← Write your Python event scripts here
├─ craftingtable.py ← Python module for import, contains mc.cmd and mc.log
Edit mod.py to define your event handlers. For example:
import craftingtable as mc
@mc.event("player_join")
async def welcome_player(player):
mc.cmd(f"title {player} actionbar Welcome, {player}!")
mc.cmd(f"give {player} minecraft:apple 5")
@mc.event("chat", priority=1)
async def greeting(message, type, player):
if message.lower() == "hello":
mc.cmd(f"say Hello, {player}!")
While in-game, run /ctpy reload to apply your changes!
Usage
- Install the Fabric mod as usual.
- Launch Minecraft to generate
mod.pyandcraftingtable.py. - Edit
mod.pyto define your Python scripts. - Start the server and your scripts will automatically handle events and execute commands.
Technical Note on Reloading
To ensure all events can be reloaded dynamically, it is recommended to include all decorators you plan to use in your mod.py at startup. Even if the function body is empty (pass), having the decorator present allows the Fabric-side listener to initialize, enabling you to add logic later via /ctpy reload.
Migration Guide (v0.0.1 → v0.0.2)
To upgrade to v0.0.2, please follow these steps carefully. Simply replacing the jar file is not enough.
1. Update the Mod File
Replace the old .jar file in your mods folder with the new CraftingTable.py v0.0.2 version.
2. Force Regenerate the Library
The internal Python library has been updated. You must delete the following file to allow the mod to generate the latest version:
- Path:
/config/craftingtablepy/craftingtable.py - Note: If you don't delete this, your scripts will fail to recognize the new decorator system.
3. Update Your Scripts (mod.py)
The event system has changed from "naming convention" to "decorator-based". Old functions without decorators will no longer be executed.
Example of changes required:
| Version | Example Code in mod.py |
|---|---|
| Old (v0.0.1) | async def on_chat(message, type, player): |
| New (v0.0.2) | @mc.event("chat")async def on_chat(message, type, player): |
Event System
Events are now registered using the @mc.event decorator. This provides better control over execution and allows for custom function names.
Basic Syntax
@mc.event("event_name", priority=1)
async def your_custom_function_name(parameters):
...
Future Plans
- Add support for other versions.
- Add more advanced event types and APIs.
- Improve stability and performance for large-scale servers.
License
MIT
Screenshots
Gallery
Versions
Files
Relations
Project Relations
More like this
Similar Mods
Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.
On ModDex
Community snapshot
By the numbers
Statistics
Want to reach Minecraft players?
We're looking for a server hosting partner to feature here and other parts of the site. Interested? Send us a message!
Get in touchGet it on
Available Platforms
On ModDex
Community snapshot
By the numbers