Fix ghost blocks and add safe teleport
- Add BlockUpdateUtil for sending block update packets to clients - sendBlockUpdate() - update single block for visible players - sendRegionUpdate() - batch update for cuboid regions - sendLocationsUpdate() - efficient update for specific positions - refreshChunks() - full chunk resync if needed - findSafeTeleportLocation() - prevents player suffocation - Update BukkitBlockSetter to send block updates after placement - Prevents ghost blocks when setting many blocks quickly - Uses main thread for packet sending after async block placement - Update MineResetHandler.teleportPlayers() to use safe teleport - Finds safe location near configured teleport destination - Prevents players from spawning inside blocks Ghost blocks occur when server sets blocks without notifying clients, causing invisible blocks or desync. Fixed by explicit packet updates.
This commit is contained in:
parent
23d527e8a1
commit
061246511b
3 changed files with 260 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ package dev.loki.lomines.handler;
|
|||
import dev.loki.lomines.LoMinesPlugin;
|
||||
import dev.loki.lomines.core.Mine;
|
||||
import dev.loki.lomines.data.config.block.FillMode;
|
||||
import dev.loki.lomines.util.block.BlockUpdateUtil;
|
||||
import dev.loki.lomines.util.location.Cuboid;
|
||||
import dev.loki.lomines.util.location.LocationParser;
|
||||
import dev.lolib.scheduler.Scheduler;
|
||||
|
|
@ -170,7 +171,8 @@ public final class MineResetHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* Teleports players standing inside the mine to the configured location.
|
||||
* Teleports players standing inside the mine to a safe location near the configured destination.
|
||||
* Prevents players from suffocating in blocks by finding a safe teleport spot.
|
||||
*/
|
||||
private void teleportPlayers() {
|
||||
var destOpt = mine.getConfig().teleport().getLocation();
|
||||
|
|
@ -181,9 +183,13 @@ public final class MineResetHandler {
|
|||
if (dest.getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find a safe teleport location to prevent suffocation
|
||||
Location safeDest = BlockUpdateUtil.findSafeTeleportLocation(dest);
|
||||
|
||||
for (Player p : dest.getWorld().getPlayers()) {
|
||||
if (mine.contains(p.getLocation())) {
|
||||
p.teleport(dest);
|
||||
p.teleport(safeDest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue