diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java b/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java index 54db7c8f..666173d3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java @@ -43,6 +43,7 @@ public interface Abilities { // pegasus / bat / alicorn / changeling Ability CARRY = register(new CarryAbility(), "carry", AbilitySlot.PASSIVE); + Ability TOGGLE_SLIGHT = register(new PegasusFlightToggleAbility(), "toggle_flight", AbilitySlot.TERTIARY); // changeling Ability DISGUISE = register(new ChangelingDisguiseAbility(), "disguise", AbilitySlot.SECONDARY); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusFlightToggleAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusFlightToggleAbility.java new file mode 100644 index 00000000..60646c3f --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusFlightToggleAbility.java @@ -0,0 +1,79 @@ +package com.minelittlepony.unicopia.ability; + +import org.jetbrains.annotations.Nullable; + +import com.minelittlepony.unicopia.Race; +import com.minelittlepony.unicopia.ability.data.Hit; +import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; +import com.minelittlepony.unicopia.entity.Living; +import com.minelittlepony.unicopia.entity.player.Pony; + +import net.minecraft.util.Identifier; + +public class PegasusFlightToggleAbility implements Ability { + + @Override + public int getWarmupTime(Pony player) { + return 0; + } + + @Override + public int getCooldownTime(Pony player) { + return 0; + } + + @Override + public boolean canUse(Race race) { + return race.canFly(); + } + + @Nullable + @Override + public Hit tryActivate(Pony player) { + return player.getMaster().isCreative() ? null : Hit.INSTANCE; + } + + @Override + public Hit.Serializer getSerializer() { + return Hit.SERIALIZER; + } + + @Override + public Identifier getIcon(Pony player, boolean swap) { + Identifier id = Abilities.REGISTRY.getId(this); + return new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + (player.getPhysics().isFlying() ? "_land" : "_takeoff") + ".png"); + } + + @Override + public double getCostEstimate(Pony player) { + return 0; + } + + @Override + public void apply(Pony player, Hit data) { + if (player.getMaster().isCreative()) { + return; + } + + player.subtractEnergyCost(1); + + if (!player.getPhysics().isFlying()) { + player.getEntity().addVelocity(0, player.getPhysics().getGravitySignum() * 0.7F, 0); + Living.updateVelocity(player.getEntity()); + player.getPhysics().startFlying(true); + } else { + player.getPhysics().cancelFlight(true); + } + player.setDirty(); + player.setAnimation(Animation.SPREAD_WINGS); + } + + @Override + public void preApply(Pony player, AbilitySlot slot) { + player.getMagicalReserves().getExertion().add(6); + } + + @Override + public void postApply(Pony player, AbilitySlot slot) { + } +} diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 2f6ff76a..19f24da1 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -286,17 +286,18 @@ "ability.unicopia.cast": "Cast Spell", "ability.unicopia.dispell": "Dispell Magic", "ability.unicopia.teleport": "Teleport", - "ability.unicopia.teleport_group": "Teleport (Group)", - "ability.unicopia.grow": "Earthly Nourishment", + "ability.unicopia.teleport_group": "Group Teleport", + "ability.unicopia.grow": "Nourish Earth", "ability.unicopia.stomp": "Ground Pound", "ability.unicopia.kick": "Crushing Blow", - "ability.unicopia.pummel": "Crushing Blow", + "ability.unicopia.pummel": "Devestating Smash", "ability.unicopia.carry": "Pickup/Drop Passenger", + "ability.unicopia.toggle_flight": "Take-off/Land", "ability.unicopia.hang": "Cling to Ceiling", - "ability.unicopia.eee": "Deafening Screech", - "ability.unicopia.feed": "Collect Love", - "ability.unicopia.capture_cloud": "Cloudbust", - "ability.unicopia.disguise": "Shapeshift", + "ability.unicopia.eee": "Screech", + "ability.unicopia.feed": "Siphon Love", + "ability.unicopia.capture_cloud": "Bust Cloud", + "ability.unicopia.disguise": "Change Form", "ability.unicopia.rainboom": "Sonic Rainboom", "gui.unicopia": "Unicopia...", diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/toggle_flight_land.png b/src/main/resources/assets/unicopia/textures/gui/ability/toggle_flight_land.png new file mode 100644 index 00000000..55bdb8aa Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/toggle_flight_land.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/toggle_flight_takeoff.png b/src/main/resources/assets/unicopia/textures/gui/ability/toggle_flight_takeoff.png new file mode 100644 index 00000000..11fcb2ca Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/toggle_flight_takeoff.png differ