forked from LogBlock/LogBlock
Updated water/lava flow logging
This commit is contained in:
@@ -25,30 +25,51 @@ public class FluidFlowLogging extends LoggingListener
|
|||||||
public void onBlockFromTo(BlockFromToEvent event) {
|
public void onBlockFromTo(BlockFromToEvent event) {
|
||||||
final WorldConfig wcfg = getWorldConfig(event.getBlock().getWorld());
|
final WorldConfig wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||||
if (!event.isCancelled() && wcfg != null) {
|
if (!event.isCancelled() && wcfg != null) {
|
||||||
|
final Block to = event.getToBlock();
|
||||||
final int typeFrom = event.getBlock().getTypeId();
|
final int typeFrom = event.getBlock().getTypeId();
|
||||||
final int typeTo = event.getToBlock().getTypeId();
|
final int typeTo = to.getTypeId();
|
||||||
|
final boolean canFlow = typeTo == 0 || nonFluidProofBlocks.contains(typeTo);
|
||||||
if (typeFrom == 10 || typeFrom == 11) {
|
if (typeFrom == 10 || typeFrom == 11) {
|
||||||
if (typeTo == 0) {
|
if (canFlow) {
|
||||||
if (wcfg.isLogging(Logging.LAVAFLOW))
|
if (isSurroundedByWater(to) && event.getBlock().getData() <= 2)
|
||||||
consumer.queueBlockPlace("LavaFlow", event.getToBlock().getLocation(), 10, (byte)(event.getBlock().getData() + 1));
|
consumer.queueBlockReplace("LavaFlow", to.getState(), 4, (byte)0);
|
||||||
} else if (nonFluidProofBlocks.contains(typeTo))
|
else if (typeTo == 0) {
|
||||||
consumer.queueBlockReplace("LavaFlow", event.getToBlock().getState(), 10, (byte)(event.getBlock().getData() + 1));
|
if (wcfg.isLogging(Logging.LAVAFLOW))
|
||||||
else if (typeTo == 8 || typeTo == 9)
|
consumer.queueBlockPlace("LavaFlow", to.getLocation(), 10, (byte)(event.getBlock().getData() + 1));
|
||||||
if (event.getFace() == BlockFace.DOWN)
|
|
||||||
consumer.queueBlockReplace("LavaFlow", event.getToBlock().getState(), 10, (byte)0);
|
|
||||||
else
|
|
||||||
consumer.queueBlockReplace("LavaFlow", event.getToBlock().getState(), 4, (byte)0);
|
|
||||||
} else if (typeFrom == 8 || typeFrom == 9)
|
|
||||||
if (typeTo == 0 || nonFluidProofBlocks.contains(typeTo)) {
|
|
||||||
if (typeTo == 0) {
|
|
||||||
if (wcfg.isLogging(Logging.WATERFLOW))
|
|
||||||
consumer.queueBlockPlace("WaterFlow", event.getToBlock().getLocation(), 8, (byte)(event.getBlock().getData() + 1));
|
|
||||||
} else
|
} else
|
||||||
consumer.queueBlockReplace("WaterFlow", event.getToBlock().getState(), 8, (byte)(event.getBlock().getData() + 1));
|
consumer.queueBlockReplace("LavaFlow", to.getState(), 10, (byte)(event.getBlock().getData() + 1));
|
||||||
final Block lower = event.getToBlock().getRelative(BlockFace.DOWN);
|
} else if (typeTo == 8 || typeTo == 9)
|
||||||
if (lower.getTypeId() == 10 || lower.getTypeId() == 11)
|
if (event.getFace() == BlockFace.DOWN)
|
||||||
consumer.queueBlockReplace("WaterFlow", lower.getState(), lower.getData() == 0 ? 49 : 4, (byte)0);
|
consumer.queueBlockReplace("LavaFlow", to.getState(), 1, (byte)0);
|
||||||
}
|
else
|
||||||
|
consumer.queueBlockReplace("LavaFlow", to.getState(), 4, (byte)0);
|
||||||
|
} else if (typeFrom == 8 || typeFrom == 9) {
|
||||||
|
if (typeTo == 0) {
|
||||||
|
if (wcfg.isLogging(Logging.WATERFLOW))
|
||||||
|
consumer.queueBlockPlace("WaterFlow", to.getLocation(), 8, (byte)(event.getBlock().getData() + 1));
|
||||||
|
} else if (nonFluidProofBlocks.contains(typeTo))
|
||||||
|
consumer.queueBlockReplace("WaterFlow", to.getState(), 8, (byte)(event.getBlock().getData() + 1));
|
||||||
|
else if (typeTo == 10 || typeTo == 11)
|
||||||
|
if (to.getData() == 0)
|
||||||
|
consumer.queueBlockReplace("WaterFlow", to.getState(), 49, (byte)0);
|
||||||
|
else if (event.getFace() == BlockFace.DOWN)
|
||||||
|
consumer.queueBlockReplace("LavaFlow", to.getState(), 1, (byte)0);
|
||||||
|
if (typeTo == 0 || nonFluidProofBlocks.contains(typeTo))
|
||||||
|
for (final BlockFace face : new BlockFace[]{BlockFace.DOWN, BlockFace.NORTH, BlockFace.WEST, BlockFace.EAST, BlockFace.SOUTH}) {
|
||||||
|
final Block lower = to.getRelative(face);
|
||||||
|
if (lower.getTypeId() == 10 || lower.getTypeId() == 11)
|
||||||
|
consumer.queueBlockReplace("WaterFlow", lower.getState(), lower.getData() == 0 ? 49 : 4, (byte)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isSurroundedByWater(Block block) {
|
||||||
|
for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.WEST, BlockFace.EAST, BlockFace.SOUTH}) {
|
||||||
|
final int type = block.getRelative(face).getTypeId();
|
||||||
|
if (type == 8 || type == 9)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user