Skip to content

Commit

Permalink
refactor: Renamed "player_received_*" events
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeUtan committed Jul 6, 2021
1 parent 77da5bb commit 9e01394
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parent" : "oran9eutan:hats/root",
"criteria" : {
"player_received_stick_hat" : {
"player_received_head_hat" : {
"trigger" : "minecraft:inventory_changed",
"conditions" : {
"items": [
Expand All @@ -13,8 +13,7 @@
}
}
},
"requirements" : [["player_received_stick_hat"]],
"rewards": {
"function": "oran9eutan:hats/event/player_received_stick_hat"
"function": "oran9eutan:hats/event/player_received_head_hat"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parent" : "oran9eutan:hats/root",
"criteria" : {
"player_received_helmet_hat" : {
"received_inventory_hat" : {
"trigger" : "minecraft:inventory_changed",
"conditions" : {
"items": [
Expand All @@ -13,8 +13,7 @@
}
}
},
"requirements" : [["player_received_helmet_hat"]],
"rewards": {
"function": "oran9eutan:hats/event/player_received_helmet_hat"
"function": "oran9eutan:hats/event/player_received_inventory_hat"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Triggered via advancement when a players inventory contains a #hat_head.
# Replaces it with a #hat_inventory.
# @s: Player that made the advancement

# 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

# Reset trigger
advancement revoke @s only oran9eutan:hats/event/player_received_head_hat

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Triggered via advancement when a players inventory contains a #hat_inventory.
# If the item is on the players head, replace it with a #hat_head.
# @s: Player that made the advancement

# Check if the item is on the players hat. If so, schedule to fix it
execute if predicate oran9eutan:hats/entity/wears_inventory_hat run schedule function oran9eutan:hats/proxies/equip_player_with_correct_hat 1t

# Reset trigger
advancement revoke @s only oran9eutan:hats/event/player_received_inventory_hat

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# 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.player.received_stick_hat] run function oran9eutan:hats/hat_mechanism/fix_players_stick_hats_if_necessary
tag @a remove hats.player.received_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

0 comments on commit 9e01394

Please sign in to comment.