SteamWar/BauSystem2.0
Archiviert
12
0

tracer/bug-354-Fix-smaller-trace-issues #242

Zusammengeführt
YoyoNow hat 9 Commits von tracer/bug-354-Fix-smaller-trace-issues nach master 2024-04-28 12:15:18 +02:00 zusammengeführt
Nur Änderungen aus Commit 7fa31704f4 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -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 * Makes checks for whether auto traces finished
*/ */
@ -137,6 +145,7 @@ public class TraceRecorder implements Listener {
TraceRecordingWrapper wrappedTrace = activeTraces.get(region); TraceRecordingWrapper wrappedTrace = activeTraces.get(region);
for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) { for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) {
TNTPoint record = record(tnt, wrappedTrace, Collections.emptyList()); TNTPoint record = record(tnt, wrappedTrace, Collections.emptyList());
if (record == null) continue;
wrappedTrace.addRecord(record); wrappedTrace.addRecord(record);
} }
wrappedTrace.commitRecorded(); wrappedTrace.commitRecorded();
@ -153,6 +162,12 @@ public class TraceRecorder implements Listener {
*/ */
private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List<Block> destroyedBlocks) { private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List<Block> destroyedBlocks) {
List<TNTPoint> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); List<TNTPoint> 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; int tntID;
if (history.size() == 0) { 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())); 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;
}
} }