SteamWar/FightSystem
Archiviert
13
1

GameMode 1 Spectator #190

Manuell gemergt
Lixfel hat 6 Commits von gm1Spectator nach master 2020-10-29 19:57:48 +01:00 zusammengeführt
4 geänderte Dateien mit 48 neuen und 4 gelöschten Zeilen
Nur Änderungen aus Commit 97dd9794ef werden angezeigt - Alle Commits anzeigen

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

@ -76,7 +76,7 @@ public class FightScoreboard {
objective.setDisplayName(fightTeam.getColoredName()); objective.setDisplayName(fightTeam.getColoredName());
fightTeam.getPlayers().forEach(fp -> { fightTeam.getPlayers().forEach(fp -> {
if(fp.isLiving()) if(fp.isLiving())
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth()); objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) Math.ceil(fp.getPlayer().getHealth()));
}); });
} }

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);
}
}
} }