Skip to content

Instantly share code, notes, and snippets.

@14mRh4X0r
Created July 1, 2014 08:13
Show Gist options
  • Save 14mRh4X0r/aa5356544901bb44f490 to your computer and use it in GitHub Desktop.
Save 14mRh4X0r/aa5356544901bb44f490 to your computer and use it in GitHub Desktop.
Python script to fix Minecraft 14w26a/b snapshots. Needs https://github.com/mcedit/pymclevel to run
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
# Unbuffer stdout
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
print "Loading world...",
from pymclevel import mclevel
level = mclevel.fromFile(sys.argv[1])
print "done."
for dim in level.dimensions.values() + [level]:
chunkCoords = list(dim.allChunks)
i = 0
total = len(chunkCoords)
fc = "Fixing chunks for %s..." % dim.displayName
print fc,
fci = len(fc) + 2
for coord in chunkCoords:
chunk = dim.getChunk(*coord)
if i % 10 == 0: print "\033[%dG%0.2f%%" % (fci, float(i) / total * 100),
chunk.Blocks[:] = chunk.Blocks[:] & 255
chunk.chunkChanged(False)
i += 1
print "\033[%dG\033[Kdone." % fci
print "Saving world...",
level.saveInPlace()
print "done."
else:
raise ImportError, "Not meant to be imported"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment