SteamWar/BauSystem2.0
Archiviert
12
0

Fix ObserverTracerCommand

Fix ObserverTracer

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-06-20 13:04:13 +02:00
Ursprung 2c88381146
Commit cd80c0a741
3 geänderte Dateien mit 119 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -314,6 +314,8 @@ LOADTIMER_SUMARY_STATS_FREQ=§7Belade Frequenz: §e{0}/m§8, §7Schuss Frequenz:
# Observer
OBSERVER_HELP = §7Rechts-Klicke einen Observer um den Trace zu bekommen. Hierfür müssen Flammenpartikel an sein. Die Partikel werden im Block angezeigt.
OBSERVER_DELETE = §7Observer Trace gelöscht
OBSERVER_RETRACE_DONE = §7Observer Trace neu berechnet
OBSERVER_RETRACE_NO-TRACE = §7Kein Observer Trace zum neu berechnen
# Other
OTHER_ITEMS_TELEPORT_NAME=§eTeleporter

Datei anzeigen

@ -71,27 +71,30 @@ public class ObserverTracer {
seen.add(b.getLocation());
spawnParticle(player, b.getLocation(), b);
switch (b.getType()) {
case OBSERVER:
calculateObserver(b);
break;
default:
BlockData blockData = b.getBlockData();
if (blockData instanceof Door) {
if (((Door) blockData).getHalf() == Bisected.Half.BOTTOM) {
blockList.add(b.getLocation().add(0, 1, 0).getBlock());
} else {
blockList.add(b.getLocation().add(0, -1, 0).getBlock());
}
}
if (checkAllowed(b, blockData)) {
calculateSpecial(b);
break;
}
if (b.getType().isBlock() && b.getType().isSolid()) {
calculateSolidBlock(b);
}
break;
if (b.getType() == Material.OBSERVER) {
calculateObserver(b);
continue;
}
BlockData blockData = b.getBlockData();
if (blockData instanceof Fence) {
calculateSimple(b);
continue;
}
if (blockData instanceof Door) {
if (((Door) blockData).getHalf() == Bisected.Half.BOTTOM) {
blockList.add(b.getLocation().add(0, 1, 0).getBlock());
} else {
blockList.add(b.getLocation().add(0, -1, 0).getBlock());
}
}
if (checkAllowed(b, blockData)) {
calculateSpecial(b);
}
if (b.getType().isBlock() && b.getType().isSolid() && b.getType().isOccluding()) {
calculateSolidBlock(b);
}
}
}
@ -125,6 +128,27 @@ public class ObserverTracer {
blockList.add(b);
}
}
if (observer.getFacing() == BlockFace.UP) {
Location location = block.getLocation();
location.add(0, -2, 0);
if (location.getY() >= 0) {
Block b = location.getBlock();
if (b.getType() == Material.DROPPER || b.getType() == Material.DISPENSER) {
blockList.add(b);
}
}
}
if (observer.getFacing() != BlockFace.UP && observer.getFacing() != BlockFace.DOWN) {
Location location = block.getLocation();
BlockFace blockFace = observer.getFacing().getOppositeFace();
location.add(blockFace.getModX(), -1, blockFace.getModZ());
if (location.getY() >= 0) {
Block b = location.getBlock();
if (b.getType() == Material.DROPPER || b.getType() == Material.DISPENSER) {
blockList.add(b);
}
}
}
}
private void calculateRedstoneLamp(Block block) {
@ -161,21 +185,79 @@ public class ObserverTracer {
if (block.getType() == Material.REDSTONE_LAMP) {
return true;
}
if (block.getType() == Material.BELL) {
return true;
}
return blockData instanceof Door
|| blockData instanceof Gate
|| blockData instanceof NoteBlock
|| blockData instanceof CraftPoweredRail
|| blockData instanceof TrapDoor;
|| blockData instanceof TrapDoor
|| blockData instanceof GlassPane;
}
private void calculateSpecial(Block block) {
BlockData blockData = block.getBlockData();
Location blockLocation = block.getLocation();
if (blockData instanceof TrapDoor) {
TrapDoor trapDoor = (TrapDoor) blockData;
fence(trapDoor.getFacing().getOppositeFace(), blockLocation);
}
if (blockData instanceof Door) {
Door door = (Door) blockData;
fence(door.getFacing().getOppositeFace(), blockLocation);
fence(doorHinge(door.getFacing(), door.getHinge()), blockLocation);
}
calculateSimple(block);
}
private void fence(BlockFace current, Location location) {
Block b = location.clone().add(current.getModX(), current.getModY(), current.getModZ()).getBlock();
if (b.getBlockData() instanceof Fence || b.getBlockData() instanceof GlassPane) {
blockList.add(b);
}
}
private BlockFace doorHinge(BlockFace blockFace, Door.Hinge hinge) {
switch (blockFace) {
case WEST:
if (hinge == Door.Hinge.RIGHT) {
return BlockFace.NORTH;
} else {
return BlockFace.SOUTH;
}
case SOUTH:
if (hinge == Door.Hinge.RIGHT) {
return BlockFace.WEST;
} else {
return BlockFace.EAST;
}
case EAST:
if (hinge == Door.Hinge.RIGHT) {
return BlockFace.SOUTH;
} else {
return BlockFace.NORTH;
}
case NORTH:
if (hinge == Door.Hinge.RIGHT) {
return BlockFace.EAST;
} else {
return BlockFace.WEST;
}
default:
throw new SecurityException();
}
}
private void calculateSimple(Block block) {
Location blockLocation = block.getLocation();
for (BlockFace blockFace : ALLOWED) {
Location location = block.getLocation().add(blockFace.getModX(), blockFace.getModY(), blockFace.getModZ());
Location location = blockLocation.clone().add(blockFace.getModX(), blockFace.getModY(), blockFace.getModZ());
Block b = location.getBlock();
if (b.getType() == Material.OBSERVER) {
Observer blockData = (Observer) b.getBlockData();
if (blockData.getFacing() == blockFace.getOppositeFace()) {
Observer current = (Observer) b.getBlockData();
if (current.getFacing() == blockFace.getOppositeFace()) {
blockList.add(b);
}
}

Datei anzeigen

@ -44,4 +44,14 @@ public class ObserverTracerCommand extends SWCommand {
BauSystem.MESSAGE.send("OBSERVER_DELETE", p);
}
@Register(value = "retrace")
public void retrace(Player p) {
if (ObserverTracerListener.observerTracerMap.containsKey(p)) {
BauSystem.MESSAGE.send("OBSERVER_RETRACE_NO-TRACE", p);
return;
}
ObserverTracerListener.observerTracerMap.get(p).trace();
BauSystem.MESSAGE.send("OBSERVER_RETRACE_DONE", p);
}
}