[Canary] MCPI

[Canary] MCPI.

1) Téléchargement du mod « Canary Raspberry Juice » :

[~] ➔ cd MINECRAFT/CANARY/Serveur.1710/plugins/
[~/MINECRAFT/CANARY/Serveur.1710/plugins] ➔ wget http://canarymod.net/download/file/fid/319
[~/MINECRAFT/CANARY/Serveur.1710/plugins] ➔ mv 319 canaryraspberryjuice-1.2.jar
[~/MINECRAFT/CANARY/Serveur.1710/plugins] ➔ cd ..

2) Lancement du serveur Canary en tâche de fond :

[~/MINECRAFT/CANARY/Serveur.1710] ➔ java -Xms512M -Xmx1536M -XX:MaxPermSize=128M -jar CanaryMod-1.7.10-1.1.3.jar &
[~/MINECRAFT/CANARY/Serveur.1710] ➔ cd ..

3) Lancer le client Minecraft.

4) Téléchargement de la librarie Python « Canary Raspberry Juice » :

[~/MINECRAFT/CANARY] ➔ mkdir McPi
[~/MINECRAFT/CANARY] ➔ cd McPi/
[~/MINECRAFT/CANARY/McPi] ➔ git clone https://github.com/martinohanlon/CanaryRaspberryJuice.git
[~/MINECRAFT/CANARY/McPi] ➔ cd CanaryRaspberryJuice/resources/mcpi/api/python
[~/MINECRAFT/CANARY/McPi/CanaryRaspberryJuice/resources/mcpi/api/python (master)] ➔ 

5) Création d’un script Python d’exemple :

Ouvrir :

pillar.py

Ajouter :

import mcpi.minecraft as minecraft
import mcpi.block as block
# Connect to the Minecraft server
world = minecraft.Minecraft.create()
# Get the player's current position and store the coordinates
[x,y,z] = world.player.getPos()
# Set some variables to customize your pillar
height = 3
material = block.BRICK_BLOCK
# Build the pillar. It will be "height" blocks high and located one step away from the player.
for level in range(0, height):
   world.setBlock( x+1, y+level, z+1, material )
   level = level + 1;

Exécuter :

[~/MINECRAFT/CANARY/McPi/CanaryRaspberryJuice/resources/mcpi/api/python (master)] ➔ python ./pillar.py

Un pilier apparaît.

6) Liens :

http://canarymod.net/plugins/raspberry-juice
http://www.stuffaboutcode.com/2015/01/minecraft-api-players-direction.html