From 9ffec0021c980d987646bed9d8ad8aaa5b8d17d2 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 16 Feb 2020 12:40:54 -0600 Subject: [PATCH] Fix movement bugs *and* allow for teleportation --- .../connector/network/session/GeyserSession.java | 6 ++++++ .../bedrock/BedrockActionTranslator.java | 10 ++++++++++ .../JavaPlayerPositionRotationTranslator.java | 13 ++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index c2618275c..ca4a65ca3 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -100,6 +100,12 @@ public class GeyserSession implements Player { @Setter private GameMode gameMode = GameMode.SURVIVAL; + @Setter + private boolean sprinting; + + @Setter + private boolean jumping; + @Setter private boolean switchingDimension = false; private boolean manyDimPackets = false; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java index 56e573c69..981e569bd 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java @@ -40,6 +40,8 @@ import org.geysermc.connector.entity.Entity; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; +import java.util.concurrent.TimeUnit; + public class BedrockActionTranslator extends PacketTranslator { @Override @@ -72,10 +74,12 @@ public class BedrockActionTranslator extends PacketTranslator { + session.setJumping(false); + }, 1, TimeUnit.SECONDS); + break; } } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java index 9d81ce797..724cb5e04 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java @@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.Serv import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.EntityEventType; import com.nukkitx.protocol.bedrock.packet.*; + import org.geysermc.connector.console.GeyserLogger; import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.type.EntityType; @@ -83,7 +84,17 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator 1.5 || (yDis < 1.45 || yDis > (session.isJumping() ? 4.3 : (session.isSprinting() ? 2.5 : 1.9))) || zDis > 1.5) { + entity.moveAbsolute(session, Vector3f.from(packet.getX(), packet.getY() + 0.6f, packet.getZ()), packet.getYaw(), packet.getPitch(), true); + } + } ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId()); session.getDownstream().getSession().send(teleportConfirmPacket);