import * as mc from "@minecraft/server"

export class Tick {

    wait(ticks) {
  
      return new Promise((resolve) => { mc.system.waitTicks(ticks * 20).then(resolve) })
    
    
    }
    repeat(ticks, deathTime, callback) {

      const intervalId = mc.system.runInterval(() => { try { callback() } catch {} }, ticks * 20)

      if (deathTime !== "none") {

        mc.system.waitTicks(deathTime * 20).then(() => { mc.system.clearRun(intervalId) })


      }

      return {
        
        remove() {
          
          mc.system.clearRun(intervalId)
        
        
        }
      
      
      }


    }
  
  
}