diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index 44c26333..0e30436d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -88,6 +88,14 @@ public class TraceRecorder implements Listener { } } + public void addAutoTraceRegion(Region region) { + autoTraceRegions.add(region); + } + + public void removeAutoTraceRegion(Region region) { + autoTraceRegions.remove(region); + } + /** * Makes checks for whether auto traces finished */ @@ -137,6 +145,7 @@ public class TraceRecorder implements Listener { TraceRecordingWrapper wrappedTrace = activeTraces.get(region); for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) { TNTPoint record = record(tnt, wrappedTrace, Collections.emptyList()); + if (record == null) continue; wrappedTrace.addRecord(record); } wrappedTrace.commitRecorded(); @@ -153,6 +162,12 @@ public class TraceRecorder implements Listener { */ private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List destroyedBlocks) { List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); + // Failsave for tnt entering unloaded chunks + if (history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) { + removeFromRecording(tntPrimed); + return null; + } + int tntID; if (history.size() == 0) { @@ -249,4 +264,19 @@ public class TraceRecorder implements Listener { activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList())); } + + /** + * Methode to be used if a tnt should be removed for internal or technical reasons + * + * @param tnt tnt to remove + * @return whether the tnt was tracked beforehand or not + */ + public boolean removeFromRecording(TNTPrimed tnt) { + Region region = tntSpawnRegion.getOrDefault(tnt, null); + if (region == null) return false; + trackedTNT.get(region).remove(tnt); + tntSpawnRegion.remove(tnt); + historyMap.remove(tnt); + return true; + } }