import {ancientShieldTime,HeavySocks,BattleCry,} from "./items/artifacts/artifacts.js"
import {bouncingBootsGround,bouncingBootsAir} from "./items/armors/armors_effects.js"
import {system} from "@minecraft/server"


export function fakeEvents(player){

    //if it works, don't touch it
    if(player.isSneaking)
        onSneak(player)
    else if(player.hasTag('sneak'))
        player.removeTag('sneak')

    if(player.isOnGround)
        onGround(player)
    else if(player.hasTag('ground'))
    {
        system.runTimeout(() => {//runtimeout pour empecher les cloud socks de buguer
            player.removeTag('ground')
        },2)
    }
        

    if(player.getVelocity().y<0)
        onFall(player)
    else if(player.hasTag('fall'))
        player.removeTag('fall')
        
}


function onSneak(player)
{
    if(!player.hasTag('sneak'))
    {
        
        player.addTag('sneak')
        ancientShieldTime(player)
        BattleCry(player)
    }
}
function onGround(player)
{
    if(!player.hasTag('ground'))
    {
        
        player.removeTag('already_double_jump')
        player.addTag('ground')
        bouncingBootsGround(player)
        HeavySocks(player)
    }
}
function onFall(player)
{
    if(!player.hasTag('fall'))
    {
        player.addTag('fall')
        bouncingBootsAir(player)
    }
}

