Home›Java›Mods›PyCraft (Python)
PyCraft (Python)
ModsJava

PyCraft (Python)

Java mod listed for Minecraft 1.21. Downloads from the MC Java Mods app on Android.

by kapiteon · on CurseForge

⬇ Download on CurseForge

The author built this one for Minecraft 1.21.11 on Fabric. On other versions it may install and then do nothing.

PyCraft (Python) — screenshot 1PyCraft (Python) — screenshot 2PyCraft (Python) — screenshot 3PyCraft (Python) — screenshot 4

PyCraft (Python) — Minecraft Java mod, screenshot 1

🐍 PyCraft

PyCraft is a lightweight utility mod that integrates a Python interpreter directly into the Minecraft client.

It is not designed to replace Java modding or create complex content mods. Instead, it serves as a flexible scripting tool to automate chat interactions, create custom keybindings, and execute expressions on the fly without restarting the game.

✨ Features

🚀 Getting Started

  1. Install PyCraft (requires Fabric API).
  2. Launch Minecraft.
  3. The mod will automatically generate a main.py file in your .minecraft/mods/ folder.
  4. Open main.py in any text editor (VS Code, Notepad++, etc.).
  5. Write your code and save. The mod will reload it instantly.


📖 Scripting API

PyCraft runs on Jython (Python 2.7). You can use standard Python syntax and libraries.

Global Functions

These functions are available to call from your script or the in-game console:

Function Description
sendMessage(text) Sends a message to the server. If text starts with /, it is executed as a command.
openChat(text) Opens the player's chat GUI with the text already typed in.


Event Hooks


Define these functions in your main.py to handle game events:

onChat(message)


Called whenever a chat message is received by the client.

onKey(state, key, modifiers)


Called whenever a keyboard key is interacted with.

📝 Example: main.py

This example demonstrates how to create a "Global Chat" hotkey and a simple auto-responder.

# -*- coding: utf-8 -*-
import re

# Event: Key Input
def onKey(state, key, modifiers):
    # Check if key is 'U' (85) and action is Press (1)
    if key == 85 and state == 1: 
        # Open chat with '!' prefix for global chat
        openChat('!')

# Event: Chat Received
def onChat(message):
    # Search for "Hello" in the incoming message
    result = re.findall(u'Hello', message)
    
    # If found, reply automatically
    if (len(result) > 0):
        sendMessage('Hi')

print('PyCraft main.py loaded!')

⚠️ Technical Notes

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

File checked by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more