SteamWar/BauSystem2.0
Archiviert
12
0

Fix MicroMotion detector in Trace
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-06-18 17:58:52 +02:00
Ursprung 1b28b377e2
Commit 8ef7bafa22
2 geänderte Dateien mit 20 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -48,7 +48,7 @@ public class Record {
} }
public TNTRecord spawn(long offset) { public TNTRecord spawn(long offset) {
TNTRecord record = new TNTRecord(offset, region); TNTRecord record = new TNTRecord(this, offset, region);
tnt.add(record); tnt.add(record);
return record; return record;
} }
@ -57,11 +57,26 @@ public class Record {
tnt.clear(); tnt.clear();
} }
private void checkMicroMotion() {
for (TNTRecord tntRecord : tnt) {
List<TNTPosition> positions = tntRecord.positions;
if (positions.isEmpty()) continue;
TNTPosition position = positions.get(positions.size() - 1);
Vector velocity = position.getVelocity();
if (velocity.getY() == 0 && (velocity.getX() != 0 || velocity.getZ() != 0) && (Math.abs(velocity.getX()) < 0.001 || Math.abs(velocity.getZ()) < 0.001)) {
tntRecord.hasMicroMotion = true;
}
}
}
public static class TNTRecord { public static class TNTRecord {
@Getter @Getter
private final UUID id = UUID.randomUUID(); private final UUID id = UUID.randomUUID();
private Record record;
@Getter @Getter
private final long offset; private final long offset;
@ -78,7 +93,8 @@ public class Record {
@Getter @Getter
private boolean hasMicroMotion = false; private boolean hasMicroMotion = false;
public TNTRecord(long offset, Region region) { public TNTRecord(Record record, long offset, Region region) {
this.record = record;
this.offset = offset; this.offset = offset;
this.region = region; this.region = region;
} }
@ -93,11 +109,7 @@ public class Record {
public void explode(TNTPrimed tntPrimed) { public void explode(TNTPrimed tntPrimed) {
add(tntPrimed, false, true); add(tntPrimed, false, true);
Vector velocity = tntPrimed.getVelocity(); record.checkMicroMotion();
if (velocity.getY() != 0) return;
if (velocity.getX() > 0.001 || velocity.getZ() > 0.001) return;
if (velocity.getX() == 0 && velocity.getZ() == 0) return;
hasMicroMotion = true;
} }
private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) { private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) {

Datei anzeigen

@ -42,7 +42,7 @@ public enum ShowModeParameterType {
COUNT(ShowModeParameter::enableCount, Arrays.asList("-count", "-c"), "TICKS", "TICKS_SINCE_START"), COUNT(ShowModeParameter::enableCount, Arrays.asList("-count", "-c"), "TICKS", "TICKS_SINCE_START"),
BUILD_DESTROY_ONLY(ShowModeParameter::enableBuildDestroyOnly, Arrays.asList("-builddestroy", "-builddestoryonly"), "WATER"), BUILD_DESTROY_ONLY(ShowModeParameter::enableBuildDestroyOnly, Arrays.asList("-builddestroy", "-builddestoryonly"), "WATER"),
TICKS_SINCE_START(ShowModeParameter::enableTicksSinceStart, Arrays.asList("-tickssincestart", "-tss"), "TICKS", "COUNT"), TICKS_SINCE_START(ShowModeParameter::enableTicksSinceStart, Arrays.asList("-tickssincestart", "-tss"), "TICKS", "COUNT"),
MICROMOTION(ShowModeParameter::enableMicroMotion, Arrays.asList("-micromotion", "-micro", "-m"), "COUNT"), MICROMOTION(ShowModeParameter::enableMicroMotion, Arrays.asList("-micromotion", "-micro", "-m")),
; ;
@Getter @Getter