diff --git a/src/main/java/com/minelittlepony/unicopia/UTags.java b/src/main/java/com/minelittlepony/unicopia/UTags.java index 184383e7..92f1473a 100644 --- a/src/main/java/com/minelittlepony/unicopia/UTags.java +++ b/src/main/java/com/minelittlepony/unicopia/UTags.java @@ -9,6 +9,8 @@ import net.minecraft.entity.effect.StatusEffect; import net.minecraft.item.Item; import net.minecraft.registry.*; import net.minecraft.registry.tag.TagKey; +import net.minecraft.util.Identifier; +import net.minecraft.world.dimension.DimensionType; public interface UTags { TagKey APPLES = item("apples"); @@ -42,6 +44,8 @@ public interface UTags { TagKey BREAKS_SUNGLASSES = damage("breaks_sunglasses"); + TagKey HAS_NO_ATMOSPHERE = dimension("has_no_atmosphere"); + static TagKey item(String name) { return TagKey.of(RegistryKeys.ITEM, Unicopia.id(name)); } @@ -62,6 +66,10 @@ public interface UTags { return TagKey.of(RegistryKeys.DAMAGE_TYPE, Unicopia.id(name)); } + static TagKey dimension(String name) { + return TagKey.of(RegistryKeys.DIMENSION_TYPE, new Identifier("c", name)); + } + static void bootstrap() { Toxics.bootstrap(); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusFlightToggleAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusFlightToggleAbility.java index 5ac0d19e..1692e086 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusFlightToggleAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusFlightToggleAbility.java @@ -30,7 +30,7 @@ public class PegasusFlightToggleAbility implements Ability { @Nullable @Override public Hit tryActivate(Pony player) { - return player.asEntity().isCreative() ? null : Hit.INSTANCE; + return player.asEntity().isCreative() || player.getPhysics().getFlightType().isGrounded() ? null : Hit.INSTANCE; } @Override @@ -54,7 +54,7 @@ public class PegasusFlightToggleAbility implements Ability { @Override public void apply(Pony player, Hit data) { - if (player.asEntity().isCreative()) { + if (tryActivate(player) == null) { return; } 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 3fdb1882..3c61d321 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -35,10 +35,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.ParticleTypes; import net.minecraft.predicate.entity.EntityPredicates; +import net.minecraft.registry.RegistryKeys; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; import net.minecraft.util.math.*; +import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.event.GameEvent; public class PlayerPhysics extends EntityPhysics implements Tickable, Motion, NbtSerialisable { @@ -154,6 +155,11 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } public FlightType getFlightType() { + DimensionType dimension = entity.getWorld().getDimension(); + + if (RegistryUtils.isIn(entity.getWorld(), dimension, RegistryKeys.DIMENSION_TYPE, UTags.HAS_NO_ATMOSPHERE)) { + return FlightType.NONE; + } if (UItems.PEGASUS_AMULET.isApplicable(entity)) { return FlightType.ARTIFICIAL; diff --git a/src/main/java/com/minelittlepony/unicopia/util/RegistryUtils.java b/src/main/java/com/minelittlepony/unicopia/util/RegistryUtils.java index a5930adb..03c35aef 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/RegistryUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/util/RegistryUtils.java @@ -49,4 +49,8 @@ public interface RegistryUtils { .filter(filter) .toList(), world.random); } + + static boolean isIn(World world, T obj, RegistryKey> registry, TagKey tag) { + return world.getRegistryManager().get(registry).getEntry(obj).isIn(tag); + } } diff --git a/src/main/resources/data/c/tags/dimension_type/has_no_atmosphere.json b/src/main/resources/data/c/tags/dimension_type/has_no_atmosphere.json new file mode 100644 index 00000000..d275da3f --- /dev/null +++ b/src/main/resources/data/c/tags/dimension_type/has_no_atmosphere.json @@ -0,0 +1,5 @@ +{ + "replace": false, + "values": [ + ] +}