Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # You may modify and distribute this filter however you wish,
- # but please give credit to WolfieMario.
- from pymclevel.java import MCJavaLevel
- displayName = "Batch Replace"
- inputs = (
- ("Batch block replacement filter by WolfieMario\n", "label"),
- ("Usage: each conversion is a sequence of \"id:metadata\" values, separated by spaces. Conversions are separated by commas." +
- " The final \"id:metadata\" value in a conversion represents what block to convert all preceding ones to." +
- " For example, \"59:7 141:7 142:7 0, 2 110\" deletes all fully-grown wheat, potatoes, and carrots, and turns grass" +
- " into mycelium. Note that the \":metadata\" is optional.", "label"),
- ("", ("string", "lines=5", "width=370", "value=")),
- )
- def perform(level, box, options):
- # Generate conversions
- conversions = {}
- lines = options[""].split(",")
- for l in lines:
- tokens = l.split()
- result = tokens.pop()
- for t in tokens:
- conversions[t] = result
- for x in xrange(box.minx, box.maxx):
- for y in xrange(box.miny, box.maxy):
- for z in xrange(box.minz, box.maxz):
- block = level.blockAt(x, y, z)
- data = level.blockDataAt(x, y, z)
- key = str(block) + ":" + str(data)
- result = None
- if key in conversions:
- result = conversions[key]
- elif str(block) in conversions:
- result = conversions[str(block)]
- if result:
- newData = result.split(":")
- level.setBlockAt(x, y, z, newData[0])
- if len(newData) > 1:
- level.setBlockDataAt(x, y, z, newData[1])
- level.markDirtyBox(box)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement