mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Fix teleports
This commit is contained in:
parent
c3b1e88b83
commit
ae44fa124d
@ -1604,8 +1604,11 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
*/
|
||||
protected void updatePlayerPosition() {
|
||||
PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
|
||||
positionAndLookPacket.position = position;
|
||||
positionAndLookPacket.position = position.clone();
|
||||
positionAndLookPacket.flags = 0x00;
|
||||
if (teleportId == Integer.MAX_VALUE) {
|
||||
teleportId = 0;
|
||||
}
|
||||
positionAndLookPacket.teleportId = teleportId++;
|
||||
playerConnection.sendPacket(positionAndLookPacket);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import net.minestom.server.item.StackingRule;
|
||||
import net.minestom.server.network.packet.client.play.ClientPlayerDiggingPacket;
|
||||
import net.minestom.server.network.packet.server.play.AcknowledgePlayerDiggingPacket;
|
||||
import net.minestom.server.network.packet.server.play.EntityEffectPacket;
|
||||
import net.minestom.server.network.packet.server.play.PlayerPositionAndLookPacket;
|
||||
import net.minestom.server.potion.PotionType;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
|
||||
@ -140,13 +139,8 @@ public class PlayerDiggingListener {
|
||||
final BlockPosition playerBlockPosition = player.getPosition().toBlockPosition();
|
||||
|
||||
// Teleport the player back if he broke a solid block just below him
|
||||
if (playerBlockPosition.subtract(0, 1, 0).equals(blockPosition)) {
|
||||
PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
|
||||
positionAndLookPacket.position = player.getPosition().clone().add(0, 0.25f, 0);
|
||||
positionAndLookPacket.flags = 0x00;
|
||||
positionAndLookPacket.teleportId = 999;
|
||||
player.getPlayerConnection().sendPacket(positionAndLookPacket);
|
||||
}
|
||||
if (playerBlockPosition.subtract(0, 1, 0).equals(blockPosition))
|
||||
player.teleport(player.getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user