SteamWar/FightSystem
Archiviert
13
1

Adding Better Tracking

Dieser Commit ist enthalten in:
Chaoscaot 2020-11-27 21:31:39 +01:00
Ursprung afa2217ce3
Commit 8c93f446df

Datei anzeigen

@ -63,7 +63,7 @@ public class ArrowStopper implements StateDependent {
LAST_LOCATION.put(entity, ((Player) ((AbstractArrow) entity).getShooter()).getEyeLocation());
int distance = (int) Math.ceil(entity.getLocation().toVector().distance(LAST_LOCATION.get(entity).toVector()) * 1.414213562);
try {
checkBlock(entity.getFacing().getOppositeFace(), entity.getLocation().getBlock(), distance, entity.getLocation().getBlockY() - LAST_LOCATION.get(entity).getBlockY());
checkBlock(entity.getFacing().getOppositeFace(), entity.getLocation().getBlock(), LAST_LOCATION.get(entity).getBlock(), distance, entity.getLocation().getBlockY() - LAST_LOCATION.get(entity).getBlockY());
} catch (TechHiddenBlock techHiddenBlock) {
entity.remove();
}
@ -101,16 +101,20 @@ public class ArrowStopper implements StateDependent {
}
}
private void checkBlock(BlockFace face, Block block, int i, int lastdown) throws TechHiddenBlock {
private void checkBlock(BlockFace face, Block block, Block start, int i, int lastdown) throws TechHiddenBlock {
Bukkit.getOnlinePlayers().forEach(player -> player.sendBlockChange(block.getLocation(), Material.RED_STAINED_GLASS.createBlockData()));
if(Config.HiddenBlocks.contains(blockToId(block)))
throw new TechHiddenBlock();
if(i != Math.abs(lastdown))
checkBlock(face, block.getRelative(face), i - 1, lastdown);
if(lastdown != 0) {
boolean negativ = lastdown < 0;
BlockFace toFace = negativ?BlockFace.UP:BlockFace.DOWN;
checkBlock(face, block.getRelative(toFace), i - 1, lastdown + (negativ?1:-1));
checkBlock(face, block.getRelative(toFace), start, i - 1, lastdown + (negativ?1:-1));
return;
}
if(i != 0) {
checkBlock(face, block.getRelative(face), start, i - 1, lastdown);
}
}