Skip to content

Commit d675ade

Browse files
SpecialBuilder32misode
authored andcommitted
Advancement models inherit from VanillaTemplate
1 parent e5cbe37 commit d675ade

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

gm4/plugins/resource_pack.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -908,9 +908,11 @@ def create_models(self, config: ModelData, models_container: NamespaceProxy[Mode
908908
ret_list.append(m)
909909
model_def_map[item] = {
910910
"type": "minecraft:special" if special_model else "minecraft:model",
911-
"model": model_compound["model"] if special_model else model_name
911+
"model": model_compound["model"] if special_model else model_name,
912912
} | (
913-
{"tints": t if (t:=model_compound.get("tints")) else {}}
913+
{"base": model_name} if special_model else {}
914+
) | (
915+
{"tints": t} if (t:=model_compound.get("tints")) else {}
914916
)
915917
self._item_def_map.update(model_def_map)
916918
return ret_list
@@ -931,28 +933,32 @@ def create_models(self, config: ModelData, models_container: NamespaceProxy[Mode
931933
if not self.forward:
932934
# then we use the vanilla item's model and settings - inheriting from VanillaTemplate for this
933935
item = config.item.entries()[0]
934-
config_copy = config.copy(update={"model": MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancements/{advancement_name}"})})
935-
TemplateOptions.create_models(self, config_copy, models_container)
936-
937-
m = models_container[f"gm4:gui/advancements/{advancement_name}"] = Model({
938-
"parent": self.forward
939-
})
940-
# config.model = MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancements/{advancement_name}"})
936+
config_copy = config.copy(update={"model": MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancement/{advancement_name}"})})
937+
m = VanillaTemplate.create_models(self, config_copy, models_container)[0]
938+
939+
else:
940+
m = models_container[f"gm4:gui/advancement/{advancement_name}"] = Model({
941+
"parent": self.forward
942+
})
943+
config.model = MapOption(__root__={config.item.entries()[0]: f"gm4:gui/advancement/{advancement_name}"})
941944
return [m]
942945

943946
def get_item_def_entry(self, config: ModelData, item: str):
944-
if self.tints:
945-
return {
946-
"type": "model",
947-
"model": config.model.entries()[0],
948-
"tints": [
949-
{
950-
"type": "minecraft:constant",
951-
"value": tint
952-
}
953-
for tint in self.tints.entries()
954-
]
955-
}
947+
if not self.forward: # use item def from VanillaTemplate
948+
return VanillaTemplate.get_item_def_entry(self, config, item)
949+
else:
950+
if self.tints:
951+
return {
952+
"type": "model",
953+
"model": config.model.entries()[0],
954+
"tints": [
955+
{
956+
"type": "minecraft:constant",
957+
"value": tint
958+
}
959+
for tint in self.tints.entries()
960+
]
961+
}
956962
return None
957963

958964
def add_namespace(self, namespace: str):

0 commit comments

Comments
 (0)