forked from Chrisknyfe/pymcworldgen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mcworldgen.py
executable file
·86 lines (65 loc) · 1.96 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
#!/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("nuclai.world")
# cool seeds: 12397
worldseed = random.randint(0, 65535)
worldsizex = 8
worldsizez = 8
print("World seed is", worldseed)
pipeline = namedModule(modulename)
tfilter = pipeline.build(worldseed, testworld)
# Generate minecraft level
for chunkrow in range(-worldsizex, worldsizex):
print("Generating chunk ", chunkrow)
for chunkcol in range(-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("Processing took", totaltime, "seconds.")
if __name__ == "__main__":
if not os.path.isdir("output"):
os.mkdir("output")
if len(sys.argv)>1:
filtertest(sys.argv[1])
else:
filtertest()
print("Generation complete.")