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
Nur Änderungen aus Commit 2cd3c3527e werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -28,9 +28,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -46,7 +44,7 @@ public abstract class ViewFlag {
*/ */
public static final List<ViewFlag> inverseFlags = new ArrayList<>(); public static final List<ViewFlag> inverseFlags = new ArrayList<>();
public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosionOnly") { public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosion") {
@Override @Override
public List<TNTRecord> filter(List<TNTRecord> records) { public List<TNTRecord> filter(List<TNTRecord> records) {
return records.stream() return records.stream()
@ -106,6 +104,41 @@ public abstract class ViewFlag {
public void modify(REntityServer server, List<TraceEntity> entities) {} public void modify(REntityServer server, List<TraceEntity> entities) {}
}; };
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion") {
@Override
public List<TNTRecord> filter(List<TNTRecord> records) {
Set<UUID> seen = new HashSet<>();
Set<TNTRecord> toRemove = new HashSet<>();
for(TNTRecord uniqueRecord: records){
if(seen.contains(uniqueRecord.getTntId())) continue;
boolean hasMicromotion = false;
for(TNTRecord record: uniqueRecord.getHistory()){
Vector velocity = record.getVelocity();
if(velocity.getY() == 0 && (Math.abs(velocity.getX()) < 0.001 || Math.abs(velocity.getZ()) < 0.001)){
hasMicromotion = true;
break;
}
}
if(!hasMicromotion)
toRemove.add(uniqueRecord);
seen.add(uniqueRecord.getTntId());
}
for(TNTRecord record: toRemove){
records.removeAll(record.getHistory());
}
return records;
}
@Override
public void modify(REntityServer server, List<TraceEntity> entities) {}
};
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced") { public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced") {
@Override @Override
public List<TNTRecord> filter(List<TNTRecord> records) {return records;} public List<TNTRecord> filter(List<TNTRecord> records) {return records;}