Here are some steps to get the TNT to work in Minecraft Pi edition.
- Copy the following code block into a file called “tnt.py”. Save the file anywhere you want
- Start Minecraft pi edition and enter an environment instance.
- Start lxTerm or whatever terminal program you like to use
- cd to the directory where you saved the tnt.py file.
- execute ‘chmod 777 tnt.py’ to change the file runnable permissions.
- execute ‘python ./tnt.py’.
- switch back to minecraft
- place a block of TNT
- right-click on the block
- your console should report something like “block data is now 1”
- left click the block with your pick 1 time.
- big badaboom.
import mcpi.minecraft
import time
mc = mcpi.minecraft.Minecraft.create();
while True:
hits = mc.events.pollBlockHits()
for hit in hits:
block = mc.getBlockWithData(hit.pos.x, hit.pos.y, hit.pos.z);
block.data = (block.data + 1) & 0xf;
mc.setBlock(hit.pos.x, hit.pos.y, hit.pos.z, block.id, block.data)
mc.postToChat("Block data is now " + str(block.data))
time.sleep(0.1)