forked from TerraFirmaCraft/TerraFirmaCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateTrees.py
138 lines (115 loc) · 4.46 KB
/
generateTrees.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import os
from nbtlib import nbt
from nbtlib.tag import *
def tree(origin, wood, nameout):
f = nbt.load(origin + '.nbt')
for block in f.root['palette']:
if block['Name'] == 'minecraft:log':
block['Name'] = String('tfc:wood/log/' + wood)
prop = block['Properties']
block['Properties'] = Compound({
'small': String('false'),
'placed': String('false'),
'axis': prop['axis']
})
if block['Name'] == 'minecraft:planks': # Planks indicate bark blocks
block['Name'] = String('tfc:wood/log/' + wood)
block['Properties'] = Compound({
'small': String('false'),
'placed': String('false'),
'axis': String('none')
})
if block['Name'] == 'minecraft:leaves':
block['Name'] = String('tfc:wood/leaves/' + wood)
block['Properties'] = Compound({
'decayable': String('true')
})
if not os.path.exists('src/main/resources/assets/tfc/structures/' + wood):
os.makedirs('src/main/resources/assets/tfc/structures/' + wood)
f.save('src/main/resources/assets/tfc/structures/' + wood + '/' + nameout + '.nbt')
def fruit_tree(ftree):
f = nbt.load('structure_templates/fruit_tree_base.nbt')
for block in f.root['palette']:
if block['Name'] == 'tfc:fruit_trees/branch/peach':
block['Name'] = String('tfc:fruit_trees/branch/' + ftree)
elif block['Name'] == 'tfc:fruit_trees/leaves/peach':
block['Name'] = String('tfc:fruit_trees/leaves/' + ftree)
elif block['Name'] == 'tfc:fruit_trees/trunk/peach':
block['Name'] = String('tfc:fruit_trees/trunk/' + ftree)
if not os.path.exists('src/main/resources/assets/tfc/structures/fruit_trees'):
os.makedirs('src/main/resources/assets/tfc/structures/fruit_trees')
f.save('src/main/resources/assets/tfc/structures/fruit_trees/' + ftree + '.nbt')
WOOD_TYPES = {
'acacia': 'acacia',
'ash': 'normal',
'aspen': 'normal',
'birch': 'normal',
'blackwood': 'tall',
'chestnut': 'normal',
'douglas_fir': 'tallXL',
'hickory': 'normal',
'maple': 'normal',
'oak': 'tallXL',
'palm': 'tropical',
'pine': 'conifer',
'rosewood': 'tall',
'sequoia': 'sequoia',
'spruce': 'conifer',
'sycamore': 'normal',
'white_cedar': 'tall',
'willow': 'willow',
'kapok': 'jungle'
}
for wood, key in WOOD_TYPES.items():
# normal (vanilla oak)
if key == 'normal':
tree('structure_templates/normal', wood, 'base')
tree('structure_templates/normal_overlay', wood, 'overlay')
# tall (tfc douglas fir, but smaller)
if key == 'tall':
tree('structure_templates/tall', wood, 'base')
tree('structure_templates/tall_overlay', wood, 'overlay')
# tallXL (tfc douglas fir, full size-ish)
if key == 'tallXL':
tree('structure_templates/tall2', wood, 'base')
tree('structure_templates/tall2_overlay', wood, 'overlay')
# overhang (willow)
if key == 'willow':
tree('structure_templates/willow', wood, 'base')
tree('structure_templates/willow_overlay', wood, 'overlay')
# conifer (vanilla spruce)
if key == 'conifer':
for s in ['1', '2', '3', '4', '5', '6', '7']:
tree('structure_templates/conifer' + s, wood, s)
# sequoia (large vanilla spruce kind of)
if key == 'sequoia':
for s in ['base', 'mid', 'top']:
for t in ['1', '2', '3']:
tree('structure_templates/conifer_large_' + s + t, wood, s + t)
# acacia (vanilla acacia, bit bigger)
if key == 'acacia':
for s in ['1', '2', '3']:
tree('structure_templates/acacia_branch' + s, wood, 'branch' + s)
# palm like trees
if key == 'tropical':
for s in ['1', '2', '3', '4', '5', '6', '7']:
tree('structure_templates/tropical' + s, wood, s)
# kapok (vanilla jungle trees, but better) Also have a vanilla oak variant
if key == 'jungle':
for s in ['branch1', 'branch2', 'branch3', 'top']:
tree('structure_templates/jungle_' + s, wood, s)
tree('structure_templates/normal', wood, 'base')
tree('structure_templates/normal_overlay', wood, 'overlay')
FRUIT_TREES = [
'banana',
'cherry',
'olive',
'red_apple',
'green_apple',
'lemon',
'orange',
'peach',
'plum'
]
for tree in FRUIT_TREES:
fruit_tree(tree)