From 12d0ecbf0ec4115b30ad97fc8c1d2128639a8b7f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 6 Sep 2023 21:27:21 +0200 Subject: [PATCH] Setup Record for Simulator use and Trace use Signed-off-by: yoyosource --- .../tracer/record/AutoTraceRecorder.java | 6 +++--- .../features/tracer/record/Recorder.java | 3 ++- .../tracer/record/SimpleTraceRecorder.java | 6 +++--- .../bausystem/features/tracer/show/Record.java | 16 +++++++++------- .../features/tracer/show/TraceShowManager.java | 2 +- 5 files changed, 18 insertions(+), 15 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..671d654c 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 @@ -81,14 +81,14 @@ public abstract class AutoTraceRecorder implements TraceRecorder { startRecording(); } if (recording) { - getRecord(tntPrimed).source(tntPrimed); + getRecord(tntPrimed).source(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks()); } } @Override public final void tick(TNTPrimed tntPrimed) { if (recording) { - getRecord(tntPrimed).location(tntPrimed); + getRecord(tntPrimed).location(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks()); } } @@ -100,7 +100,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder { if (recording) { Record.TNTRecord tntRecord = getRecord(tntPrimed); if (inBuildRegion) tntRecord.setInBuildArea(true); - tntRecord.explode(tntPrimed); + tntRecord.explode(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks()); } 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..dc7b06ac 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 @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.tracer.record; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.StoredRecords; +import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; @@ -100,7 +101,7 @@ public class Recorder implements Listener { public void set(Region region, TraceRecorder traceRecorder) { regionTraceRecorderMap.put(region, traceRecorder); traceRecorder.recordSupplier(() -> { - Record record = new Record(region); + Record record = new Record(region, TraceShowManager::show); StoredRecords.add(region, record); return record; }); 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..e85847f1 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 @@ -56,19 +56,19 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { @Override public void spawn(TNTPrimed tntPrimed) { - getRecord(tntPrimed).source(tntPrimed); + getRecord(tntPrimed).source(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks()); } @Override public void tick(TNTPrimed tntPrimed) { - getRecord(tntPrimed).location(tntPrimed); + getRecord(tntPrimed).location(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks()); } @Override public void explode(TNTPrimed tntPrimed, boolean inBuildRegion) { Record.TNTRecord tntRecord = getRecord(tntPrimed); if (inBuildRegion) tntRecord.setInBuildArea(true); - tntRecord.explode(tntPrimed); + tntRecord.explode(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks()); recordMap.remove(tntPrimed); } 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 ca7f7156..7b22a424 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 @@ -31,6 +31,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.function.BiConsumer; @RequiredArgsConstructor public class Record { @@ -38,6 +39,7 @@ public class Record { @Getter private final List tnt = new ArrayList<>(); private final Region region; + private final BiConsumer showFunction; public int size() { return tnt.size(); @@ -102,16 +104,16 @@ public class Record { this.region = region; } - public void source(TNTPrimed tntPrimed) { - add(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks(), true, false); + public void source(Vector location, Vector velocity, int fuseTicks) { + add(location, velocity, fuseTicks, true, false); } - public void location(TNTPrimed tntPrimed) { - add(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks(), false, false); + public void location(Vector location, Vector velocity, int fuseTicks) { + add(location, velocity, fuseTicks, false, false); } - public void explode(TNTPrimed tntPrimed) { - add(tntPrimed.getLocation().toVector(), tntPrimed.getVelocity(), tntPrimed.getFuseTicks(), false, true); + public void explode(Vector location, Vector velocity, int fuseTicks) { + add(location, velocity, fuseTicks, false, true); record.checkMicroMotion(); } @@ -125,7 +127,7 @@ public class Record { position = new TNTPosition(this, location, fuseTicks, positions.get(positions.size() - 1).getLocation(), velocity, lastVelocity, source, exploded); } positions.add(position); - TraceShowManager.show(region, position); + record.showFunction.accept(region, position); } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index 5cebaa1c..22d6bc9a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -90,7 +90,7 @@ public class TraceShowManager implements Listener { } /* Only to be called by record */ - static void show(Region region, TNTPosition tnt) { + public static void show(Region region, TNTPosition tnt) { Map> regionalShowModes = showModes.get(region); if (regionalShowModes == null) { return;