ItemEvents.rightClicked('terminal:qixing', e => {
const { player, level } = e
const direction = player.getLookAngle().scale(10)
const newPos = player.position.add(direction)
const checkCollision = (x, y, z) => {
return !level.getBlock(x, y, z).isAir() ||
!level.getBlock(x, y+1, z).isAir()
}
if (!checkCollision(newPos.x, newPos.y, newPos.z)) {
player.playSound('entity.enderman.teleport', 1, 1)
player.teleport(newPos.x, newPos.y, newPos.z)
player.addItemCooldown('terminal:qixing', 200)
} else {
player.playSound('block.note_block.didgeridoo', 1, 0.5)
player.tell(Text.red("There are blocks that cannot be executed"))
}
})