forked from Xinyuuu7/BastionGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jigsawBlocksGenerator.py
63 lines (49 loc) · 1.88 KB
/
jigsawBlocksGenerator.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
import os
import nbtlib
directory = 'jigsaws'
filenames = []
for root, dirs, files in os.walk(directory):
for fname in files:
filenames.append(os.path.join(root, fname))
def gen_jigsaws():
for filename in filenames:
nbt_file = nbtlib.load(filename)
blocks = nbt_file['blocks']
text = 'this.put(\"' + filename[:-4].replace('\\', '/') + '\", Arrays.asList(\n'
jigsaw_count = 0
first = True
for block in blocks:
blockstateid = int(block['state'])
blockinfo = nbt_file['palette'][blockstateid]
name = blockinfo['Name']
if name != 'minecraft:jigsaw':
continue
jigsaw_count += 1
orientation = blockinfo['Properties']['orientation']
orient_1, orient_2 = orientation.split('_')
poolname = block['nbt']['pool']
# processing poolname
poolname = poolname.upper().replace('\\', '_').replace('/', '_')
jigsawname = block['nbt']['name']
targetname = block['nbt']['target']
joint = block['nbt']['joint']
if not first:
text += ',\n'
first = False
text += f'\t\tnew JigsawBlock(PoolType.{poolname[10:]}, JointType.{joint.upper()}, '
text += f'\"{jigsawname[10:]}\", \"{targetname[10:]}\", '
text += f'BlockDirection.{orient_1.upper()}, BlockDirection.{orient_2.upper()}, '
blockpos = block['pos']
bpos = 'new BPos('
c = 0
for integer in blockpos:
c += 1
value = str(integer)[4:-1]
bpos += value
if c != 3:
bpos += ','
bpos += '))'
text += bpos
text += '\n));'
print(text)
gen_jigsaws()