Last active
November 16, 2024 23:13
-
-
Save SimonCoulombe/73104d62545bf82b3d5d8dbe02ae2a0b to your computer and use it in GitHub Desktop.
minecraft python adventures 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some notes on installing minecraft to follow along the book. | |
# raspberryJuice is not updated anymore (stops at minecraft 1.12 or something) | |
# I got JuicyRaspberryPi instead. | |
# installation instructions here: | |
# https://github.com/wensheng/JuicyRaspberryPie/blob/master/doc/using-api-spigot.md | |
# steps that worked for me: | |
# Installed Java SDK 17 (exactly 17, not more, not less). Got it from adoptium: | |
#https://adoptium.net/fr/ | |
# create a directory called "minecraft_py" somewhere | |
# inside that directory, create directories "build" and "server". | |
# get the spigot buildtools latest version here: | |
# https://hub.spigotmc.org/jenkins/job/BuildTools/ | |
# save BuildTools.jar in minecraft_py/build | |
# start a powershell terminal at "minecraft_py/build" by : | |
# -navigating to that directory in windows explorer, | |
# - then "shift-right click" somewhere empty , | |
# - choose "start new powershell terminal here" | |
#run this in the powershell terminal, replacing "simon" in JAVA_HOME with your username | |
$env:JAVA_HOME = "C:\Users\simon\AppData\Local\Programs\Eclipse Adoptium\jdk-17.0.13.11-hotspot" | |
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH" | |
java -jar BuildTools.jar --rev 1.18.1 | |
# this will generate a bunch of files, including something called spigot-1.18.1.jar | |
# copy that file to minecraft_py/server and rename it spigot.jar | |
# also create file eula.txt in minecraft_py/server and add the following content in it: | |
eula=true | |
# also create file run.bat ine minecraft_py/server and add the following content in it: | |
@echo off | |
set "JAVA_HOME=C:\Users\simon\AppData\Local\Programs\Eclipse Adoptium\jdk-17.0.13.11-hotspot" | |
set "PATH=%JAVA_HOME%\bin;%PATH%" | |
java -Xms8G -Xmx8G -jar spigot.jar | |
pause | |
# download juicyraspberrypi for for spigot 1.18.1 from releases here (juicyraspberrypie-1.18.1.jar) | |
#https://github.com/wensheng/JuicyRaspberryPie/releases/tag/v0.3 | |
# then copy juicyraspberrypie-1.18.1.jar to minecraft_py/server/plugins | |
# start the spigot server by double-clikcing run.bat | |
# start the minecraft launcher | |
# create a new installation | |
# select release 1.18.1 | |
# start a new minecratft game using the installation you just made | |
# pick multiplayer, "localhost" | |
# you'Re in!! | |
# in server terminal type | |
op YOURUSERNAME | |
# in minecraft chat type | |
/gamemode creative | |
# in game press F3 to show location, facing east | |
from mcpi.minecraft import minecraft | |
mc = minecraft.create() | |
pos = mc.player.getTilePos() | |
x,y,z = pos.x, pos.y, pos.z | |
mc.spawnEntity( x+2, y, z , "donkey") | |
panda = mc.spawnEntity( x+2, y, z , "panda") | |
panda.setPos(x+2,y,z+10) | |
# rainbow.py | |
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
from math import * | |
colors = [14, 1, 4, 5, 3, 11, 10] | |
mc = minecraft.Minecraft.create() | |
height = 60 | |
mc.setBlocks(-64, 0, 0, 64, height + len(colors), 0, 0) | |
for x in range(0, 128): | |
for colourindex in range(0, len(colors)): | |
y = sin((x / 128.0) * pi) * height + colourindex | |
mc.setBlock(x - 64, y, 0, block.WOOL.id, colors[len(colors) - 1 - colourindex]) | |
# to disable pausing on loss of focus: | |
hold f3, press p | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment