diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java index d1a45aa2..a3c3e6fa 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ToggleFlightAbility.java @@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.util.Identifier; +import net.minecraft.util.math.Vec3d; public class ToggleFlightAbility implements Ability { @@ -27,7 +28,7 @@ public class ToggleFlightAbility implements Ability { @Nullable @Override public Optional prepare(Pony player) { - return Hit.of(!player.asEntity().hasVehicle() && !player.asEntity().isCreative() && !player.getPhysics().getFlightType().isGrounded()); + return Hit.of(!player.asEntity().isCreative() && !player.getPhysics().getFlightType().isGrounded()); } @Override @@ -59,6 +60,11 @@ public class ToggleFlightAbility implements Ability { player.subtractEnergyCost(1); if (!player.getPhysics().isFlying()) { + if (player.asEntity().hasVehicle()) { + Vec3d pos = player.asEntity().getPos(); + player.asEntity().stopRiding(); + player.asEntity().setPosition(pos.getX(), pos.getY() + 0.25, pos.getZ()); + } player.asEntity().addVelocity(0, player.getPhysics().getGravitySignum() * 0.7F, 0); Living.updateVelocity(player.asEntity()); player.getPhysics().startFlying(true); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayerEntity.java index 2ae21fe5..30a69af2 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayerEntity.java @@ -52,4 +52,9 @@ abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHan private void onUpdateKilledAdvancementCriterion(Entity entityKilled, int score, DamageSource damageSource, CallbackInfo info) { get().onKill(entityKilled, damageSource); } + + @Inject(method = "startRiding(Lnet/minecraft/entity/Entity;Z)Z", at = @At("HEAD")) + private void onStartRiding(Entity entity, boolean force, CallbackInfoReturnable info) { + get().getPhysics().cancelFlight(true); + } }