SteamWar/BauSystem2.0
Archiviert
12
0

Fix many inconveniences
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-09-08 20:46:00 +02:00
Ursprung 4fbbdf3a49
Commit c92d610ca9
4 geänderte Dateien mit 18 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -53,7 +53,9 @@ public class Simulator19 implements Simulator {
@Override
public void run() {
long time = System.currentTimeMillis();
while (!simulatorData.tntList.isEmpty() || currentTick <= toCalculate.getKey() && System.currentTimeMillis() - time < 40) {
while (!simulatorData.tntList.isEmpty() || currentTick <= toCalculate.getKey()) {
if (System.currentTimeMillis() - time >= 40) break;
List<List<Pair<TNTData, Integer>>> toSpawnInTick = toCalculate.getValue().get(currentTick);
if (toSpawnInTick != null) {
int finalCurrentTick = currentTick;
@ -94,7 +96,7 @@ public class Simulator19 implements Simulator {
}
System.out.println("Time: " + (System.currentTimeMillis() - time) + "ms " + simulatorData.cacheMisses + "/" + simulatorData.accessed + "/" + simulatorData.aired);
if (simulatorData.tntList.isEmpty() && currentTick <= toCalculate.getKey()) {
if (simulatorData.tntList.isEmpty() && currentTick > toCalculate.getKey()) {
simulatorData.airBlocks.forEach(pos -> previewRecord.addAir(new Vector(pos.x, pos.y, pos.z)));
consumer.accept(previewRecord);
cancel();

Datei anzeigen

@ -66,6 +66,8 @@ public class TNTSimulator {
private List<Player> toShow = new ArrayList<>();
private BukkitTask currentlyCalculating = null;
@Getter
private PreviewRecord previewRecord = null;
public TNTSimulator() {

Datei anzeigen

@ -36,6 +36,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
@ -77,6 +78,10 @@ public class TNTSimulatorListener implements Listener {
return RayTraceUtils.traceREntity(player, to, simulator.getEntities());
}
private static final Class<?> base = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying");
private static final Reflection.FieldAccessor<Double> x = Reflection.getField(base, double.class, 0);
private static final Reflection.FieldAccessor<Double> y = Reflection.getField(base, double.class, 1);
private static final Reflection.FieldAccessor<Double> z = Reflection.getField(base, double.class, 2);
private static final Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
@ -86,6 +91,7 @@ public class TNTSimulatorListener implements Listener {
TNTSimulator tntSimulator = currentSimulator.get(player);
if (tntSimulator == null) return o;
if (!tntSimulator.hasPreview(player)) return o;
if (!tntSimulator.getPreviewRecord().isAir(x.get(o), y.get(o), z.get(o))) return o;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
PlayerMovementWrapper.impl.setPosition(player, o);
}, 0L);
@ -139,7 +145,7 @@ public class TNTSimulatorListener implements Listener {
hideShow(e.getPlayer(), simulatorPair);
}
@EventHandler
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent e) {
hideShow(e.getPlayer(), new Pair<>(null, false));
}

Datei anzeigen

@ -84,4 +84,9 @@ public class PreviewRecord {
public boolean has(Player player) {
return showModeMap.containsKey(player);
}
public boolean isAir(double x, double y, double z) {
Vector vec = new Vector(x, y, z);
return destroyedBlocks.contains(new Vector(vec.getBlockX(), vec.getBlockY(), vec.getBlockZ()));
}
}