Skip to content

Commit f190087

Browse files
Advancement models inherit from VanillaTemplate
1 parent 2317b6c commit f190087

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

gm4/plugins/resource_pack.py

+28-21
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,13 @@ def create_models(self, config: ModelData, models_container: NamespaceProxy[Mode
992992
ret_list.append(m)
993993
model_def_map[item] = {
994994
"type": "minecraft:special" if special_model else "minecraft:model",
995-
"model": model_compound["model"] if special_model else model_name
995+
"model": model_compound["model"] if special_model else model_name,
996996
} | (
997-
{"tints": t if (t:=model_compound.get("tints")) else {}}
997+
{"base": model_name} if special_model else {}
998+
) | (
999+
{"tints": t} if (t:=model_compound.get("tints")) else {}
9981000
)
1001+
print(model_def_map)
9991002
self._item_def_map.update(model_def_map)
10001003
return ret_list
10011004

@@ -1015,28 +1018,32 @@ def create_models(self, config: ModelData, models_container: NamespaceProxy[Mode
10151018
if not self.forward:
10161019
# then we use the vanilla item's model and settings - inheriting from VanillaTemplate for this
10171020
item = config.item.entries()[0]
1018-
config_copy = config.copy(update={"model": MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancements/{advancement_name}"})})
1019-
TemplateOptions.create_models(self, config_copy, models_container)
1020-
1021-
m = models_container[f"gm4:gui/advancements/{advancement_name}"] = Model({
1022-
"parent": self.forward
1023-
})
1024-
# config.model = MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancements/{advancement_name}"})
1021+
config_copy = config.copy(update={"model": MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancement/{advancement_name}"})})
1022+
m = VanillaTemplate.create_models(self, config_copy, models_container)[0]
1023+
1024+
else:
1025+
m = models_container[f"gm4:gui/advancement/{advancement_name}"] = Model({
1026+
"parent": self.forward
1027+
})
1028+
config.model = MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancement/{advancement_name}"})
10251029
return [m]
10261030

10271031
def get_item_def_entry(self, config: ModelData, item: str):
1028-
if self.tints:
1029-
return {
1030-
"type": "model",
1031-
"model": config.model.entries()[0],
1032-
"tints": [
1033-
{
1034-
"type": "minecraft:constant",
1035-
"value": tint
1036-
}
1037-
for tint in self.tints.entries()
1038-
]
1039-
}
1032+
if not self.forward: # use item def from VanillaTemplate
1033+
return VanillaTemplate.get_item_def_entry(self, config, item)
1034+
else:
1035+
if self.tints:
1036+
return {
1037+
"type": "model",
1038+
"model": config.model.entries()[0],
1039+
"tints": [
1040+
{
1041+
"type": "minecraft:constant",
1042+
"value": tint
1043+
}
1044+
for tint in self.tints.entries()
1045+
]
1046+
}
10401047
return None
10411048

10421049
def add_namespace(self, namespace: str):

0 commit comments

Comments
 (0)