From 222e208141b3720bf6c1bb2b9be0cc96d65d8d12 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 7 Oct 2023 23:44:30 +0100 Subject: [PATCH] Fixed alicorn amulet flight not working --- src/main/java/com/minelittlepony/unicopia/FlightType.java | 4 ++++ src/main/java/com/minelittlepony/unicopia/Race.java | 4 ++++ .../minelittlepony/unicopia/entity/player/PlayerPhysics.java | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/unicopia/FlightType.java b/src/main/java/com/minelittlepony/unicopia/FlightType.java index 47b0848d..f2ef92f0 100644 --- a/src/main/java/com/minelittlepony/unicopia/FlightType.java +++ b/src/main/java/com/minelittlepony/unicopia/FlightType.java @@ -42,6 +42,10 @@ public enum FlightType { return this == INSECTOID ? 0.66F : 1; } + public FlightType or(FlightType other) { + return ordinal() > other.ordinal() ? this : other; + } + /** * Predicate for abilities to control whether a player can fly. * diff --git a/src/main/java/com/minelittlepony/unicopia/Race.java b/src/main/java/com/minelittlepony/unicopia/Race.java index 67c17dd2..58db596f 100644 --- a/src/main/java/com/minelittlepony/unicopia/Race.java +++ b/src/main/java/com/minelittlepony/unicopia/Race.java @@ -220,6 +220,10 @@ public record Race (Supplier compositeSupplier, boolean canCast, Flig public boolean canCast() { return any(Race::canCast); } + + public FlightType flightType() { + return physical().flightType().or(pseudo().flightType()); + } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 6a6e689b..da819207 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -197,7 +197,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab .filter(effect -> !effect.isDead() && effect instanceof FlightType.Provider) .map(effect -> ((FlightType.Provider)effect).getFlightType()) .filter(FlightType::isPresent) - .orElse(pony.getObservedSpecies().flightType()); + .orElse(pony.getCompositeRace().flightType()); } public void cancelFlight(boolean force) {