mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Properly update the client position when switching vehicle
This commit is contained in:
parent
34ba838ab5
commit
9739403ff4
@ -882,16 +882,15 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
|
|||||||
public void addPassenger(@NotNull Entity entity) {
|
public void addPassenger(@NotNull Entity entity) {
|
||||||
Check.stateCondition(instance == null, "You need to set an instance using Entity#setInstance");
|
Check.stateCondition(instance == null, "You need to set an instance using Entity#setInstance");
|
||||||
Check.stateCondition(entity == getVehicle(), "Cannot add the entity vehicle as a passenger");
|
Check.stateCondition(entity == getVehicle(), "Cannot add the entity vehicle as a passenger");
|
||||||
|
|
||||||
final Entity vehicle = entity.getVehicle();
|
final Entity vehicle = entity.getVehicle();
|
||||||
if (vehicle != null) {
|
if (vehicle != null) {
|
||||||
vehicle.removePassenger(entity);
|
vehicle.removePassenger(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.passengers.add(entity);
|
this.passengers.add(entity);
|
||||||
entity.vehicle = this;
|
entity.vehicle = this;
|
||||||
|
|
||||||
sendPacketToViewersAndSelf(getPassengersPacket());
|
sendPacketToViewersAndSelf(getPassengersPacket());
|
||||||
|
entity.refreshPosition(position);
|
||||||
|
entity.synchronizePosition(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -903,11 +902,14 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
|
|||||||
*/
|
*/
|
||||||
public void removePassenger(@NotNull Entity entity) {
|
public void removePassenger(@NotNull Entity entity) {
|
||||||
Check.stateCondition(instance == null, "You need to set an instance using Entity#setInstance");
|
Check.stateCondition(instance == null, "You need to set an instance using Entity#setInstance");
|
||||||
|
if (!passengers.remove(entity)) return;
|
||||||
if (!passengers.remove(entity))
|
|
||||||
return;
|
|
||||||
entity.vehicle = null;
|
entity.vehicle = null;
|
||||||
sendPacketToViewersAndSelf(getPassengersPacket());
|
sendPacketToViewersAndSelf(getPassengersPacket());
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
Player player = (Player) entity;
|
||||||
|
player.getPlayerConnection().sendPacket(new PlayerPositionAndLookPacket(player.getPosition(),
|
||||||
|
(byte) 0x00, player.getNextTeleportId(), true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user