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 de.steamwar.bausystem.configplayer.Config;
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.linkage.LinkageUtils;
import de.steamwar.bausystem.region.loader.PrototypeLoader;

Datei anzeigen

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

Datei anzeigen

@ -80,11 +80,12 @@ public class ProcessingTracesState implements LaufbauState {
private void createCuboid(TNTRecord tntPosition) {
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));
} else {
Location previousLocation = tntPosition.getPrevious().get().getLocation();
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));
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));
}
public Optional<TNTRecord> getPrev(){
public Optional<TNTRecord> getPrevious(){
int index = history.indexOf(this);
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));

Datei anzeigen

@ -105,7 +105,19 @@ public class Trace {
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
*
* @param player The player the trace is rendered to