stoneskin

learning coding with Scratch , Python and Java

Session 1: Get Started With Python and Minecraft

Session 1.1 Setup your Python-minecraft programming Environment

1. What python could do with Minecraft game

2. Setup Minecraft Client and Server

2.1 Install Minecraft Java edition Client

Go to minecraft website download the Java Edition

2.2 Setup Minecraft Server

3. Install Python and mcpi-e Modules

4. Run your first python code in Minecraft world

Create a Python project folder, Download and save the sample1.py file to your python project folder

sample1.py

from mcpi_e.minecraft import Minecraft

serverAddress="127.0.0.1" # change to your minecraft server
pythonApiPort=4711 #default port for RaspberryJuice plugin is 4711, it could be changed in plugins\RaspberryJuice\config.yml
playerName="stoneskin" # change to your username

mc = Minecraft.create(serverAddress,pythonApiPort,playerName)
pos = mc.player.getPos()

print("pos: x:{},y:{},z:{}".format(pos.x,pos.y,pos.z))

Use your favorite python editor to open the sample1.py file. When you install python, it come with a python editor call IDLE.