Skip to content

Commit edc07b1

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

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

gm4/plugins/resource_pack.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,11 @@ 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
)
9991001
self._item_def_map.update(model_def_map)
10001002
return ret_list
@@ -1015,28 +1017,32 @@ def create_models(self, config: ModelData, models_container: NamespaceProxy[Mode
10151017
if not self.forward:
10161018
# then we use the vanilla item's model and settings - inheriting from VanillaTemplate for this
10171019
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}"})
1020+
config_copy = config.copy(update={"model": MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancement/{advancement_name}"})})
1021+
m = VanillaTemplate.create_models(self, config_copy, models_container)[0]
1022+
1023+
else:
1024+
m = models_container[f"gm4:gui/advancement/{advancement_name}"] = Model({
1025+
"parent": self.forward
1026+
})
1027+
config.model = MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancement/{advancement_name}"})
10251028
return [m]
10261029

10271030
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-
}
1031+
if not self.forward: # use item def from VanillaTemplate
1032+
return VanillaTemplate.get_item_def_entry(self, config, item)
1033+
else:
1034+
if self.tints:
1035+
return {
1036+
"type": "model",
1037+
"model": config.model.entries()[0],
1038+
"tints": [
1039+
{
1040+
"type": "minecraft:constant",
1041+
"value": tint
1042+
}
1043+
for tint in self.tints.entries()
1044+
]
1045+
}
10401046
return None
10411047

10421048
def add_namespace(self, namespace: str):

0 commit comments

Comments
 (0)