Skip to content

Instantly share code, notes, and snippets.

@seebs
Created July 23, 2015 18:50
Show Gist options
  • Save seebs/4371b62b8bcabdc50212 to your computer and use it in GitHub Desktop.
Save seebs/4371b62b8bcabdc50212 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
import pymclevel
import sys
print "Loading world..."
level = pymclevel.loadWorld('/home/seebs/src/mcaedit/world')
print "Loaded."
def has_object(chunk, id):
x = (chunk.Blocks == id)
if x.any():
# print "Found id in %d, %d" % (cx, cz)
return True
return False
regions = dict()
sys.stdout.write("Building region list: ")
sys.stdout.flush()
found_regions = 0
found_chunks = 0
for cx, cz in list(level.allChunks):
rx = cx / 32
rz = cz / 32
found_chunks += 1
if rx not in regions:
regions[rx] = dict()
if rz not in regions[rx]:
regions[rx][rz] = list()
found_regions += 1
sys.stderr.write("+")
sys.stderr.flush()
regions[rx][rz].append({'x': cx, 'z': cz})
print "Done. %d chunks, %d regions." % (found_chunks, found_regions)
total = 0
delete = 0
useless_regions = list()
useless_chunks = list()
tried = 1
for rx in iter(regions):
for rz in iter(regions[rx]):
print "Region %d/%d [%d, %d]: %d chunks" % (tried, found_regions, rx, rz, len(regions[rx][rz]))
tried = tried + 1
sys.stdout.flush()
this_batch = list()
this_batch.append((rx, rz))
useless_chunks.append(this_batch)
found_any = False
for coords in regions[rx][rz]:
cx = coords['x']
cz = coords['z']
chunk = level.getChunk(cx, cz)
x = (chunk.Biomes == 69)
if x.any():
found_any = True
chunk.Biomes[x] = 159
print "Chunk [%d,%d] had biome 69." % (cx, cz)
chunk.chunkChanged()
level.saveInPlace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment