-
Notifications
You must be signed in to change notification settings - Fork 26
/
armor.py
92 lines (89 loc) · 2.9 KB
/
armor.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
import os
import json
import shutil
import glob
from jproperties import Properties
optifine = Properties()
i = 0
item_type = ["leather_helmet", "leather_chestplate", "leather_leggings", "leather_boots"]
def write_armor(file, gmdl, layer, i):
if i == 0:
type = "helmet"
elif i == 1:
type = "chestplate"
elif i == 2:
type = "leggings"
elif i == 3:
type = "boots"
ajson = {
"format_version": "1.10.0",
"minecraft:attachable": {
"description": {
"identifier": f"geyser_custom:{gmdl}.player",
"item": { f"geyser_custom:{gmdl}": "query.owner_identifier == 'minecraft:player'" },
"materials": {
"default": "armor_leather",
"enchanted": "armor_leather_enchanted"
},
"textures": {
"default": f"textures/armor_layer/{layer}",
"enchanted": "textures/misc/enchanted_item_glint"
},
"geometry": {
"default": f"geometry.player.armor.{type}"
},
"scripts": {
"parent_setup": "variable.helmet_layer_visible = 0.0;"
},
"render_controllers": ["controller.render.armor"]
}
}
}
with open(file, "w") as f:
f.write(json.dumps(ajson))
while i < 4:
try:
with open(f"pack/assets/minecraft/models/item/{item_type[i]}.json", "r") as f:
data = json.load(f)
except:
i += 1
continue
for override in data["overrides"]:
custom_model_data = override["predicate"]["custom_model_data"]
model = override["model"]
namespace = model.split(":")[0]
item = model.split("/")[-1]
if item in item_type:
continue
else:
try:
path = model.split(":")[1]
optifine_file = f"{namespace}_{item}"
with open(f"pack/assets/minecraft/optifine/cit/ia_generated_armors/{optifine_file}.properties", "rb") as f:
optifine.load(f)
if i == 2:
layer = optifine.get("texture.leather_layer_2").data.split(".")[0]
else:
layer = optifine.get("texture.leather_layer_1").data.split(".")[0]
if not os.path.exists("staging/target/rp/textures/armor_layer"):
os.mkdir("staging/target/rp/textures/armor_layer")
if not os.path.exists(f"staging/target/rp/textures/armor_layer/{layer}.png"):
shutil.copy(f"pack/assets/minecraft/optifine/cit/ia_generated_armors/{layer}.png", "staging/target/rp/textures/armor_layer")
with open(f"pack/assets/{namespace}/models/{path}.json", "r") as f :
texture = json.load(f)["textures"]["layer1"]
tpath = texture.split(":")[1]
try:
shutil.copy(f"pack/assets/{namespace}/textures/{tpath}.png", f"staging/target/rp/textures/{namespace}/{path}.png")
except Exception as e:
print(e)
afile = glob.glob(f"staging/target/rp/attachables/{namespace}/{path}*.json")
with open(afile[0], "r") as f:
da = json.load(f)["minecraft:attachable"]
gmdl = da["description"]["identifier"].split(":")[1]
pfile = afile[0].replace(".json", ".player.json")
write_armor(pfile, gmdl, layer, i)
except Exception as e:
print(e)
print("Item not found of ...")
continue
i += 1