-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.py
39 lines (34 loc) · 1.13 KB
/
convert.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
from nbt.nbt import NBTFile
nbtfile = NBTFile("32.nbt", "rb")
size = [x.value for x in nbtfile["size"]]
# print("Size:", size)
# for x in nbtfile["size"][0]:
# for y in nbtfile["size"][1]:
# for z in nbtfile["size"][2]:
# block = nbtfile["blocks"][x * size[1] * this.size[2] + pos[1] * this.size[2] + pos[2]]
# print(nbtfile["palette"][0])
for block in nbtfile["blocks"]:
pos = [x.value for x in block["pos"]]
if pos[0] < 32 and pos[2] < 32:
state = block["state"].value
name = nbtfile["palette"][state]["Name"].value
# print(name)
blockID = 2
if name == "minecraft:air":
blockID = 0
elif name == "minecraft:dirt" or name == "minecraft:grass_block":
blockID = 1
elif name == "minecraft:oak_leaves":
blockID = 3
elif name == "minecraft:oak_log":
blockID = 4
elif name == "minecraft:sand":
blockID = 5
elif name == "minecraft:stone":
blockID = 6
elif name == "minecraft:water":
blockID = 7
elif name == "minecraft:wall_torch":
blockID = 0
if blockID != 0:
print(f"chunk->setBlock({31 - pos[0]}, {pos[1]}, {pos[2]}, {blockID});")