SteamWar/FightSystem
Archiviert
13
1

Merge pull request 'This should fix the waterlogged waterremover problem' (#195) from fixWaterlogged into master

Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Lixfel 2020-10-28 10:17:38 +01:00
Commit 525804016e
3 geänderte Dateien mit 47 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -37,4 +37,24 @@ class WaterRemover_14 {
return ((Waterlogged) data).isWaterlogged(); return ((Waterlogged) data).isWaterlogged();
} }
static boolean removeWater(Block block){
if(block.getType() == Material.WATER){
block.setType(Material.AIR);
return true;
}
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
Waterlogged waterlogged = (Waterlogged) data;
if(waterlogged.isWaterlogged()){
waterlogged.setWaterlogged(false);
block.setBlockData(waterlogged);
return true;
}
return false;
}
} }

Datei anzeigen

@ -29,4 +29,12 @@ public class WaterRemover_8 {
Material type = block.getType(); Material type = block.getType();
return type == Material.WATER || type == Material.STATIONARY_WATER; return type == Material.WATER || type == Material.STATIONARY_WATER;
} }
static boolean removeWater(Block block){
if(isWater(block)){
block.setType(Material.AIR);
return true;
}
return false;
}
} }

Datei anzeigen

@ -49,14 +49,15 @@ public class WaterRemover {
} }
private static void checkBlock(Block b, int startX, int startY, int startZ) throws IsAnOcean { private static void checkBlock(Block b, int startX, int startY, int startZ) throws IsAnOcean {
if(!isWater(b)) if(!removeWater(b))
return; return;
// If distance to original block is greater than 20 // If distance to original block is greater than 20
if(Math.abs(startX - b.getX()) + Math.abs(startY - b.getY() + Math.abs(startZ - b.getZ())) >= 20) if(Math.abs(startX - b.getX()) + Math.abs(startY - b.getY() + Math.abs(startZ - b.getZ())) >= 20){
b.setType(Material.WATER);
throw new IsAnOcean(); throw new IsAnOcean();
}
b.setType(Material.AIR);
try{ try{
checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ); checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ);
checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ); checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ);
@ -84,4 +85,19 @@ public class WaterRemover {
return WaterRemover_14.isWater(block); return WaterRemover_14.isWater(block);
} }
} }
public static boolean removeWater(Block block){
//checks for water and removes it, if present
switch(Core.getVersion()){
case 8:
case 9:
case 10:
case 12:
return WaterRemover_8.removeWater(block);
case 14:
case 15:
default:
return WaterRemover_14.removeWater(block);
}
}
} }