diff --git a/beet.yml b/beet.yml index a5f3e1b..b305011 100644 --- a/beet.yml +++ b/beet.yml @@ -35,12 +35,13 @@ meta: cmd_id: 777 default_item_head: minecraft:stick default_item_inventory: minecraft:leather_helmet - render: - data_pack: - advancements: ["oran9eutan:*"] - functions: ["oran9eutan:*"] installation_advancement: author_skull_owner: Oran9eUtan icon: item: "minecraft:stick" nbt: "{CustomModelData: {{ hats.hat.fez.cmd }}}" + render: + data_pack: + advancements: ["oran9eutan:*"] + functions: ["oran9eutan:*"] + item_tags: ["oran9eutan:*"] diff --git a/datapack/data/oran9eutan/advancements/hats/root.json b/datapack/data/oran9eutan/advancements/hats/root.json index 660a811..9bd7cba 100644 --- a/datapack/data/oran9eutan/advancements/hats/root.json +++ b/datapack/data/oran9eutan/advancements/hats/root.json @@ -1,7 +1,7 @@ { "display": { "icon": { - "item": "minecraft:stick", + "item": "{{ hats.default_item_head }}", "nbt": "{CustomModelData: {{ hats.hat.fez.cmd }}}" }, "title": { diff --git a/datapack/data/oran9eutan/functions/hats/dress/villager/add_fav_cat_trade.mcfunction b/datapack/data/oran9eutan/functions/hats/dress/villager/add_fav_cat_trade.mcfunction index d8ede6f..ffc817c 100644 --- a/datapack/data/oran9eutan/functions/hats/dress/villager/add_fav_cat_trade.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/dress/villager/add_fav_cat_trade.mcfunction @@ -2,11 +2,11 @@ # Descr: Adds offer of the favorite cat the Villager Trader is wearing # Add template offer -data modify entity @s Offers.Recipes append value {sell:{id:"minecraft:leather_helmet",Count:1b}} +data modify entity @s Offers.Recipes append value {sell:{id:"{{ hats.default_item_inventory }}",Count:1b}} # Set the sell item of the template offer to the cat hat on the villagers head data modify entity @s Offers.Recipes[-1].sell.tag set from entity @s ArmorItems[3].tag # Set offer price loot replace entity @s weapon.offhand loot oran9eutan:hats/trades/villager/fav_cat_price -data modify entity @s Offers.Recipes[-1].buy set from entity @s HandItems[1] \ No newline at end of file +data modify entity @s Offers.Recipes[-1].buy set from entity @s HandItems[1] diff --git a/datapack/data/oran9eutan/functions/hats/dress/villager/add_profession_trade.mcfunction b/datapack/data/oran9eutan/functions/hats/dress/villager/add_profession_trade.mcfunction index 397968d..549c608 100644 --- a/datapack/data/oran9eutan/functions/hats/dress/villager/add_profession_trade.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/dress/villager/add_profession_trade.mcfunction @@ -2,7 +2,7 @@ # descr: Adds profession dependent special offer to the Villager # Add template offer -data modify entity @s Offers.Recipes append value {buy:{id:"minecraft:emerald", Count:1b}, sell:{id:"minecraft:leather_helmet",Count:1b}} +data modify entity @s Offers.Recipes append value {buy:{id:"minecraft:emerald", Count:1b}, sell:{id:"{{ hats.default_item_inventory }}",Count:1b}} # Give Villager item depending on profession loot replace entity @s weapon.offhand loot oran9eutan:hats/trades/villager/profession @@ -10,4 +10,4 @@ data modify entity @s Offers.Recipes[-1].sell.tag set from entity @s HandItems[1 # Set offer price loot replace entity @s weapon.offhand loot oran9eutan:hats/trades/villager/profession_price -data modify entity @s Offers.Recipes[-1].buy set from entity @s HandItems[1] \ No newline at end of file +data modify entity @s Offers.Recipes[-1].buy set from entity @s HandItems[1] diff --git a/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_fav_cat_trade.mcfunction b/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_fav_cat_trade.mcfunction index 9387348..56c192d 100644 --- a/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_fav_cat_trade.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_fav_cat_trade.mcfunction @@ -2,11 +2,11 @@ # Descr: Adds offer of the favorite cat the Wandering Trader is wearing # Add template offer -data modify entity @s Offers.Recipes append value {buy:{id:"minecraft:emerald", Count:1b}, sell:{id:"minecraft:leather_helmet",Count:1b}} +data modify entity @s Offers.Recipes append value {buy:{id:"minecraft:emerald", Count:1b}, sell:{id:"{{ hats.default_item_inventory }}",Count:1b}} # Set the sell item of the template offer to the cat hat on the Wandering Traders head data modify entity @s Offers.Recipes[-1].sell.tag set from entity @s ArmorItems[3].tag # Set offer price loot replace entity @s weapon.offhand loot oran9eutan:hats/trades/wandering_trader/fav_cat_price -data modify entity @s Offers.Recipes[-1].buy set from entity @s HandItems[1] \ No newline at end of file +data modify entity @s Offers.Recipes[-1].buy set from entity @s HandItems[1] diff --git a/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_villager_trade.mcfunction b/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_villager_trade.mcfunction index c4fbfb4..1f73261 100644 --- a/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_villager_trade.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/dress/wandering_trader/add_villager_trade.mcfunction @@ -2,7 +2,7 @@ # descr: Adds a hat trade related to Villagers # Add template offer that is modified later -data modify entity @s Offers.Recipes append value {buy:{id:"minecraft:emerald", Count:1b}, sell:{id:"minecraft:leather_helmet",Count:1b}} +data modify entity @s Offers.Recipes append value {buy:{id:"minecraft:emerald", Count:1b}, sell:{id:"{{ hats.default_item_inventory }}",Count:1b}} # Give trade sell item loot replace entity @s weapon.offhand loot oran9eutan:hats/hat_on_head/villager/random diff --git a/datapack/data/oran9eutan/functions/hats/event/player_dropped_hat_item.mcfunction b/datapack/data/oran9eutan/functions/hats/event/player_dropped_hat_item.mcfunction index 83f092c..58157ec 100644 --- a/datapack/data/oran9eutan/functions/hats/event/player_dropped_hat_item.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/event/player_dropped_hat_item.mcfunction @@ -1,5 +1,5 @@ -# Player dropped a stick or a leather helmet. Not certain that item is a hat -# executor: Player getting advancement +# Player dropped a #hat_head or a #hat_inventory. Not certain that item is a hat +# @s: Player that made advancement # Convert all nearby dog hat items into dogs execute if {{ hats.setting["dog_conversion"].is_true }} as @e[type=item,distance=..2,nbt={Item:{tag:{Tags:["hats.hat.type.dog"]}}}] at @s if data entity @s Item.tag.dog_data run function oran9eutan:hats/dog_mechanism/copy_dog_data_from_item diff --git a/datapack/data/oran9eutan/functions/hats/event/player_interacted_with_armor_stand.mcfunction b/datapack/data/oran9eutan/functions/hats/event/player_interacted_with_armor_stand.mcfunction index 5845436..ef3397c 100644 --- a/datapack/data/oran9eutan/functions/hats/event/player_interacted_with_armor_stand.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/event/player_interacted_with_armor_stand.mcfunction @@ -1,4 +1,4 @@ -# Replace leather helmet hats on armor stands nearby with stick hats +# Replace #hat_inventory hats on armor stands nearby with #hat_head hats execute as @e[type=minecraft:armor_stand,distance=0..8,tag=!global.ignore] if predicate oran9eutan:hats/entity/wears_inventory_hat run function oran9eutan:hats/hat_mechanism/equip_armorstand_with_correct_hat advancement revoke @s only oran9eutan:hats/event/player_interacted_with_armor_stand diff --git a/datapack/data/oran9eutan/functions/hats/event/player_received_head_hat.mcfunction b/datapack/data/oran9eutan/functions/hats/event/player_received_head_hat.mcfunction index 8f67dee..82a1636 100644 --- a/datapack/data/oran9eutan/functions/hats/event/player_received_head_hat.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/event/player_received_head_hat.mcfunction @@ -5,7 +5,7 @@ # Tag Player that they received a #hat_head tag @s add hats.tmp.received_head_hat # Fix the #hat_head in the next tick. Changing the inventory on an advancement trigger is buggy -schedule function oran9eutan:hats/proxies/fix_players_stick_hats_if_necessary 1t +schedule function oran9eutan:hats/proxies/fix_players_head_hats_if_necessary 1t # Reset trigger advancement revoke @s only oran9eutan:hats/event/player_received_head_hat diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_armorstand_with_correct_hat.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_armorstand_with_correct_hat.mcfunction index 8918e4c..1abeef2 100644 --- a/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_armorstand_with_correct_hat.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_armorstand_with_correct_hat.mcfunction @@ -1,7 +1,7 @@ ######################################################################## # as: ArmorStand # -# Descr: Replace the #hat on the ArmorStands head with an #hat_on_head # +# Descr: Replace the #hat on the ArmorStands head with an #hat_on_head # ######################################################################## -# Since #hat and #hat_on_head items have the same nbt, only change the item id -data modify entity @s ArmorItems[3] merge value {id:"minecraft:stick"} \ No newline at end of file +# Since #hat_inventory and #hat_head items have the same nbt, only change the item id +data modify entity @s ArmorItems[3] merge value {id:"{{ hats.default_item_head }}"} diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_player_with_correct_hat.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_player_with_correct_hat.mcfunction index 22d169b..5cdc722 100644 --- a/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_player_with_correct_hat.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/hat_mechanism/equip_player_with_correct_hat.mcfunction @@ -9,7 +9,7 @@ data modify storage minecraft:hats buffer.armor set value [] data modify storage minecraft:hats buffer.armor append from storage minecraft:hats buffer.all[{Slot:103b}] # Modify hat -data modify storage minecraft:hats buffer.armor[0].id set value "minecraft:stick" +data modify storage minecraft:hats buffer.armor[0].id set value "{{ hats.default_item_head }}" data modify storage minecraft:hats buffer.armor[0].Slot set value 0b # Replace Player helmet with modified hat diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats.mcfunction similarity index 79% rename from datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats.mcfunction rename to datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats.mcfunction index 7b63489..84ab5ca 100644 --- a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats.mcfunction @@ -1,5 +1,5 @@ -# executor: Player who have a stick hat in their inventory that needs to be fixed -# descr: Replaces any stick hats in the Players inventory with leather helmet hats +# Replaces any #hat_head hats in the players inventory with #hat_inventory hats +# @s: Player who has a #hat_head hat in their inventory # Extract hotbar from buffer.inv data modify storage minecraft:hats buffer.hotbar append from storage minecraft:hats buffer.inv[{Slot:0b}] @@ -12,7 +12,7 @@ data modify storage minecraft:hats buffer.hotbar append from storage minecraft:h data modify storage minecraft:hats buffer.hotbar append from storage minecraft:hats buffer.inv[{Slot:7b}] data modify storage minecraft:hats buffer.hotbar append from storage minecraft:hats buffer.inv[{Slot:8b}] -execute if data storage minecraft:hats buffer.hotbar[{id:"minecraft:stick", tag:{Tags:["hats.hat"]}}] run function oran9eutan:hats/hat_mechanism/fix_players_stick_hats_in_hotbar +execute if data storage minecraft:hats buffer.hotbar[{id:"{{ hats.default_item_head }}", tag:{Tags:["hats.hat"]}}] run function oran9eutan:hats/hat_mechanism/fix_players_head_hats_in_hotbar # Remove item in offhand from buffer.inv data remove storage minecraft:hats buffer.inv[{Slot:-106b}] @@ -34,4 +34,4 @@ data remove storage minecraft:hats buffer.inv[{Slot:1b}] data remove storage minecraft:hats buffer.inv[{Slot:0b}] # Now only items in the Players inventory should be left in buffer.inv -execute if data storage minecraft:hats buffer.inv[{id:"minecraft:stick", tag:{Tags:["hats.hat"]}}] run function oran9eutan:hats/hat_mechanism/fix_players_stick_hats_in_inventory \ No newline at end of file +execute if data storage minecraft:hats buffer.inv[{id:"{{ hats.default_item_head }}", tag:{Tags:["hats.hat"]}}] run function oran9eutan:hats/hat_mechanism/fix_players_head_hats_in_inventory diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_if_necessary.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_if_necessary.mcfunction new file mode 100644 index 0000000..ce2098d --- /dev/null +++ b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_if_necessary.mcfunction @@ -0,0 +1,12 @@ +# Determines if the Player has any #hat_head items in their inventory and then fixes them +# @s: Player whose #hat_head hats are going to be fixed + +# Store the Players inventory +data modify storage hats buffer.inv set from entity @s Inventory +# #hat_head hats on the Players head shold not get fixed +data remove storage minecraft:hats buffer.inv[{Slot:103b}] + +execute if data storage minecraft:hats buffer.inv[{id:"{{ hats.default_item_head }}", tag:{Tags:["hats.hat"]}}] run function oran9eutan:hats/hat_mechanism/fix_players_head_hats + +# Clean up +data remove storage minecraft:hats buffer diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_in_hotbar.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_in_hotbar.mcfunction new file mode 100644 index 0000000..6ebaff7 --- /dev/null +++ b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_in_hotbar.mcfunction @@ -0,0 +1,16 @@ +# Fixes all #hat_head hats in a players hotbar slots +# @s: Player whos inventory is getting fixed +# requirements: +# - storage buffer.hotbar has to be populated +# - at least one #hat_head hat has to exist in buffer.hotbar + +# Replace all #hat_head hats with helmet hats +data modify storage minecraft:hats buffer.hotbar[{id:"{{ hats.default_item_head }}", tag:{Tags:["hats.hat"]}}].id set value "{{ hats.default_item_inventory }}" + +# Replaced Players hotbar with modified hotbar +setblock ~ 0 ~ minecraft:yellow_shulker_box +data modify block ~ 0 ~ Items set from storage minecraft:hats buffer.hotbar +loot replace entity @s hotbar.0 9 mine ~ 0 ~ minecraft:air{drop_contents:1b} + +# Clean up +setblock ~ 0 ~ minecraft:air diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_in_inventory.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_in_inventory.mcfunction similarity index 84% rename from datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_in_inventory.mcfunction rename to datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_in_inventory.mcfunction index 8f2dd08..a27e7be 100644 --- a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_in_inventory.mcfunction +++ b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_head_hats_in_inventory.mcfunction @@ -1,8 +1,8 @@ -# executor: Player whos inventory is getting fixed -# descr: Fixes all stick hats in the Players inventory slots +# Fixes all #hat_head hats in a players inventory slots +# @s: Player whos inventory is getting fixed # requirements: # - storage buffer.inv has to be populated -# - at least one stick hat has to exist in buffer.inv +# - at least one #hat_head hat has to exist in buffer.inv # Correct slot data data modify storage minecraft:hats buffer.inv[{Slot:9b}].Slot set value 0b @@ -33,10 +33,10 @@ data modify storage minecraft:hats buffer.inv[{Slot:33b}].Slot set value 24b data modify storage minecraft:hats buffer.inv[{Slot:34b}].Slot set value 25b data modify storage minecraft:hats buffer.inv[{Slot:35b}].Slot set value 26b -# Replace all stick Hats with helmet hats -data modify storage minecraft:hats buffer.inv[{id:"minecraft:stick", tag:{Tags:["hats.hat"]}}].id set value "minecraft:leather_helmet" +# Replace all #hat_head hats with #hat_inventory hats +data modify storage minecraft:hats buffer.inv[{id:"{{ hats.default_item_head }}", tag:{Tags:["hats.hat"]}}].id set value "{{ hats.default_item_inventory }}" -# Replaced Players inventory with modified inventory +# Replaced players inventory with modified inventory setblock ~ 0 ~ minecraft:yellow_shulker_box data modify block ~ 0 ~ Items set from storage minecraft:hats buffer.inv loot replace entity @s inventory.0 27 mine ~ 0 ~ minecraft:air{drop_contents:1b} diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_if_necessary.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_if_necessary.mcfunction deleted file mode 100644 index 5f63b0c..0000000 --- a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_if_necessary.mcfunction +++ /dev/null @@ -1,12 +0,0 @@ -# executor: Player whose stick hats are going to be fixed -# descr: Determines if the Player has any stick hats that need to be fixed and then fixes them - -# Store the Players inventory -data modify storage hats buffer.inv set from entity @s Inventory -# Stick hats on the Players head shold not get fixed -data remove storage minecraft:hats buffer.inv[{Slot:103b}] - -execute if data storage minecraft:hats buffer.inv[{id:"minecraft:stick", tag:{Tags:["hats.hat"]}}] run function oran9eutan:hats/hat_mechanism/fix_players_stick_hats - -# Clean up -data remove storage minecraft:hats buffer \ No newline at end of file diff --git a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_in_hotbar.mcfunction b/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_in_hotbar.mcfunction deleted file mode 100644 index e911fef..0000000 --- a/datapack/data/oran9eutan/functions/hats/hat_mechanism/fix_players_stick_hats_in_hotbar.mcfunction +++ /dev/null @@ -1,16 +0,0 @@ -# executor: Player whos inventory is getting fixed -# descr: Fixes all stick hats in the Players hotbar slots -# requirements: -# - storage buffer.hotbar has to be populated -# - at least one stick hat has to exist in buffer.hotbar - -# Replace all stick hats with helmet hats -data modify storage minecraft:hats buffer.hotbar[{id:"minecraft:stick", tag:{Tags:["hats.hat"]}}].id set value "minecraft:leather_helmet" - -# Replaced Players hotbar with modified hotbar -setblock ~ 0 ~ minecraft:yellow_shulker_box -data modify block ~ 0 ~ Items set from storage minecraft:hats buffer.hotbar -loot replace entity @s hotbar.0 9 mine ~ 0 ~ minecraft:air{drop_contents:1b} - -# Clean up -setblock ~ 0 ~ minecraft:air diff --git a/datapack/data/oran9eutan/functions/hats/proxies/fix_players_head_hats_if_necessary.mcfunction b/datapack/data/oran9eutan/functions/hats/proxies/fix_players_head_hats_if_necessary.mcfunction new file mode 100644 index 0000000..bb9d6ce --- /dev/null +++ b/datapack/data/oran9eutan/functions/hats/proxies/fix_players_head_hats_if_necessary.mcfunction @@ -0,0 +1,6 @@ +# This function is scheduled as a proxy, so that another function call can be scheduled with a desired context +# @s: World + +# Execute proxied function as Players that received a #hat_head hat +execute as @a[tag=!global.ignore,tag=hats.tmp.received_head_hat] run function oran9eutan:hats/hat_mechanism/fix_players_head_hats_if_necessary +tag @a remove hats.tmp.received_head_hat diff --git a/datapack/data/oran9eutan/functions/hats/proxies/fix_players_stick_hats_if_necessary.mcfunction b/datapack/data/oran9eutan/functions/hats/proxies/fix_players_stick_hats_if_necessary.mcfunction deleted file mode 100644 index c800760..0000000 --- a/datapack/data/oran9eutan/functions/hats/proxies/fix_players_stick_hats_if_necessary.mcfunction +++ /dev/null @@ -1,6 +0,0 @@ -# executor: World -# descr: This function is scheduled as a proxy, so that another function call can be scheduled with a desired context - -# Execute proxied function as Players that received a stick hat -execute as @a[tag=!global.ignore,tag=hats.tmp.received_head_hat] run function oran9eutan:hats/hat_mechanism/fix_players_stick_hats_if_necessary -tag @a remove hats.tmp.received_head_hat diff --git a/datapack/data/oran9eutan/tags/items/hat_head.json b/datapack/data/oran9eutan/tags/items/hat_head.json index e9744cf..d69b595 100644 --- a/datapack/data/oran9eutan/tags/items/hat_head.json +++ b/datapack/data/oran9eutan/tags/items/hat_head.json @@ -1 +1 @@ -{"values":["minecraft:stick"]} +{"values":["{{ hats.default_item_head }}"]} diff --git a/datapack/data/oran9eutan/tags/items/hat_inventory.json b/datapack/data/oran9eutan/tags/items/hat_inventory.json index a4fb06e..9c11822 100644 --- a/datapack/data/oran9eutan/tags/items/hat_inventory.json +++ b/datapack/data/oran9eutan/tags/items/hat_inventory.json @@ -1 +1 @@ -{"values":["minecraft:leather_helmet"]} +{"values":["{{ hats.default_item_inventory }}"]} diff --git a/hats/macros/advancements.json b/hats/macros/advancements.json index 0502ea7..9233a1e 100644 --- a/hats/macros/advancements.json +++ b/hats/macros/advancements.json @@ -4,7 +4,7 @@ {%- macro icon_hat(cmd) -%} { - "item": "minecraft:stick", + "item": "{{ hats.default_item_head }}", "nbt": "{CustomModelData: {{ cmd }}}" } {%- endmacro %} diff --git a/hats/plugins/item_models.py b/hats/plugins/item_models.py index 5c4f20d..a06f1f1 100644 --- a/hats/plugins/item_models.py +++ b/hats/plugins/item_models.py @@ -17,26 +17,29 @@ class ModelOverride: def beet_default(ctx: Context): opts = HatsOptions.from_json(ctx.meta["hats"]) - ctx.assets.merge(item_models(ctx, opts.cmd_id)) + ctx.assets.merge(item_models(ctx, opts)) -def item_models(ctx: Context, cmd_id: int): +def item_models(ctx: Context, opts: HatsOptions): """Create item models used for custom model data""" assets = ResourcePack() - registry = HatRegistry.get(cmd_id) + registry = HatRegistry.get(opts.cmd_id) overrides = [] for category, hats in registry.categories.items(): overrides += [ModelOverride(hat.cmd, hat.model_path(category)) for hat in hats] overrides = sorted(overrides, key=lambda o: o.cmd) - assets.models["minecraft:item/stick"] = Model( - ctx.template.render("models/stick.json", overrides=overrides) + item_head_name = opts.default_item_head.split(":")[1] + item_inventory_name = opts.default_item_inventory.split(":")[1] + + assets.models[f"minecraft:item/{item_head_name}"] = Model( + ctx.template.render(f"models/{item_head_name}.json", overrides=overrides) ) - assets.models["minecraft:item/leather_helmet"] = Model( - ctx.template.render("models/leather_helmet.json", overrides=overrides) + assets.models[f"minecraft:item/{item_inventory_name}"] = Model( + ctx.template.render(f"models/{item_inventory_name}.json", overrides=overrides) ) return assets