advancement revoke @s only pctf:rightclick_maker
execute if score @s maker_cooldown matches 10..35 run title @s actionbar {"text":"You are using the items too quickly!","color":"yellow"}
execute if score @s maker_cooldown matches 1.. run return 0
execute unless predicate pctf:offhand run return run tellraw @s {"text":"Clear your offhand item!","color":"red"}

execute store result storage pctf:map_maker input.map_id int 1 run scoreboard players get @s map_maker_id
execute if entity @s[tag=edit_mode] store result storage pctf:map_maker input.map_id int 1 run scoreboard players get @s map_editor_id

execute if items entity @s weapon.mainhand minecraft:lime_dye[minecraft:custom_data~{green_flag:1b}] run function pctf:create_game_object/flag_location/green with storage pctf:map_maker input
execute if items entity @s weapon.mainhand minecraft:light_blue_dye[minecraft:custom_data~{aqua_flag:1b}] run function pctf:create_game_object/flag_location/aqua with storage pctf:map_maker input
execute if items entity @s weapon.mainhand minecraft:yellow_dye[minecraft:custom_data~{yellow_flag:1b}] run function pctf:create_game_object/flag_location/yellow with storage pctf:map_maker input
execute if items entity @s weapon.mainhand minecraft:magenta_dye[minecraft:custom_data~{light_purple_flag:1b}] run function pctf:create_game_object/flag_location/light_purple with storage pctf:map_maker input

execute if items entity @s weapon.mainhand minecraft:tnt_minecart[minecraft:custom_data~{destroy_all:1b}] run function pctf:mode/z_map_maker/reset_markers with storage pctf:map_maker input

execute if items entity @s weapon.mainhand minecraft:red_dye[minecraft:custom_data~{red_spawn:1b}] run function pctf:create_game_object/spawn_location/red with storage pctf:map_maker input
execute if items entity @s weapon.mainhand minecraft:blue_dye[minecraft:custom_data~{blue_spawn:1b}] run function pctf:create_game_object/spawn_location/blue with storage pctf:map_maker input

execute if items entity @s weapon.mainhand minecraft:light_gray_dye[minecraft:custom_data~{death_plane:1b}] store result storage pctf:map_maker input.y int 1 run data get entity @s Pos[1]
execute if items entity @s weapon.mainhand minecraft:light_gray_dye[minecraft:custom_data~{death_plane:1b}] run function pctf:create_game_object/death_plane with storage pctf:map_maker input

execute if items entity @s weapon.mainhand minecraft:fermented_spider_eye[minecraft:custom_data~{red_dropoff:1b}] run function pctf:create_game_object/flag_dropoff/red with storage pctf:map_maker input
execute if items entity @s weapon.mainhand minecraft:heart_of_the_sea[minecraft:custom_data~{blue_dropoff:1b}] run function pctf:create_game_object/flag_dropoff/blue with storage pctf:map_maker input

execute if items entity @s weapon.mainhand minecraft:gold_ingot[minecraft:custom_data~{shop:1b}] run function pctf:create_game_object/shop with storage pctf:map_maker input
execute if items entity @s weapon.mainhand minecraft:slime_ball[minecraft:custom_data~{create:1b}] run function pctf:mode/z_map_maker/create with storage pctf:map_maker input

execute if items entity @s weapon.mainhand minecraft:echo_shard[minecraft:custom_data~{destroy_nearest:1b}] run function pctf:mode/z_map_maker/destroy_nearest with storage pctf:map_maker input

execute if items entity @s weapon.mainhand minecraft:nether_star[minecraft:custom_data={return:1b}] run function pctf:mode/return_simple
execute if items entity @s weapon.mainhand minecraft:nether_star[minecraft:custom_data={edit:1b,return:1b}] run function pctf:mode/return with storage pctf:map_maker input

execute if items entity @s[tag=picking_map] weapon.mainhand minecraft:slime_ball[minecraft:custom_data={this_map:1b}] run function pctf:mode/z_map_maker/this_map with storage pctf:map_maker input

execute if items entity @s[tag=picking_map] weapon.mainhand minecraft:magma_cream[minecraft:custom_data={next_map:1b}] run function pctf:mode/z_map_maker/next_map/init

execute if items entity @s weapon.mainhand minecraft:rabbit_hide[minecraft:custom_data~{powerup:1b}] run function pctf:create_game_object/powerup_location/spawn with storage pctf:map_maker input

playsound minecraft:block.bamboo.place player @s ~ ~ ~ 1 0

scoreboard players set @s maker_cooldown 45