-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmcworldgen.py
executable file
·97 lines (73 loc) · 2.25 KB
/
mcworldgen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
"""
mcworldgen.py
Standalone generator for mcworldgen: generates a default-ish minecraft map.
"""
# Dependencies
import random
import math
import copy
import time
import os
import subprocess
#import numpy
import time
import pymclevel as mcl
import sys
# Modules to test
from diamondsquare import *
from layer import *
from landmark import *
from saveutils import *
def namedModule(name):
"""Return a module given its name."""
try:
topLevel = __import__(name)
except ImportError:
name = "pipelines."+name
topLevel = __import__(name)
packages = name.split(".")[1:]
m = topLevel
for p in packages:
m = getattr(m, p)
return m
random.seed()
def filtertest(modulename="default"):
totaltime = 0
testworld = createWorld("testworld")
# cool seeds: 12397
worldseed = random.randint(0, 65535)
worldsizex = 8
worldsizez = 8
print "World seed is", worldseed
pipeline = namedModule(modulename)
print pipeline, dir(pipeline)
tfilter = pipeline.build(worldseed, testworld)
# Generate minecraft level
for chunkrow in xrange(-worldsizex, worldsizex):
print "Generating westward chunk strip", chunkrow
for chunkcol in xrange(-worldsizez, worldsizez):
#print "\n========\nChunk", (chunkrow, chunkcol), "\n========"
starttime = time.clock()
currchunk = tfilter.getChunk(chunkrow, chunkcol)
endtime = time.clock()
totaltime += endtime - starttime
setWorldChunk( testworld, currchunk, chunkrow, chunkcol)
saveWorld(testworld)
renderWorld("testworld", "testworld-"+str(worldseed)+"-"+str(worldsizex*2)+"x"+str(worldsizez*2))
print "World seed is", worldseed
print "Processing took", totaltime, "seconds."
if __name__ == "__main__":
try:
import psyco
psyco.full()
except ImportError:
print "Psyco could not be loaded. Install with \'sudo apt-get install python-psyco\' for additional speed boosts."
pass
if not os.path.isdir("renders"):
os.mkdir("renders")
if len(sys.argv)>1:
filtertest(sys.argv[1])
else:
filtertest()
print "Generation complete."