diff --git a/src/main/java/com/minelittlepony/unicopia/UTags.java b/src/main/java/com/minelittlepony/unicopia/UTags.java index 1c76ab57..e0f3f4a8 100644 --- a/src/main/java/com/minelittlepony/unicopia/UTags.java +++ b/src/main/java/com/minelittlepony/unicopia/UTags.java @@ -8,6 +8,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"); @@ -39,6 +41,8 @@ public interface UTags { TagKey PINEAPPLE_EFFECTS = effect("pineapple_effects"); + TagKey HAS_NO_ATMOSPHERE = dimension("has_no_atmosphere"); + static TagKey item(String name) { return TagKey.of(RegistryKeys.ITEM, Unicopia.id(name)); } @@ -55,6 +59,10 @@ public interface UTags { return TagKey.of(RegistryKeys.STATUS_EFFECT, 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 0e5e5d5f..c7732253 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -34,10 +34,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 { @@ -153,6 +154,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": [ + ] +}