SteamWar/BauSystem2.0
Archiviert
12
0

Add optimistic recalc on block break and place
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-09-09 13:32:22 +02:00
Ursprung 7e2780f326
Commit 2774b29342
2 geänderte Dateien mit 10 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -96,7 +96,7 @@ public class Simulator19 implements Simulator {
System.out.println("Time: " + (System.currentTimeMillis() - time) + "ms " + simulatorData.blockTypesMap.size() + "/" + simulatorData.blockDataMap.size() + "/" + simulatorData.collisionDataMap.size() + "/" + simulatorData.airBlocks.size() + " " + recordMap.size());
if (simulatorData.tntList.isEmpty() && currentTick > toCalculate.getKey()) {
previewRecord.setDestroyedBlocks(simulatorData.airBlocks());
previewRecord.setAccessedBlocks(vector -> true);
previewRecord.setAccessedBlocks(simulatorData.accessedBlocks());
consumer.accept(previewRecord);
cancel();
}

Datei anzeigen

@ -26,6 +26,7 @@ import org.bukkit.util.Vector;
import org.bukkit.util.VoxelShape;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class SimulatorData {
@ -95,11 +96,18 @@ public class SimulatorData {
collisionDataMap.remove(pos);
}
public void clearBlocks(Set<Pos> poss) { // TODO: Optimize
public void clearBlocks(Set<Pos> poss) {
poss.forEach(this::clearBlock);
}
public Set<Vector> airBlocks() {
return airBlocks.stream().map(pos -> new Vector(pos.x, pos.y, pos.z)).collect(Collectors.toSet());
}
public Predicate<Vector> accessedBlocks() {
return vector -> {
Pos pos = new Pos(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return airBlocks.contains(pos) || blockTypesMap.containsKey(pos) || blockDataMap.containsKey(pos) || collisionDataMap.containsKey(pos);
};
}
}