3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Fix movement bugs *and* allow for teleportation

Dieser Commit ist enthalten in:
RednedEpic 2020-02-16 12:40:54 -06:00
Ursprung f52684f0dd
Commit 9ffec0021c
3 geänderte Dateien mit 28 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -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;

Datei anzeigen

@ -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<PlayerActionPacket> {
@Override
@ -72,10 +74,12 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
case START_SPRINT:
ClientPlayerStatePacket startSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
session.getDownstream().getSession().send(startSprintPacket);
session.setSprinting(true);
break;
case STOP_SPRINT:
ClientPlayerStatePacket stopSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
session.getDownstream().getSession().send(stopSprintPacket);
session.setSprinting(false);
break;
case DROP_ITEM:
ClientPlayerActionPacket dropItemPacket = new ClientPlayerActionPacket(PlayerAction.DROP_ITEM, position, BlockFace.values()[packet.getFace()]);
@ -114,6 +118,12 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
session.getUpstream().sendPacket(spawnPacket);
entity.updateBedrockAttributes(session);
break;
case JUMP:
session.setJumping(true);
session.getConnector().getGeneralThreadPool().schedule(() -> {
session.setJumping(false);
}, 1, TimeUnit.SECONDS);
break;
}
}
}

Datei anzeigen

@ -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<Serve
}
session.setSpawned(true);
entity.moveAbsolute(session, Vector3f.from(packet.getX(), packet.getY() + EntityType.PLAYER.getOffset() + 0.1f, packet.getZ()), packet.getYaw(), packet.getPitch(), true);
if (!packet.getRelative().isEmpty()) {
entity.moveRelative(session, packet.getX(), packet.getY() + EntityType.PLAYER.getOffset() + 0.1f, packet.getZ(), packet.getYaw(), packet.getPitch(), true);
} else {
float xDis = Math.abs(entity.getPosition().getX() - (float) packet.getX());
float yDis = entity.getPosition().getY() - (float) packet.getY();
float zDis = Math.abs(entity.getPosition().getZ() - (float) packet.getZ());
if (xDis > 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);