尝试阻止外部stopRiding#2

This commit is contained in:
17146 2025-05-11 14:44:45 +08:00 committed by Light_Quanta
parent 911c616f22
commit 4bfb9e1675
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -44,8 +44,9 @@ public class LivingEntityMixin implements ICustomKnockback {
@Inject(method = "stopRiding()V", at = @At("HEAD"), cancellable = true) @Inject(method = "stopRiding()V", at = @At("HEAD"), cancellable = true)
public void stopRiding(CallbackInfo ci) { public void stopRiding(CallbackInfo ci) {
Entity entity = ((LivingEntity) (Object) this).getVehicle(); var living = ((LivingEntity) (Object) this);
if (entity instanceof VehicleEntity) { Entity entity = living.getVehicle();
if (entity instanceof VehicleEntity && living instanceof Player) {
ci.cancel(); ci.cancel();
} }
} }