From 952d2f03dc2111f6fea9d0fa100c69838e2bf5ea Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 18 Sep 2023 17:18:27 +0200 Subject: [PATCH] Add -testblockdestroy and -testblockdestroyonly as Trace Show options Signed-off-by: yoyosource --- .../bausystem/features/tracer/record/AutoTraceRecorder.java | 3 ++- .../steamwar/bausystem/features/tracer/record/Recorder.java | 5 +++-- .../features/tracer/record/SimpleTraceRecorder.java | 3 ++- .../bausystem/features/tracer/record/TraceRecorder.java | 2 +- .../bausystem/features/tracer/show/EntityShowMode.java | 4 ++++ .../de/steamwar/bausystem/features/tracer/show/Record.java | 4 ++++ .../bausystem/features/tracer/show/ShowModeParameter.java | 5 +++++ .../features/tracer/show/ShowModeParameterType.java | 1 + 8 files changed, 22 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index f0eeab8c..35c6c497 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -93,13 +93,14 @@ public abstract class AutoTraceRecorder implements TraceRecorder { } @Override - public final void explode(TNTPrimed tntPrimed, boolean inBuildRegion) { + public final void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion) { if (!recording && shouldStartRecording(StartType.EXPLODE)) { startRecording(); } if (recording) { Record.TNTRecord tntRecord = getRecord(tntPrimed); if (inBuildRegion) tntRecord.setInBuildArea(true); + if (inTestblockRegion) tntRecord.setInTestblockArea(true); tntRecord.explode(tntPrimed); } lastExplosion = 0; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 7dd12060..896b6ec5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -65,7 +65,7 @@ public class Recorder implements Listener { } @Override - public void explode(TNTPrimed tntPrimed, boolean b) { + public void explode(TNTPrimed tntPrimed, boolean inBuildArea, boolean inTestblockRegion) { } @Override @@ -155,7 +155,8 @@ public class Recorder implements Listener { TraceRecorder traceRecorder = get((TNTPrimed) entity); Region region = tntTraceRecorderMap.get((TNTPrimed) entity); boolean inBuildRegion = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); - traceRecorder.explode((TNTPrimed) entity, inBuildRegion); + boolean inTestblockRegion = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)); + traceRecorder.explode((TNTPrimed) entity, inBuildRegion, inTestblockRegion); tntTraceRecorderMap.remove(entity); tick(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java index 1077f59a..a5b7b77e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java @@ -65,9 +65,10 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { } @Override - public void explode(TNTPrimed tntPrimed, boolean inBuildRegion) { + public void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion) { Record.TNTRecord tntRecord = getRecord(tntPrimed); if (inBuildRegion) tntRecord.setInBuildArea(true); + if (inTestblockRegion) tntRecord.setInTestblockArea(true); tntRecord.explode(tntPrimed); recordMap.remove(tntPrimed); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java index bb2a1325..20279fa7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java @@ -34,7 +34,7 @@ public interface TraceRecorder { } void spawn(TNTPrimed tntPrimed); void tick(TNTPrimed tntPrimed); - void explode(TNTPrimed tntPrimed, boolean inBuildRegion); + void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion); default void tick() { } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java index 0828ce73..657a44c0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java @@ -84,6 +84,10 @@ public class EntityShowMode implements ShowMode { return; } + if (showModeParameter.isTestblockDestroyOnly() && !position.getRecord().isInTestblockArea()) { + return; + } + if (showModeParameter.isMicroMotion() && !position.getRecord().isHasMicroMotion()) { return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java index 8314b640..b091d6ef 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java @@ -93,6 +93,10 @@ public class Record { @Setter private boolean inBuildArea = false; + @Getter + @Setter + private boolean inTestblockArea = false; + @Getter private boolean hasMicroMotion = false; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java index 802c1eba..3b83151b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java @@ -31,6 +31,7 @@ public class ShowModeParameter { private boolean ticks = false; private boolean count = false; private boolean buildDestroyOnly = false; + private boolean testblockDestroyOnly = false; private boolean ticksSinceStart = false; private boolean microMotion = false; @@ -66,6 +67,10 @@ public class ShowModeParameter { this.buildDestroyOnly = true; } + public void enableTestblockDestroyOnly() { + this.testblockDestroyOnly = true; + } + public void enableTicksSinceStart() { this.ticksSinceStart = true; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java index a4f83958..2d957ddb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java @@ -41,6 +41,7 @@ public enum ShowModeParameterType { TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE", "COUNT", "TICKS_SINCE_START"), COUNT(ShowModeParameter::enableCount, Arrays.asList("-count", "-c"), "TICKS", "TICKS_SINCE_START"), BUILD_DESTROY_ONLY(ShowModeParameter::enableBuildDestroyOnly, Arrays.asList("-builddestroy", "-builddestoryonly"), "WATER"), + TESTBLOCK_DESTROY_ONLY(ShowModeParameter::enableTestblockDestroyOnly, Arrays.asList("-testblockdestroy", "-testblockdestroyonly"), "WATER"), TICKS_SINCE_START(ShowModeParameter::enableTicksSinceStart, Arrays.asList("-tickssincestart", "-tss"), "TICKS", "COUNT"), MICROMOTION(ShowModeParameter::enableMicroMotion, Arrays.asList("-micromotion", "-micro", "-m")), ;