mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Safety null check for dismount check code
This commit is contained in:
parent
775e1e8921
commit
7ef005006b
1 changed files with 16 additions and 14 deletions
|
@ -79,21 +79,23 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
||||||
session.sendDownstreamPacket(sneakPacket);
|
session.sendDownstreamPacket(sneakPacket);
|
||||||
|
|
||||||
Entity currentVehicle = session.getPlayerEntity().getVehicle();
|
Entity currentVehicle = session.getPlayerEntity().getVehicle();
|
||||||
session.setMountVehicleScheduledFuture(session.scheduleInEventLoop(() -> {
|
if (currentVehicle != null) {
|
||||||
if (session.getPlayerEntity().getVehicle() == null) {
|
session.setMountVehicleScheduledFuture(session.scheduleInEventLoop(() -> {
|
||||||
return;
|
if (session.getPlayerEntity().getVehicle() == null) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long vehicleBedrockId = currentVehicle.getGeyserId();
|
long vehicleBedrockId = currentVehicle.getGeyserId();
|
||||||
if (session.getPlayerEntity().getVehicle().getGeyserId() == vehicleBedrockId) {
|
if (session.getPlayerEntity().getVehicle().getGeyserId() == vehicleBedrockId) {
|
||||||
// The Bedrock client, as of 1.19.51, dismounts on its end. The server may not agree with this.
|
// The Bedrock client, as of 1.19.51, dismounts on its end. The server may not agree with this.
|
||||||
// If the server doesn't agree with our dismount (sends a packet saying we dismounted),
|
// If the server doesn't agree with our dismount (sends a packet saying we dismounted),
|
||||||
// then remount the player.
|
// then remount the player.
|
||||||
SetEntityLinkPacket linkPacket = new SetEntityLinkPacket();
|
SetEntityLinkPacket linkPacket = new SetEntityLinkPacket();
|
||||||
linkPacket.setEntityLink(new EntityLinkData(vehicleBedrockId, session.getPlayerEntity().getGeyserId(), EntityLinkData.Type.PASSENGER, true, false));
|
linkPacket.setEntityLink(new EntityLinkData(vehicleBedrockId, session.getPlayerEntity().getGeyserId(), EntityLinkData.Type.PASSENGER, true, false));
|
||||||
session.sendUpstreamPacket(linkPacket);
|
session.sendUpstreamPacket(linkPacket);
|
||||||
}
|
}
|
||||||
}, 1, TimeUnit.SECONDS));
|
}, 1, TimeUnit.SECONDS));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MOUSEOVER:
|
case MOUSEOVER:
|
||||||
// Handle the buttons for mobile - "Mount", etc; and the suggestions for console - "ZL: Mount", etc
|
// Handle the buttons for mobile - "Mount", etc; and the suggestions for console - "ZL: Mount", etc
|
||||||
|
|
Loading…
Reference in a new issue