From 80b885514f3c0ae0d1f0a4557b137a44ae1aae89 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 20 May 2024 01:49:02 +0100 Subject: [PATCH] Add broken wings status effect --- .../unicopia/client/gui/HudEffects.java | 3 +-- .../unicopia/entity/Living.java | 3 +-- .../unicopia/entity/effect/EffectUtils.java | 12 +++++++-- .../unicopia/entity/effect/UEffects.java | 1 + .../unicopia/entity/player/PlayerPhysics.java | 25 +++++++++++++++++- .../resources/assets/unicopia/lang/en_us.json | 1 + .../textures/mob_effect/broken_wings.png | Bin 0 -> 7982 bytes 7 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/assets/unicopia/textures/mob_effect/broken_wings.png diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/HudEffects.java b/src/main/java/com/minelittlepony/unicopia/client/gui/HudEffects.java index 2188245d..4d0bd016 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/HudEffects.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/HudEffects.java @@ -7,7 +7,6 @@ import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.duck.EntityDuck; -import com.minelittlepony.unicopia.entity.effect.EffectUtils; import com.minelittlepony.unicopia.entity.effect.UEffects; import com.minelittlepony.unicopia.entity.player.Pony; @@ -31,7 +30,7 @@ public class HudEffects { private static void apply(Pony pony, float tickDelta, boolean on) { if (on) { - if (!pony.asEntity().hasStatusEffect(StatusEffects.HUNGER) && EffectUtils.getAmplifier(pony.asEntity(), UEffects.FOOD_POISONING) > 0) { + if (!pony.asEntity().hasStatusEffect(StatusEffects.HUNGER) && pony.asEntity().hasStatusEffect(UEffects.FOOD_POISONING)) { addedHunger = true; pony.asEntity().addStatusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 1, 1, false, false)); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index 7a1807db..fa8cf61d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -23,7 +23,6 @@ import com.minelittlepony.unicopia.entity.behaviour.Guest; import com.minelittlepony.unicopia.entity.damage.MagicalDamageSource; import com.minelittlepony.unicopia.entity.duck.LivingEntityDuck; import com.minelittlepony.unicopia.entity.effect.CorruptInfluenceStatusEffect; -import com.minelittlepony.unicopia.entity.effect.EffectUtils; import com.minelittlepony.unicopia.entity.effect.UEffects; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.input.Heuristic; @@ -200,7 +199,7 @@ public abstract class Living implements Equine, Caste @Override public boolean beforeUpdate() { landEvent.beforeTick(); - if (EffectUtils.getAmplifier(entity, UEffects.PARALYSIS) > 1 && entity.getVelocity().horizontalLengthSquared() > 0) { + if (entity.hasStatusEffect(UEffects.PARALYSIS) && entity.getVelocity().horizontalLengthSquared() > 0) { entity.setVelocity(entity.getVelocity().multiply(0, 1, 0)); updateVelocity(); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/EffectUtils.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/EffectUtils.java index dff45f27..208ccf04 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/EffectUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/EffectUtils.java @@ -6,11 +6,19 @@ import net.minecraft.entity.effect.StatusEffectInstance; public interface EffectUtils { static boolean isPoisoned(LivingEntity entity) { - return getAmplifier(entity, UEffects.FOOD_POISONING) > 2; + return getAmplifier(entity, UEffects.FOOD_POISONING) > 1; + } + + static boolean hasABrokenWing(LivingEntity entity) { + return entity.hasStatusEffect(UEffects.BROKEN_WINGS); + } + + static boolean hasBothBrokenWing(LivingEntity entity) { + return getAmplifier(entity, UEffects.BROKEN_WINGS) > 1; } static int getAmplifier(LivingEntity entity, StatusEffect effect) { - return entity.hasStatusEffect(effect) ? entity.getStatusEffect(effect).getAmplifier() : 0; + return entity.hasStatusEffect(effect) ? entity.getStatusEffect(effect).getAmplifier() + 1 : 0; } static boolean isChangingRace(LivingEntity entity) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/UEffects.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/UEffects.java index 83feb060..586a053b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/UEffects.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/UEffects.java @@ -17,6 +17,7 @@ public interface UEffects { StatusEffect CORRUPT_INFLUENCE = register("corrupt_influence", new CorruptInfluenceStatusEffect(0x00FF00)); StatusEffect PARALYSIS = register("paralysis", new SimpleStatusEffect(StatusEffectCategory.HARMFUL, 0, false)); StatusEffect FORTIFICATION = register("fortification", new SimpleStatusEffect(StatusEffectCategory.BENEFICIAL, 0x000077, false)); + StatusEffect BROKEN_WINGS = register("broken_wings", new SimpleStatusEffect(StatusEffectCategory.BENEFICIAL, 0xEEAA00, false)); /** * Side-effect of wearing the alicorn amulet. * Causes the player to lose grip on whatever item they're holding. 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 5229258f..cebc54c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -16,6 +16,7 @@ import com.minelittlepony.unicopia.compat.ad_astra.OxygenApi; import com.minelittlepony.unicopia.entity.*; import com.minelittlepony.unicopia.entity.damage.UDamageTypes; import com.minelittlepony.unicopia.entity.duck.LivingEntityDuck; +import com.minelittlepony.unicopia.entity.effect.EffectUtils; import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar; import com.minelittlepony.unicopia.input.Heuristic; import com.minelittlepony.unicopia.item.AmuletItem; @@ -229,6 +230,10 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (wasFlying) { entity.calculateDimensions(); } + + if (!pony.isClient()) { + pony.setDirty(); + } } public double getHorizontalMotion() { @@ -285,6 +290,19 @@ public class PlayerPhysics extends EntityPhysics implements Tickab cancelFlight(false); } + if (!pony.isClient()) { + System.out.println(ticksInAir + " " + type.canFly() + " " + isFlying() + " " + EffectUtils.hasBothBrokenWing(entity)); + if (type.canFly() + && isFlying() + && EffectUtils.hasBothBrokenWing(entity) + && ticksInAir > 90) { + + entity.getWorld().playSoundFromEntity(null, entity, USounds.Vanilla.ENTITY_PLAYER_BIG_FALL, SoundCategory.PLAYERS, 2, 1F); + entity.damage(entity.getDamageSources().generic(), 3); + cancelFlight(true); + } + } + if (entity.isOnGround()) { isCancelled = false; } @@ -441,7 +459,12 @@ public class PlayerPhysics extends EntityPhysics implements Tickab entity.fallDistance = 0; - applyThrust(velocity); + if (!EffectUtils.hasABrokenWing(entity) || entity.age % 50 < 25) { + applyThrust(velocity); + } else if (entity.getWorld().random.nextInt(40) == 0) { + entity.getWorld().playSoundFromEntity(null, entity, USounds.Vanilla.ENTITY_PLAYER_BIG_FALL, SoundCategory.PLAYERS, 2, 1.5F); + entity.damage(entity.getDamageSources().generic(), 0.5F); + } if (type.isAvian()) { if (pony.getObservedSpecies() != Race.BAT && entity.getWorld().random.nextInt(9000) == 0) { diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index a6c45570..fa43ed75 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -407,6 +407,7 @@ "effect.unicopia.paralysis": "Paralysis", "effect.unicopia.butter_fingers": "Butterfingers", "effect.unicopia.fortification": "Fortification", + "effect.unicopia.broken_wings": "Broken Wings", "effect.unicopia.change_race_earth": "Earth Pony Metamorphosis", "effect.unicopia.change_race_unicorn": "Unicorn Metamorphosis", diff --git a/src/main/resources/assets/unicopia/textures/mob_effect/broken_wings.png b/src/main/resources/assets/unicopia/textures/mob_effect/broken_wings.png new file mode 100644 index 0000000000000000000000000000000000000000..f83f4b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