mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-01-31 19:16:44 +01:00
Fix null exceptions when an entity says it has a vehicle but actually doesn't. #118
This commit is contained in:
parent
5ad9b46430
commit
a444395c28
2 changed files with 13 additions and 8 deletions
|
@ -383,15 +383,17 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
return Equine.<E, Living<E>>of(entity, e -> e instanceof Living<?>).orElse(null);
|
||||
}
|
||||
|
||||
public static void updateVelocity(Entity entity) {
|
||||
entity.velocityModified = true;
|
||||
//if (entity instanceof ServerPlayerEntity ply) {
|
||||
// ply.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(ply));
|
||||
//}
|
||||
public static void updateVelocity(@Nullable Entity entity) {
|
||||
if (entity != null) {
|
||||
entity.velocityModified = true;
|
||||
//if (entity instanceof ServerPlayerEntity ply) {
|
||||
// ply.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(ply));
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public static void transmitPassengers(Entity entity) {
|
||||
if (entity.world instanceof ServerWorld sw) {
|
||||
public static void transmitPassengers(@Nullable Entity entity) {
|
||||
if (entity != null && entity.world instanceof ServerWorld sw) {
|
||||
sw.getChunkManager().sendToNearbyPlayers(entity, new EntityPassengersSetS2CPacket(entity));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,6 +312,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
if (isClient()) {
|
||||
if (entity.hasVehicle() && entity.isSneaking()) {
|
||||
|
||||
@Nullable
|
||||
Entity vehicle = entity.getVehicle();
|
||||
|
||||
if (vehicle instanceof Trap) {
|
||||
|
@ -326,7 +327,9 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
} else {
|
||||
setCarrier((UUID)null);
|
||||
entity.stopRiding();
|
||||
entity.refreshPositionAfterTeleport(vehicle.getPos());
|
||||
if (vehicle != null) {
|
||||
entity.refreshPositionAfterTeleport(vehicle.getPos());
|
||||
}
|
||||
Living.transmitPassengers(vehicle);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue