-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetbiome.py
90 lines (81 loc) · 2.4 KB
/
setbiome.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
# SethBling's SetBiome Filter
# Directions: Just select a region and use this filter, it will apply the
# biome to all columns within the selected region. It can be used on regions
# of any size, they need not correspond to chunks.
#
# If you modify and redistribute this code, please credit SethBling
from pymclevel import MCSchematic
from pymclevel import TAG_Compound
from pymclevel import TAG_Short
from pymclevel import TAG_Byte
from pymclevel import TAG_Byte_Array
from pymclevel import TAG_String
from numpy import zeros
inputs = (
("Biome", ("Desert",
"Mushroom Island",
"Ocean",
"Plains",
"Mountains",
"Forest",
"Taiga",
"Swamp",
"River",
"Nether",
"Sky",
"Frozen Ocean",
"Frozen River",
"Ice Plains",
"Ice Mountains",
"Mushroom Shore",
"Beach",
"Desert Hills",
"Forest Hills",
"Taiga Hills",
"Mountains Edge",
"Jungle",
"Jungle Hills",
)),
)
biomes = {
"Ocean":0,
"Plains":1,
"Desert":2,
"Mountains":3,
"Forest":4,
"Taiga":5,
"Swamp":6,
"River":7,
"Nether":8,
"Sky":9,
"Frozen Ocean":10,
"Frozen River":11,
"Ice Plains":12,
"Ice Mountains":13,
"Mushroom Island":14,
"Mushroom Shore":15,
"Beach":16,
"Desert Hills":17,
"Forest Hills":18,
"Taiga Hills":19,
"Mountains Edge":20,
"Jungle":21,
"Jungle Hills":22,
}
def perform(level, box, options):
biome = biomes[options["Biome"]]
minx = int(box.minx/16)*16
minz = int(box.minz/16)*16
for x in xrange(minx, box.maxx, 16):
for z in xrange(minz, box.maxz, 16):
chunk = level.getChunk(x / 16, z / 16)
chunk.decompress()
chunk.dirty = True
array = chunk.root_tag["Level"]["Biomes"].getValue()
chunkx = int(x/16)*16
chunkz = int(z/16)*16
for bx in xrange(max(box.minx, chunkx), min(box.maxx, chunkx+16)):
for bz in xrange(max(box.minz, chunkz), min(box.maxz, chunkz+16)):
idx = 16*(bz-chunkz)+(bx-chunkx)
array[idx] = biome
chunk.root_tag["Level"]["Biomes"].setValue(array)