if (!event.getBlock().isLiquid()) return;
Location loc = event.getToBlock().getLocation();
BlockState from = event.getBlock().getState();
BlockState to = event.getToBlock().getState();
MaterialData data = from.getData();
//Lava
if (from.getTypeId() == 10 || from.getTypeId() == 11) {
//Flowing into a normal block
if (fluidBlocks.contains(to.getTypeId())) {
data.setData((byte)(from.getRawData() + 1));
from.setData(data);
}
//Flowing into water
else if (to.getTypeId() == 8 || to.getTypeId() == 9) {
from.setTypeId(event.getFace() == BlockFace.DOWN?10:4);
data.setData((byte)0);
from.setData(data);
}
DataManager.addEntry(new BlockChangeEntry("Environment", DataType.LAVA_FLOW, loc, to, from));
}
//Water
else if (from.getTypeId() == 8 || from.getTypeId() == 9) {
//Normal block
if (fluidBlocks.contains(to.getTypeId())) {
data.setData((byte)(from.getRawData() + 1));
from.setData(data);
DataManager.addEntry(new BlockChangeEntry("Environment", DataType.WATER_FLOW, loc, to, from));
}
//If we are flowing over lava, cobble or obsidian will form