SteamWar/BauSystem2.0
Archiviert
12
0

Fix Trace again
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-04-14 12:14:53 +02:00
Ursprung 8a8d8888c8
Commit 20e907a5a2
4 geänderte Dateien mit 44 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -63,7 +63,7 @@ public class ProcessingTracesState implements LaufbauState {
} else { } else {
Vector movement = location.clone().subtract(previousLocation); Vector movement = location.clone().subtract(previousLocation);
cuboidList.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)); cuboidList.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 (Math.abs(tntPosition.getFirstVelocity().getX()) >= Math.abs(tntPosition.getFirstVelocity().getZ())) { if (Math.abs(tntPosition.getUpdateVelocity().getX()) >= Math.abs(tntPosition.getUpdateVelocity().getZ())) {
cuboidList.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); cuboidList.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98));
cuboidList.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); cuboidList.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98));
} else { } else {

Datei anzeigen

@ -22,29 +22,53 @@ package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.shared.Position; import de.steamwar.bausystem.shared.Position;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.function.Supplier;
@Getter @Getter
public class TNTPosition extends Position { public class TNTPosition extends Position {
@RequiredArgsConstructor
public static class CachingSupplier<T> implements Supplier<T> {
private final Supplier<T> supplier;
private boolean initialized;
private T value;
@Override
public T get() {
if (!initialized) {
value = supplier.get();
initialized = true;
}
return value;
}
}
private final Record.TNTRecord record; private final Record.TNTRecord record;
private final int fuseTicks; private final int fuseTicks;
private final Vector previousLocation; private final Vector previousLocation;
private final Vector velocity; private final Vector velocity;
private final Vector firstVelocity; private final CachingSupplier<Vector> updateVelocity;
private final boolean exploded; private final boolean exploded;
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, Vector firstVelocity, boolean exploded) { public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier<Vector> updateVelocity, boolean exploded) {
super(entity.getLocation().toVector()); super(entity.getLocation().toVector());
this.record = record; this.record = record;
this.fuseTicks = entity.getFuseTicks(); this.fuseTicks = entity.getFuseTicks();
this.previousLocation = previousLocation; this.previousLocation = previousLocation;
this.velocity = velocity; this.velocity = velocity;
this.firstVelocity = firstVelocity; this.updateVelocity = updateVelocity;
this.exploded = exploded; this.exploded = exploded;
} }
public Vector getUpdateVelocity() {
return updateVelocity.get();
}
@Override @Override
public String toString() { public String toString() {
return "Position{" + return "Position{" +

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import lombok.Getter; import lombok.Getter;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -98,9 +99,21 @@ public class Record {
private void add(TNTPrimed tntPrimed, boolean exploded) { private void add(TNTPrimed tntPrimed, boolean exploded) {
TNTPosition position; TNTPosition position;
if (positions.isEmpty()) { if (positions.isEmpty()) {
position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), null, exploded); position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), exploded);
} else { } else {
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), positions.get(0).getVelocity(), exploded); int currentSize = positions.size() + 1;
TNTPosition.CachingSupplier<Vector> velocitySupplier = new TNTPosition.CachingSupplier<>(() -> {
Vector current = null;
for (int i = currentSize - 1; i >= 0; i--) {
TNTPosition currentTNT = positions.get(i);
if ((currentTNT.getVelocity().getX() == 0 || currentTNT.getVelocity().getZ() == 0) && current != null) {
break;
}
current = currentTNT.getVelocity();
}
return current;
});
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, exploded);
} }
positions.add(position); positions.add(position);
TraceShowManager.show(position); TraceShowManager.show(position);

Datei anzeigen

@ -109,7 +109,7 @@ public abstract class FactoredEntityShowMode implements ShowMode<TNTPosition> {
} }
if (showModeParameter.isInterpolate_XZ()) { if (showModeParameter.isInterpolate_XZ()) {
Vector updatePointXZ = Math.abs(position.getFirstVelocity().getX()) >= Math.abs(position.getFirstVelocity().getZ()) Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ())
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
: position.getLocation().clone().setX(position.getPreviousLocation().getX()); : position.getLocation().clone().setX(position.getPreviousLocation().getX());
if (!position.getLocation().equals(updatePointXZ)) { if (!position.getLocation().equals(updatePointXZ)) {