So, I wanted to quickly create a bunch of disposable worlds that I can run my very rough scripts in to see where I need to tweak them.
So, the first thing I did was create a small script that removes everything from the world. (NOTE: for some reason some flowers and things are left behind. It might be an attribute thing...)
import mcpi.minecraft as minecraft
import mcpi.block as block
mc = minecraft.Minecraft.create()
blockId = block.AIR.id
blockId = block.DIRT.id
There are no indents so should just work if cut and pasted to a text file and saved. I used clearall.py
Then start Minecraft
Create a World
The whole world is made AIR with a 'ground' of DIRT is added at Y=0.
This will take a while to run so be patient.
Now you have one blank world.
But that would be slow to do that every time you need a blank world.
Well with a bit of jiggery pokery you don't have to.
The method I used is probably a bit manual but it is faster than coding for new worlds every time.
Maybe somebody brighter than me can automate it.
Step 1. Make sure you can see hidden folders when browsing on your Raspberry Pi.
The got to ~/pi (if your username is pi)
This is the directory where your saved Worlds are stored.
One per folder. For me the blank world I created was called world
Create a bunch of new directories. I used world-blank1, world-blank2 etc....
Make as many as you want.
Go into the original world directory and copy all the files.
Then paste those files into each of your world-blank directories.
Now you have replicated the blank world you created with the above script too all of these world maps.
If you go back into Minecraft they will be there. Only problem is they will all have the same name. Not ideal when you want to know which ones you have broken and which are still clean.
This is where it gets a bit more low level but still quite simple.
Installed ghex a gui based hex editor with sudo apt-get install ghex
Then for each folder open level.dat using ghex and find where it says world
Modify the text to a different name making sure to keep it the same size. Maybe B0001.
Save the updated level.dat.
Do this for each of your new directories making sure to use a different name (B0002,B0003,...) .
If you run minecraft you will get a list of Worlds all with different names. For me the order was still a bit mixed up but I can live with that.
Finally, rather than having to do this every time I created a new directory under com.mojang called backup-blank and copied all my newly made blank world into that directory.
Now I can mess about with the blank worlds. Building all kinds of strange shapes not caring about it being perfect as I can just delete that world and replace it with a new clean one by just copying the saved worlds in backup-blank back into the minecraftWorlds directory and start again.
Note: For me I have 20(ish) blank worlds created as I mess up a fair bit and this usually allows me to do one good session without having to copy across or create a new blank world.