SteamWar/FightSystem
Archiviert
13
1

Arrows Stopping in Techhider Blocks #208

Manuell gemergt
Lixfel hat 17 Commits von arrow-in-techhider nach master 2021-01-02 09:20:42 +01:00 zusammengeführt
Nur Änderungen aus Commit 8c93f446df werden angezeigt - Alle Commits anzeigen

Datei anzeigen

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