diff --git a/src/main/java/pw/kaboom/extras/modules/block/BlockPhysics.java b/src/main/java/pw/kaboom/extras/modules/block/BlockPhysics.java index f92d2bd..680ffa6 100644 --- a/src/main/java/pw/kaboom/extras/modules/block/BlockPhysics.java +++ b/src/main/java/pw/kaboom/extras/modules/block/BlockPhysics.java @@ -48,14 +48,12 @@ class BlockPhysics implements Listener { for (int x = -radius; x <= radius; x++) { for (int y = -radius; y <= radius; y++) { for (int z = -radius; z <= radius; z++) { - if (blockCount < 300) { + if (blockCount < 200) { final Location blockLocation = new Location(world, block.getX() + x, block.getY() + y, block.getZ() + z); final Block coordBlock = world.getBlockAt(blockLocation); - if ((coordBlock.getType() == Material.LAVA || - coordBlock.getType() == Material.WATER || - coordBlock.getType() == Material.OBSIDIAN) && - block.getType() != coordBlock.getType()) { + if (coordBlock.isLiquid() || + coordBlock.getType() == Material.OBSIDIAN) { blockCount++; } @@ -71,13 +69,12 @@ class BlockPhysics implements Listener { @EventHandler void onBlockPhysics(BlockPhysicsEvent event) { - final Material material = event.getSourceBlock().getType(); + final Material material = event.getChangedType(); if (material == Material.FARMLAND) { event.setCancelled(true); - } else if (material == Material.LAVA || - material == Material.WATER) { - final Block block = event.getSourceBlock(); + } else if (event.getBlock().isLiquid()) { + final Block block = event.getBlock(); final World world = block.getWorld(); final int radius = 5; int blockCount = 0; @@ -85,12 +82,11 @@ class BlockPhysics implements Listener { for (int x = -radius; x <= radius; x++) { for (int y = -radius; y <= radius; y++) { for (int z = -radius; z <= radius; z++) { - if (blockCount < 300) { + if (blockCount < 200) { final Location blockLocation = new Location(world, block.getX() + x, block.getY() + y, block.getZ() + z); final Block coordBlock = world.getBlockAt(blockLocation); - if ((coordBlock.getType() == Material.LAVA || - coordBlock.getType() == Material.WATER || + if ((coordBlock.isLiquid() || coordBlock.getType() == Material.OBSIDIAN) && block.getType() != coordBlock.getType()) { blockCount++; @@ -107,7 +103,7 @@ class BlockPhysics implements Listener { } else if (Main.nonSolidBlockList.contains(material) || material == Material.AIR || material == Material.CAVE_AIR) { - final Block block = event.getSourceBlock(); + final Block block = event.getBlock(); final World world = block.getWorld(); final int radius = 5; int blockCount = 0; @@ -115,7 +111,7 @@ class BlockPhysics implements Listener { for (int x = -radius; x <= radius; x++) { for (int y = -radius; y <= radius; y++) { for (int z = -radius; z <= radius; z++) { - if (blockCount < 42) { + if (blockCount < 100) { final Location blockLocation = new Location(world, block.getX() + x, block.getY() + y, block.getZ() + z); final Block coordBlock = world.getBlockAt(blockLocation); @@ -136,61 +132,7 @@ class BlockPhysics implements Listener { } } } - } /*else if (Main.nonSolidDoubleBlockList.contains(material)) { - final Block block = event.getSourceBlock(); - - if (Main.nonSolidDoubleBlockList.contains(block.getRelative(BlockFace.DOWN).getType())) { - event.setCancelled(true); - } else if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR || - (Main.nonSolidWaterBlockList.contains(material) && - block.getRelative(BlockFace.DOWN).getType() == Material.WATER) || - (Main.nonSolidBlockList.contains(block.getRelative(BlockFace.DOWN).getType()) && - !Main.nonSolidDoubleBlockList.contains(block.getRelative(BlockFace.DOWN).getType()))) { - Material materialReplacement = Material.AIR; - - if (Main.nonSolidWaterBlockList.contains(material)) { - materialReplacement = Material.WATER; - } - - for (int y = block.getRelative(BlockFace.UP).getY(); y <= 256; y++) { - final World world = event.getBlock().getWorld(); - final Block coordBlock = world.getBlockAt(new Location(world, block.getX(), y, block.getZ())); - - if (Main.nonSolidDoubleBlockList.contains(coordBlock.getType()) || - (block.getType() == Material.KELP_PLANT && - coordBlock.getType() == Material.KELP)) { - coordBlock.setType(materialReplacement, false); - continue; - } - - break; - } - - event.setCancelled(true); - block.setType(materialReplacement, false); - } - } else if (Main.nonSolidSingularBlockList.contains(material)) { - final Block block = event.getSourceBlock(); - - if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR || - (Main.nonSolidWaterBlockList.contains(material) && - block.getRelative(BlockFace.DOWN).getType() == Material.WATER) || - Main.nonSolidBlockList.contains(block.getRelative(BlockFace.DOWN).getType())) { - if (block.getType() == Material.KELP && - block.getRelative(BlockFace.DOWN).getType() == Material.KELP_PLANT) { - return; - } - - Material materialReplacement = Material.AIR; - - if (Main.nonSolidWaterBlockList.contains(material)) { - materialReplacement = Material.WATER; - } - - event.setCancelled(true); - block.setType(materialReplacement, false); - } - }*/ + } } @EventHandler