(adsbygoogle = window.adsbygoogle || []).push({});
Hello NGU in this Tut i'm going to show you how to Code using Python for Minecraft on Raspberry PI
Let's start from the Basics:
Part 1.) How to post a message onto your screen
from mcpi import minecraft
mc = minecraft.Minecraft.create()
mc.postToChat("Hello world")
------------------------------------------------------------------------------------------------------------------------------
If you're entering commands directly into the Python window, just hit Enter after each line. If it's a file, save with Ctrl + S and run with F5. When your code runs, you should see your message on screen in the game.
------------------------------------------------------------------------------------------------------------------------------
Images for Part 1.)
You must login or register to view this content.You must login or register to view this content.
------------------------------------------------------------------------------------------------------------------------------
Part 2.)Find your location.
pos = mc.player.getPos()
x, y, z = mc.player.getPos()
Part 3.)How to Teleport
x, y, z = mc.player.getPos()
mc.player.setPos(x, y+100, z)
Where it says "+100" you can edit it too Example: "-1337 or +420".
And it should send you too where you set it too.
Part 4.)Set Block
x, y, z = mc.player.getPos()
mc.setBlock(x+1, y, z, 1)
Where it says "1" = Stone, other blocks you can try.
Air: 0
Grass: 2
Dirt: 3
---------
Now with the block in-sight Try changing it to something else:
mc.setBlock(x+1, y, z, 2)
Image for Part 4.)
You must login or register to view this content.You must login or register to view this content.
------------------------------------------------------------------------------------------------------------------------------
Part 5.)TNT
Another interesting block is TNT! To place a normal TNT block use:
tnt = 46
mc.setBlock(x, y, z, tnt)
Part 6.)However, this TNT block is fairly boring. Try applying data as 1:
tnt = 46
mc.setBlock(x, y, z, tnt, 1)
Now try making a big cube of TNT blocks!
tnt = 46
mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1)
You must login or register to view this content.
Now there should be a big Block of TNT as shown above just simply left click on it too watch it Explode
You must login or register to view this content.
------------------------------------------------------------------------------------------------------------------------------
This is the end of SwarMzY's coding on Minecraft, Hope you enjoyed! i hope to do more tutorials in the near future.
Regards, SwarMzY