Fix mounts being unmountable with cache chunks (#1576)

Teleports need to be confirmed before riding
This commit is contained in:
Camotoy 2020-11-27 17:56:32 -05:00 committed by GitHub
parent 894275b8c4
commit 11d9d30050
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -31,13 +31,14 @@ import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
// Used for horses
/**
* Sent by the client when moving a horse.
*/
@Translator(packet = MoveEntityAbsolutePacket.class)
public class BedrockMoveEntityAbsoluteTranslator extends PacketTranslator<MoveEntityAbsolutePacket> {
@Override
public void translate(MoveEntityAbsolutePacket packet, GeyserSession session) {
ClientVehicleMovePacket clientVehicleMovePacket = new ClientVehicleMovePacket(
packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ(),
packet.getRotation().getY() - 90, packet.getRotation().getX()

View file

@ -31,7 +31,9 @@ import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
// Makes minecarts respond to player input
/**
* Sent by the client for minecarts and boats.
*/
@Translator(packet = PlayerInputPacket.class)
public class BedrockPlayerInputTranslator extends PacketTranslator<PlayerInputPacket> {

View file

@ -61,6 +61,10 @@ public class JavaEntitySetPassengersTranslator extends PacketTranslator<ServerEn
if (passengerId == session.getPlayerEntity().getEntityId()) {
passenger = session.getPlayerEntity();
session.setRidingVehicleEntity(entity);
// We need to confirm teleports before entering a vehicle, or else we will likely exit right out
if (session.getConnector().getConfig().isCacheChunks()) {
session.confirmTeleport(passenger.getPosition().sub(0, EntityType.PLAYER.getOffset(), 0).toDouble());
}
}
// Passenger hasn't loaded in and entity link needs to be set later
if (passenger == null && passengerId != 0) {