import { world } from "@minecraft/server";


world.beforeEvents.itemUseOn.subscribe((event) => {

    if (event.itemStack.typeId === "item:ascendant_and_steel") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function tetra6");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y-2)+ " "+ event.block.location.z+ " run function tetra5");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function tetra1");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function tetra2");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function tetra3");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function tetra4");
        }  
    }
    if (event.itemStack.typeId === "item:bottomless_water_bucket") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~1 ~ ~ ~ ~ flowing_water replace air");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~-1 ~ ~ ~ ~ flowing_water replace air");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~-1 ~ ~ ~-1 flowing_water replace air");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~1 ~ ~ ~1 flowing_water replace air");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~ ~ ~1 ~ ~ flowing_water replace air");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~-1 ~ ~ ~-1 ~ ~ flowing_water replace air");
        }  
    }
    if (event.itemStack.typeId === "item:bottomless_water_bucket") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~1 ~ ~ ~ ~ flowing_water replace water");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~-1 ~ ~ ~ ~ flowing_water replace water");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~-1 ~ ~ ~-1 flowing_water replace water");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~1 ~ ~ ~1 flowing_water replace water");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~ ~ ~1 ~ ~ flowing_water replace water");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~-1 ~ ~ ~-1 ~ ~ flowing_water replace water");
        }  
    }
    if (event.itemStack.typeId === "item:bottomless_powdered_snow_bucket") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~1 ~ ~ ~ ~ powder_snow replace air");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~-1 ~ ~ ~ ~ powder_snow replace air");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~-1 ~ ~ ~-1 powder_snow replace air");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~1 ~ ~ ~1 powder_snow replace air");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~ ~ ~1 ~ ~ powder_snow replace air");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~-1 ~ ~ ~-1 ~ ~ powder_snow replace air");
        }  
    }
    if (event.itemStack.typeId === "item:ember_and_steel") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~1 ~1 ~-1 ~-1 ~-1 fire replace air");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y-2)+ " "+ event.block.location.z+ " run fill ~1 ~1 ~1 ~-1 ~-1 ~-1 fire replace air");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~1 ~1 ~-1 ~-1 ~-1 fire replace air");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~1 ~1 ~-1 ~-1 ~-1 fire replace air");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~1 ~1 ~-1 ~-1 ~-1 fire replace air");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~1 ~1 ~-1 ~-1 ~-1 fire replace air");
        }  
    }
    if (event.itemStack.typeId === "item:flint_and_netherite") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~1 ~ ~ ~ ~ fire replace air");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y-2)+ " "+ event.block.location.z+ " run fill ~ ~1 ~ ~ ~ ~ fire replace air");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~-1 ~ ~ ~-1 fire replace air");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~1 ~ ~ ~1 fire replace air");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~ ~ ~1 ~ ~ fire replace air");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~-1 ~ ~ ~-1 ~ ~ fire replace air");
        }  
    }
    if (event.itemStack.typeId === "item:bottomless_lava_bucket") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~1 ~ ~ ~ ~ flowing_lava replace air");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~-1 ~ ~ ~ ~ flowing_lava replace air");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~-1 ~ ~ ~-1 flowing_lava replace air");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~1 ~ ~ ~1 flowing_lava replace air");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~ ~ ~1 ~ ~ flowing_lava replace air");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~-1 ~ ~ ~-1 ~ ~ flowing_lava replace air");
        }  
    }
    if (event.itemStack.typeId === "item:bottomless_lava_bucket") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~1 ~ ~ ~ ~ flowing_lava replace lava");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~-1 ~ ~ ~ ~ flowing_lava replace lava");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~-1 ~ ~ ~-1 flowing_lava replace lava");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~ ~ ~1 ~ ~ ~1 flowing_lava replace lava");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~1 ~ ~ ~1 ~ ~ flowing_lava replace lava");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run fill ~-1 ~ ~ ~-1 ~ ~ flowing_lava replace lava");
        }  
    }
    if (event.itemStack.typeId === "item:brimstone_and_steel") {
      
        

        if(event.blockFace=="Up"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function brim6");                                  
        }      
        
        if(event.blockFace=="Down"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y-2)+ " "+ event.block.location.z+ " run function brim5");
        }  
        
        if(event.blockFace=="North"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function brim1");
        }  

        if(event.blockFace=="South"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function brim2");
        }  

        if(event.blockFace=="East"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function brim3");
        }  

        if(event.blockFace=="West"){
            event.source.runCommandAsync("execute positioned "+ event.block.location.x+ " "+ (event.block.location.y)+ " "+ event.block.location.z+ " run function brim4");
        }  
    }
});