#🛠
execute if block ~ ~ ~ #minecraft:anvil run return run kill @s
execute if block ~ ~1 ~ #minecraft:anvil run return run kill @s
particle minecraft:enchant ~ ~1 ~ 0 0 0 1 100
scoreboard players add .global reforgeId 1
scoreboard players add .global id 1
scoreboard players operation @s reforgeId = .global reforgeId
scoreboard players set .rotation const 0
execute store result score .rotation const run data get entity @p Rotation[0]
summon text_display ~ ~1.4 ~0.05 {NoGravity:1b,Silent:1b,billboard:"center",shadow:0b,see_through:0b,alignment:"center",Tags:["target_type_displayname2","finit","forge_tag"],text:[{"bold":false,"color":"gold","italic":false,"text":""}],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[2f,2f,2f]}}
summon interaction ~ ~1.5 ~ {NoGravity:1b,Silent:1b,width:0f,height:0f,response:1b,Tags:["forge_detection","finit","forge_tag"],CustomNameVisible:0b,CustomName:{"bold":true,"color":"white","italic":false,"text":"Click here to forge!"}}
summon item_display ~ ~1.75 ~ {view_range:0.5f,width:1f,height:1f,billboard:"fixed",item_display:"fixed",Tags:["target_forge_display_item","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[0.5f,0.5f,0.5f]},item:{id:"minecraft:barrier",count:1,components:{"minecraft:item_model":"minecraft:air"}},teleport_duration:2}

execute if score .rotation const matches 46..135 run summon interaction ~ ~1 ~0.3 {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_item", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches 46..135 run summon interaction ~ ~1 ~-0.3 {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_reforge", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches 46..135 run summon item_display ~ ~1 ~0.3 {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"white","italic":false,"text":"Item"},width:1f,height:1.5f,billboard:"vertical",item_display:"fixed",Tags:["target_type_item", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches 46..135 run summon item_display ~ ~1 ~-0.3 {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"aqua","italic":false,"text":"Forge"},width:1f,height:1.5f,billboard:"fixed",item_display:"fixed",Tags:["target_type_reforge", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches 46..135 run summon block_display ~ ~1 ~0.3 {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:smooth_stone_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches 46..135 run summon block_display ~ ~1 ~-0.3 {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:polished_deepslate_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches 46..135 as @n[tag=target_forge_display_item,tag=finit] at @s run tp @s ~ ~ ~ -90 0
execute if score .rotation const matches 46..135 run summon text_display ~ ~1.7 ~0.25 {line_width:80,NoGravity:1b,Silent:1b,billboard:"vertical",shadow:0b,see_through:0b,alignment:"right",Tags:["target_type_displayname","finit","forge_tag"],text:[{"color":"green","italic":false,"text":""},{"bold":true,"color":"#00E600","italic":false,"text":""}],background:840017408,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.425f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
execute if score .rotation const matches 46..135 run summon text_display ~ ~1.5 ~-0.5 {line_width:200,background:-936168653,view_range:0.1f,width:1f,height:1f,billboard:"vertical",alignment:"left",Tags:["target_forge_display_text","finit","forge_tag"],text:{"color":"white","italic":false,"text":""},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[1f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
# Angle 2
execute if score .rotation const matches -45..45 run summon interaction ~0.3 ~1 ~ {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_item", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches -45..45 run summon interaction ~-0.3 ~1 ~ {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_reforge", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches -45..45 run summon item_display ~0.3 ~1 ~ {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"white","italic":false,"text":"Item"},width:1f,height:1.5f,billboard:"vertical",item_display:"fixed",Tags:["target_type_item", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches -45..45 run summon item_display ~-0.3 ~1 ~ {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"aqua","italic":false,"text":"Forge"},width:1f,height:1.5f,billboard:"fixed",item_display:"fixed",Tags:["target_type_reforge", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches -45..45 run summon block_display ~0.3 ~1 ~ {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:smooth_stone_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches -45..45 run summon block_display ~-0.3 ~1 ~ {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:polished_deepslate_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches -45..45 as @n[tag=target_forge_display_item,tag=finit] at @s run tp @s ~ ~ ~ 180 0
execute if score .rotation const matches -45..45 run summon text_display ~0.25 ~1.7 ~ {line_width:80,NoGravity:1b,Silent:1b,billboard:"vertical",shadow:0b,see_through:0b,alignment:"right",Tags:["target_type_displayname","finit","forge_tag"],text:[{"color":"green","italic":false,"text":""},{"bold":true,"color":"#00E600","italic":false,"text":""}],background:840017408,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.425f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
execute if score .rotation const matches -45..45 run summon text_display ~-0.5 ~1.5 ~ {line_width:200,background:-936168653,view_range:0.1f,width:1f,height:1f,billboard:"vertical",alignment:"left",Tags:["target_forge_display_text","finit","forge_tag"],text:{"color":"white","italic":false,"text":""},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[1f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
# Angle 3
execute if score .rotation const matches -135..-46 run summon interaction ~ ~1 ~-0.3 {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_item", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches -135..-46 run summon interaction ~ ~1 ~0.3 {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_reforge", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches -135..-46 run summon item_display ~ ~1 ~-0.3 {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"white","italic":false,"text":"Item"},width:1f,height:1.5f,billboard:"vertical",item_display:"fixed",Tags:["target_type_item", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches -135..-46 run summon item_display ~ ~1 ~0.3 {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"aqua","italic":false,"text":"Forge"},width:1f,height:1.5f,billboard:"fixed",item_display:"fixed",Tags:["target_type_reforge", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches -135..-46 run summon block_display ~ ~1 ~-0.3 {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:smooth_stone_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches -135..-46 run summon block_display ~ ~1 ~0.3 {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:polished_deepslate_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches -135..-46 as @n[tag=target_forge_display_item,tag=finit] at @s run tp @s ~ ~ ~ 90 0
execute if score .rotation const matches -135..-46 run summon text_display ~ ~1.7 ~-0.25 {line_width:80,NoGravity:1b,Silent:1b,billboard:"vertical",shadow:0b,see_through:0b,alignment:"right",Tags:["target_type_displayname","finit","forge_tag"],text:[{"color":"green","italic":false,"text":""},{"bold":true,"color":"#00E600","italic":false,"text":""}],background:840017408,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.425f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
execute if score .rotation const matches -135..-46 run summon text_display ~ ~1.5 ~0.5 {line_width:200,background:-936168653,view_range:0.1f,width:1f,height:1f,billboard:"vertical",alignment:"left",Tags:["target_forge_display_text","finit","forge_tag"],text:{"color":"white","italic":false,"text":""},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[1f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
# Angle 4
execute if score .rotation const matches -180..-136 run summon interaction ~-0.3 ~1 ~ {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_item", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches -180..-136 run summon interaction ~0.3 ~1 ~ {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_reforge", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches -180..-136 run summon item_display ~-0.3 ~1 ~ {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"white","italic":false,"text":"Item"},width:1f,height:1.5f,billboard:"vertical",item_display:"fixed",Tags:["target_type_item", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches -180..-136 run summon item_display ~0.3 ~1 ~ {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"aqua","italic":false,"text":"Forge"},width:1f,height:1.5f,billboard:"fixed",item_display:"fixed",Tags:["target_type_reforge", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches -180..-136 run summon block_display ~-0.3 ~1 ~ {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:smooth_stone_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches -180..-136 run summon block_display ~0.3 ~1 ~ {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:polished_deepslate_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches -180..-136 run summon text_display ~0.25 ~1.7 ~ {line_width:80,view_range:0.1f,width:1f,height:1f,billboard:"vertical",alignment:"left",Tags:["target_forge_display_text","finit","forge_tag"],text:{"color":"white","italic":false,"text":""},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[1f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
execute if score .rotation const matches -180..-136 run summon text_display ~-0.5 ~1.5 ~ {line_width:200,background:-936168653,NoGravity:1b,Silent:1b,billboard:"vertical",shadow:0b,see_through:0b,alignment:"right",Tags:["target_type_displayname","finit","forge_tag"],text:[{"color":"green","italic":false,"text":""},{"bold":true,"color":"#00E600","italic":false,"text":""}],background:840017408,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.425f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
execute if score .rotation const matches -180..-136 as @n[tag=target_forge_display_item,tag=finit] at @s run tp @s ~ ~ ~ 0 0
execute if score .rotation const matches 136..180 run summon interaction ~-0.3 ~1 ~ {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_item", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches 136..180 run summon interaction ~0.3 ~1 ~ {NoGravity:1b,Silent:1b,width:0.5f,height:0.5f,response:1b,Tags:["target_interaction_reforge", "inputitem","finit","forge_tag"]}
execute if score .rotation const matches 136..180 run summon item_display ~-0.3 ~1 ~ {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"white","italic":false,"text":"Item"},width:1f,height:1.5f,billboard:"vertical",item_display:"fixed",Tags:["target_type_item", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches 136..180 run summon item_display ~0.3 ~1 ~ {NoGravity:1b,Silent:1b,CustomNameVisible:1b,CustomName:{"bold":false,"color":"aqua","italic":false,"text":"Forge"},width:1f,height:1.5f,billboard:"fixed",item_display:"fixed",Tags:["target_type_reforge", "displayitem","finit","forge_tag"],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.25f,0f],scale:[0.3f,0.3f,0.3f]},item:{id:"minecraft:structure_void",count:1,components:{"minecraft:item_model":"minecraft:air"}}}
execute if score .rotation const matches 136..180 run summon block_display ~-0.3 ~1 ~ {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:smooth_stone_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches 136..180 run summon block_display ~0.3 ~1 ~ {Tags:["forge_tag","finit"],NoGravity:1b,Silent:1b,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.2f,0f,-0.2f],scale:[0.4f,0.2f,0.4f]},block_state:{Name:"minecraft:polished_deepslate_slab",Properties:{type:"bottom"}}}
execute if score .rotation const matches 136..180 as @n[tag=target_forge_display_item,tag=finit] at @s run tp @s ~ ~ ~ 0 0
execute if score .rotation const matches 136..180 run summon text_display ~-0.25 ~1.7 ~ {line_width:80,NoGravity:1b,Silent:1b,billboard:"vertical",shadow:0b,see_through:0b,alignment:"right",Tags:["target_type_displayname","finit","forge_tag"],text:[{"color":"green","italic":false,"text":""},{"bold":true,"color":"#00E600","italic":false,"text":""}],background:840017408,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.425f,0f,0f],scale:[0.5f,0.5f,0.5f]}}
execute if score .rotation const matches 136..180 run summon text_display ~0.5 ~1.5 ~ {line_width:200,background:-936168653,view_range:0.1f,width:1f,height:1f,billboard:"vertical",alignment:"left",Tags:["target_forge_display_text","finit","forge_tag"],text:{"color":"white","italic":false,"text":""},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[1f,0f,0f],scale:[0.5f,0.5f,0.5f]}}

summon marker ~ ~0.5 ~ {Tags:["forge_base","forge_tag","finit"],NoGravity:1b,Silent:1b}
execute at @s run data modify entity @e[tag=target_type_item,sort=nearest,limit=1] Rotation set value [90f,0f]
execute at @s run data modify entity @e[tag=target_type_reforge,sort=nearest,limit=1] Rotation set value [90f,0f]

#id Setup
execute as @e[tag=forge_tag,tag=finit] at @s run scoreboard players operation @s id = .global id


#forgeid setup for detection
execute at @s run scoreboard players operation @e[tag=forge_detection,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
execute at @s run scoreboard players operation @e[tag=target_interaction_item,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
execute at @s run scoreboard players operation @e[tag=target_type_item,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
execute at @s run scoreboard players operation @e[tag=target_forge_display_item,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
execute at @s run scoreboard players operation @e[tag=target_forge_display_text,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
scoreboard players add .global reforgeId 1
execute at @s run scoreboard players operation @e[tag=target_interaction_reforge,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
execute at @s run scoreboard players operation @e[tag=target_type_reforge,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
execute at @s run scoreboard players operation @e[tag=target_type_displayname,tag=finit,sort=nearest,limit=1] reforgeId = .global reforgeId
#execute at @s unless block ~ ~ ~ #minecraft:air run execute as @e[tag=finit] at @s run tp @s ~ ~-0.5 ~
execute at @s if score .rotation const matches 46..135 run setblock ~ ~ ~ minecraft:anvil[facing=north] destroy
execute at @s if score .rotation const matches -45..45 run setblock ~ ~ ~ minecraft:anvil[facing=west] destroy
execute at @s if score .rotation const matches -135..-46 run setblock ~ ~ ~ minecraft:anvil[facing=south] destroy
execute at @s if score .rotation const matches -180..-136 run setblock ~ ~ ~ minecraft:anvil[facing=east] destroy
execute at @s if score .rotation const matches 136..180 run setblock ~ ~ ~ minecraft:anvil[facing=east] destroy
execute if block ~ ~-1 ~ air run setblock ~ ~-1 ~ stone destroy
execute if block ~ ~-1 ~ water run setblock ~ ~-1 ~ stone destroy
playsound minecraft:block.anvil.place master @a ~ ~ ~ 1 0.8 0
playsound minecraft:block.enchantment_table.use master @a ~ ~ ~ 1 2 0
tag @e[tag=finit] remove finit
kill @s
tag @s remove init