mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed player position messed up when mounting a boat whilst flying
Players can now fly from boats again. Fixes #377
This commit is contained in:
parent
7c779eb2e3
commit
d6286c7a00
2 changed files with 12 additions and 1 deletions
|
@ -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<Hit> {
|
||||
|
||||
|
@ -27,7 +28,7 @@ public class ToggleFlightAbility implements Ability<Hit> {
|
|||
@Nullable
|
||||
@Override
|
||||
public Optional<Hit> 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<Hit> {
|
|||
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);
|
||||
|
|
|
@ -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<Boolean> info) {
|
||||
get().getPhysics().cancelFlight(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue