First of all, sorry if I made the thread in the wrong subforum. I've no idea where to post this. I wouldn't consider this as a mod, which is why I didn't post this in Mod development.
To the problem. I've written a filter for MC Edit which will let you select 2 blocks and will randomly (you pick the chance) change block 1 with block 2 in the selected area. And the filter works nicely in all situation but one. When I need to change blocks with the same ID but different blockData, like Stone Bricks and Cracked Stone Bricks. Or wool with different colors. And I made the filter just because of that reason. I need to randomly swap stone bricks with cracked and mossy stone bricks in a big structure.
How do I fix that?
inputs = (
("Pick block A:", "blocktype"), #Block that will be replaced
("Pick block B:", "blocktype"), #Block that will replace it
("Chance", (15, 1, 100)),
def perform(level, box, options):
chance = options["Chance"]
blockTypeA = options["Pick block A:"].ID
blockTypeB = options["Pick block B:"].ID
changeChance = float(chance) / 100.0
for x in xrange(box.minx, box.maxx): #nasty loop to go trough every block in the selection box
for z in xrange(box.minz, box.maxz): #not sure if I could use the other 2 methods since
for y in xrange(box.miny, box.maxy): #I don't see them checking every block separately.
if level.blockAt (x, y, z) == blockTypeA:
if random.random() < changeChance:
level.setBlockAt(x, y, z, blockTypeB)
I know I have to use blockData, but I don't know how.