Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
4fbbdf3a49
Commit
c92d610ca9
@ -53,7 +53,9 @@ public class Simulator19 implements Simulator {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long time = System.currentTimeMillis();
|
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);
|
List<List<Pair<TNTData, Integer>>> toSpawnInTick = toCalculate.getValue().get(currentTick);
|
||||||
if (toSpawnInTick != null) {
|
if (toSpawnInTick != null) {
|
||||||
int finalCurrentTick = currentTick;
|
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);
|
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)));
|
simulatorData.airBlocks.forEach(pos -> previewRecord.addAir(new Vector(pos.x, pos.y, pos.z)));
|
||||||
consumer.accept(previewRecord);
|
consumer.accept(previewRecord);
|
||||||
cancel();
|
cancel();
|
||||||
|
@ -66,6 +66,8 @@ public class TNTSimulator {
|
|||||||
|
|
||||||
private List<Player> toShow = new ArrayList<>();
|
private List<Player> toShow = new ArrayList<>();
|
||||||
private BukkitTask currentlyCalculating = null;
|
private BukkitTask currentlyCalculating = null;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private PreviewRecord previewRecord = null;
|
private PreviewRecord previewRecord = null;
|
||||||
|
|
||||||
public TNTSimulator() {
|
public TNTSimulator() {
|
||||||
|
@ -36,6 +36,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
@ -77,6 +78,10 @@ public class TNTSimulatorListener implements Listener {
|
|||||||
return RayTraceUtils.traceREntity(player, to, simulator.getEntities());
|
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<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
|
||||||
private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
|
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);
|
TNTSimulator tntSimulator = currentSimulator.get(player);
|
||||||
if (tntSimulator == null) return o;
|
if (tntSimulator == null) return o;
|
||||||
if (!tntSimulator.hasPreview(player)) 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(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
PlayerMovementWrapper.impl.setPosition(player, o);
|
PlayerMovementWrapper.impl.setPosition(player, o);
|
||||||
}, 0L);
|
}, 0L);
|
||||||
@ -139,7 +145,7 @@ public class TNTSimulatorListener implements Listener {
|
|||||||
hideShow(e.getPlayer(), simulatorPair);
|
hideShow(e.getPlayer(), simulatorPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||||
hideShow(e.getPlayer(), new Pair<>(null, false));
|
hideShow(e.getPlayer(), new Pair<>(null, false));
|
||||||
}
|
}
|
||||||
|
@ -84,4 +84,9 @@ public class PreviewRecord {
|
|||||||
public boolean has(Player player) {
|
public boolean has(Player player) {
|
||||||
return showModeMap.containsKey(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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren