execute positioned 1500 42 1500 as @e[distance=..70,nbt={OnGround:1b}] at @s if entity @e[type=minecraft:armor_stand,scores={conveyormove=1..},limit=1,tag=producer.base] run function ws:work/misc/producer/base.move
execute positioned as 68bac6ee-ab18-4a10-9947-a34d6b4c1a08 run scoreboard players set @n[tag=tovar,distance=..1] itemtier 0
item replace entity @e[scores={itemtier=1}] container.0 with coal[minecraft:custom_data={tier:1}]
execute at @e[type=item,scores={itemtier=1}] run particle minecraft:portal ~ ~0.3 ~ 0.01 0.01 0.01 0.1 2
item replace entity @e[type=item,scores={itemtier=2}] container.0 with coal[minecraft:custom_data={tier:2}]
execute at @e[type=item,scores={itemtier=2}] run particle minecraft:happy_villager ~ ~0.3 ~ 0.01 0.01 0.01 3 3
item replace entity @e[type=item,scores={itemtier=3}] container.0 with coal[minecraft:custom_data={tier:3}]
execute at @e[type=item,scores={itemtier=3..}] run particle minecraft:dripping_lava ~ ~0.3 ~ 0.1 0.1 0.1 3 3
execute as @e[tag=tovar,type=item] run data merge entity @s {Age:0s}

execute if items block 1518 39 1488 container.* * as @a[team=seller,tag=base] run function ws:work/misc/producer/base.pay
execute if items block 1518 41 1488 container.* * unless items block 1518 41 1488 container.* coal run function ws:work/misc/producer/base.block
execute positioned 1516.33 41.75 1486.41 align xyz run tp @e[type=item,dx=0] 1516.5 42.00 1488.5
execute positioned 1518 43 1488 as @a[dx=0,gamemode=!creative] run damage @s 10 minecraft:cramming

execute if block 1483 44 1511 minecraft:lever[powered=true] run scoreboard players add .error error 1
execute if score .error error matches 2400.. store result score .error base.error run random value 1..3
execute if score .error base.error matches 3 as @a[tag=base,team=seller] run function ws:work/misc/producer/base.error
execute if score .error error matches 2400.. run scoreboard players set .error error 0

execute if block 1483 44 1511 minecraft:lever[powered=true] run scoreboard players add @e[type=minecraft:armor_stand,tag=producer.base] conveyor 1
execute if block 1483 44 1511 minecraft:lever[powered=true] if score @e[type=minecraft:armor_stand,limit=1,tag=producer.base] conveyor matches 1..2 run item replace entity @e[type=minecraft:item_frame,tag=conveyor] container.0 with minecraft:terracotta[minecraft:custom_model_data=1001]
execute if block 1483 44 1511 minecraft:lever[powered=true] if score @e[type=minecraft:armor_stand,limit=1,tag=producer.base] conveyor matches 3..4 run item replace entity @e[type=minecraft:item_frame,tag=conveyor] container.0 with minecraft:terracotta[minecraft:custom_model_data=1002]
scoreboard players set @e[scores={conveyor=4..}] conveyor 0
execute if block 1483 44 1511 minecraft:lever[powered=true] run return run scoreboard players set @e[type=minecraft:armor_stand,limit=1,tag=producer.base] conveyormove 1
scoreboard players set @e[type=minecraft:armor_stand,limit=1,tag=producer.base] conveyormove 0