Skip to content

Instantly share code, notes, and snippets.

View vznxyz's full-sized avatar
💎
🤫 😄

vznxyz

💎
🤫 😄
View GitHub Profile
@vznxyz
vznxyz / HopperAndChestFinder.kt
Created November 13, 2019 18:26
finds hoppers and chests starting from a hopper
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) {
@vznxyz
vznxyz / BlockFaceConversion.kt
Created November 10, 2019 17:39
BlockFace to yaw util
/**
* 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
@vznxyz
vznxyz / RegionMaker.kt
Created November 9, 2019 20:55
find ground level util
/**
* 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())) {
@vznxyz
vznxyz / Plugin.kt
Created October 6, 2019 19:00
Suppress bukkit 1.12 command dispatched async log
// 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")
}