SteamWar/BauSystem2.0
Archiviert
12
0

Trace Refactor #233

Zusammengeführt
YoyoNow hat 121 Commits von TracerGUI nach master 2024-04-21 16:03:26 +02:00 zusammengeführt
5 geänderte Dateien mit 31 neuen und 20 gelöschten Zeilen
Nur Änderungen aus Commit 48175de8d8 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -22,7 +22,6 @@ package de.steamwar.bausystem;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils; import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
import de.steamwar.bausystem.features.tracer2.TraceManager;
import de.steamwar.bausystem.features.world.RamUsage; import de.steamwar.bausystem.features.world.RamUsage;
import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.PrototypeLoader;

Datei anzeigen

@ -20,10 +20,9 @@
package de.steamwar.bausystem.features.slaves.laufbau.states; package de.steamwar.bausystem.features.slaves.laufbau.states;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTRecord;
import de.steamwar.bausystem.features.tracer.Trace; import de.steamwar.bausystem.features.tracer.Trace;
import de.steamwar.bausystem.features.tracer.TraceManager; import de.steamwar.bausystem.features.tracer.TraceManager;
import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.linkage.LinkedInstance; import de.steamwar.linkage.LinkedInstance;
import lombok.Getter; import lombok.Getter;
@ -47,10 +46,10 @@ public class FilteringTracesState implements LaufbauState {
private final int totalRecord; private final int totalRecord;
List<Trace> traces; List<Trace> traces;
private List<Record.TNTRecord> tntRecords = new ArrayList<>(); private List<List<TNTRecord>> tntHistories = new ArrayList<>();
@Getter @Getter
private List<TNTPosition> tntPositions = new ArrayList<>(); private List<TNTRecord> tntPositions = new ArrayList<>();
public FilteringTracesState(World world, BiPredicate<Location, Integer> inRegionCheck) { public FilteringTracesState(World world, BiPredicate<Location, Integer> inRegionCheck) {
List<Trace> traces = new ArrayList<>(traceManager.getAll()); List<Trace> traces = new ArrayList<>(traceManager.getAll());
@ -67,29 +66,29 @@ public class FilteringTracesState implements LaufbauState {
@Override @Override
public boolean hasNext() { public boolean hasNext() {
return !traces.isEmpty() || !tntRecords.isEmpty(); return !traces.isEmpty() || !tntHistories.isEmpty();
} }
@Override @Override
public void next() { public void next() {
if (tntRecords.isEmpty()) { if (tntHistories.isEmpty()) {
Trace trace = traces.remove(0); Trace trace = traces.remove(0);
tntRecords.addAll(trace.getTnt()); tntHistories.addAll(trace.getHistories());
} }
if (tntRecords.isEmpty()) { if (tntHistories.isEmpty()) {
return; return;
} }
Record.TNTRecord tntRecord = tntRecords.remove(0); List<TNTRecord> tntRecords = tntHistories.remove(0);
tntRecord.getPositions().forEach(tntPosition -> { tntRecords.forEach(tntRecord -> {
if (FlatteningWrapper.impl.inWater(world, tntPosition.getLocation())) { if (FlatteningWrapper.impl.inWater(world, tntRecord.getLocation().toVector())) {
return; return;
} }
if (inRegionCheck.test(tntPosition.getLocation().toLocation(world), 1)) { if (inRegionCheck.test(tntRecord.getLocation(), 1)) {
tntPositions.add(tntPosition); tntPositions.add(tntRecord);
} }
if (tntPosition.getPreviousLocation() != null && inRegionCheck.test(tntPosition.getPreviousLocation().toLocation(world), 1)) { if (tntRecord.getPrevious().isPresent() && inRegionCheck.test(tntRecord.getPrevious().get().getLocation(), 1)) {
tntPositions.add(tntPosition); tntPositions.add(tntRecord);
} }
}); });
} }

Datei anzeigen

@ -80,11 +80,12 @@ public class ProcessingTracesState implements LaufbauState {
private void createCuboid(TNTRecord tntPosition) { private void createCuboid(TNTRecord tntPosition) {
Location location = tntPosition.getLocation(); Location location = tntPosition.getLocation();
Location previousLocation = tntPosition.getPrevious().getLocation(); Optional<TNTRecord> previous = tntPosition.getPrevious();
if (previousLocation == null) { if (!previous.isPresent()) {
toExpand.add(new Cuboid(location.getX() - 0.49, location.getY(), location.getZ() - 0.49, 0.98, 0.98, 0.98)); toExpand.add(new Cuboid(location.getX() - 0.49, location.getY(), location.getZ() - 0.49, 0.98, 0.98, 0.98));
} else { } else {
Location previousLocation = tntPosition.getPrevious().get().getLocation();
Location movement = location.clone().subtract(previousLocation); Location movement = location.clone().subtract(previousLocation);
toExpand.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98)); toExpand.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98));
if (tntPosition.getVelocity().getX() >= tntPosition.getVelocity().getZ()) { if (tntPosition.getVelocity().getX() >= tntPosition.getVelocity().getZ()) {

Datei anzeigen

@ -82,7 +82,7 @@ public class TNTRecord {
return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1)); return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1));
} }
public Optional<TNTRecord> getPrev(){ public Optional<TNTRecord> getPrevious(){
int index = history.indexOf(this); int index = history.indexOf(this);
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1)); return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));

Datei anzeigen

@ -105,7 +105,19 @@ public class Trace {
this.records = records; this.records = records;
} }
//TODO default options /**
*
*/
public Set<List<TNTRecord>> getHistories() {
Set<List<TNTRecord>> histories = new HashSet<>();
for(TNTRecord record: records) {
histories.add(record.getHistory());
}
return histories;
}
/** Renders this traces /** Renders this traces
* *
* @param player The player the trace is rendered to * @param player The player the trace is rendered to