mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 07:17:58 +01:00
Added a c:has_no_atmosphere dimension_type tag to disable pegasus flight when in spaaaaaaace #120
This commit is contained in:
parent
fff5d10f55
commit
58b1aad7a2
5 changed files with 26 additions and 3 deletions
|
@ -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<Item> APPLES = item("apples");
|
||||
|
@ -39,6 +41,8 @@ public interface UTags {
|
|||
|
||||
TagKey<StatusEffect> PINEAPPLE_EFFECTS = effect("pineapple_effects");
|
||||
|
||||
TagKey<DimensionType> HAS_NO_ATMOSPHERE = dimension("has_no_atmosphere");
|
||||
|
||||
static TagKey<Item> 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<DimensionType> dimension(String name) {
|
||||
return TagKey.of(RegistryKeys.DIMENSION_TYPE, new Identifier("c", name));
|
||||
}
|
||||
|
||||
static void bootstrap() {
|
||||
Toxics.bootstrap();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class PegasusFlightToggleAbility implements Ability<Hit> {
|
|||
@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<Hit> {
|
|||
|
||||
@Override
|
||||
public void apply(Pony player, Hit data) {
|
||||
if (player.asEntity().isCreative()) {
|
||||
if (tryActivate(player) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<PlayerEntity> implements Tickable, Motion, NbtSerialisable {
|
||||
|
@ -153,6 +154,11 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> 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;
|
||||
|
|
|
@ -49,4 +49,8 @@ public interface RegistryUtils {
|
|||
.filter(filter)
|
||||
.toList(), world.random);
|
||||
}
|
||||
|
||||
static <T> boolean isIn(World world, T obj, RegistryKey<? extends Registry<T>> registry, TagKey<T> tag) {
|
||||
return world.getRegistryManager().get(registry).getEntry(obj).isIn(tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue