This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun findHoppersAndChests(block: Block, | |
| lambda: (Set<Hopper>, Set<Chest>) -> Unit, | |
| hoppers: HashSet<Hopper> = hashSetOf(block.state.data as Hopper), | |
| chests: HashSet<Chest> = hashSetOf()) { | |
| when (block.type) { | |
| Material.HOPPER -> { | |
| val hopper = block.state.data as org.bukkit.material.Hopper | |
| val relative = block.getRelative(hopper.facing) | |
| if (relative.type == Material.CHEST || relative.type == Material.TRAPPED_CHEST) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Converts a [BlockFace] to a yaw value. | |
| */ | |
| private fun faceToYaw(face: BlockFace): Float { | |
| return when (face) { | |
| BlockFace.NORTH -> 180.0F | |
| BlockFace.NORTH_NORTH_EAST -> 202.5F | |
| BlockFace.NORTH_EAST -> 225.0F | |
| BlockFace.EAST_NORTH_EAST -> 247.5F | |
| BlockFace.EAST -> 270.0F |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Tries to find the most probable ground level for a given [point]. | |
| */ | |
| private fun findGroundLevel(point: Point3D): Int { | |
| for (y in 0..5) { | |
| // path visualization is always going to be down | |
| val block = startLoc.world.getBlockAt(point.x, point.y - y, point.z) | |
| // don't put block updates in the air | |
| if (NON_SOLID_BLOCKS.contains(block.type.id.toByte())) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // hijack logging filter to suppress the server's complaints about commands being dispatched async | |
| Bukkit.getLogger().setFilter { | |
| return@setFilter !it.message.contains("Command Dispatched Async") | |
| } |