Sueta
PY

Python plugin for mcpi

0.0.3

python mcpi RaspberryJuice

·Plugin

[This plugin still in development]
This is a plugin to run "mcpi" python file from Minecraft command input in game.

Pre-Requirements:
1. need RaspberryJuice plugin to be installed in the spigot plugin
2, the server need have python installed
3. the python API MCPI or similar python package needs to be installed

py -m pip install mcpi

or

py -m pip install mcpi-e

installation:
1. copy your python code in a folder of the Minecraft server.
2. in this plugin config.yml set the command template to run python file

py:
    python_command_template: 'py C:\Python\test\{name}.py'

usage:
/py [filename]
/py reload

sample:
/py test 10, 50

and your test.py code will look like below:

from mcpi_e.minecraft import Minecraft
from mcpi_e import block
import sys

serverAddress = "127.0.0.1"
playerName = "any"
pythonApiPort = 4711

blockId=block.SANDSTONE.id
size=5

if len(sys.argv)-1>0:
    playerName=sys.argv[1]
if len(sys.argv)-1>1:
    try:
        size=int(sys.argv[2])
    except:
        print("1nd argument is not a number, will use default size=5")
if len(sys.argv)-1>2:
    try:
        blockId=int(sys.argv[3])
    except:
        print("2nd argument is not a number, will use default blockId= Sand")
  
mc = Minecraft.create(serverAddress,pythonApiPort,playerName)

pos = mc.player.getPos()
x = pos.x
y = pos.y
z = pos.z

Similar projects

Plugin →