diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java index eaa96379..dd1c9c23 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java @@ -83,6 +83,15 @@ public interface Ability { return false; } + /** + * Checks whether this ability has any special actions for the given activation type. + *

+ * The default is to only respond to press-and-hold actions. + */ + default boolean acceptsQuickAction(Pony player, ActivationType type) { + return type == ActivationType.NONE; + } + /** * Called on the client to get any data required for the quick action. * diff --git a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java index 844fd96f..936ffa83 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java @@ -63,6 +63,11 @@ public class CarryAbility implements Ability { return false; } + @Override + public boolean acceptsQuickAction(Pony player, ActivationType type) { + return type == ActivationType.NONE || type == ActivationType.TAP; + } + @Override public boolean apply(Pony iplayer, Hit data) { PlayerEntity player = iplayer.asEntity(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 62dfda4a..ca76579f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -116,6 +116,11 @@ public class EarthPonyKickAbility implements Ability { return false; } + @Override + public boolean acceptsQuickAction(Pony player, ActivationType type) { + return type == ActivationType.NONE || type == ActivationType.TAP || type == ActivationType.DOUBLE_TAP; + } + @Nullable @Override public Optional prepare(Pony player) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java index c9436ce9..af66c200 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/FlyingDashAbility.java @@ -49,6 +49,11 @@ public class FlyingDashAbility implements Ability { return false; } + @Override + public boolean acceptsQuickAction(Pony player, ActivationType type) { + return type == ActivationType.NONE || type == ActivationType.TAP; + } + @Override public boolean apply(Pony player, Hit data) { player.getPhysics().dashForward((float)player.asWorld().random.nextTriangular(2.5F, 0.3F)); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java index c9abd9b6..6e1fd02f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java @@ -54,6 +54,11 @@ public class PegasusRainboomAbility implements Ability { return false; } + @Override + public boolean acceptsQuickAction(Pony player, ActivationType type) { + return type == ActivationType.NONE || type == ActivationType.TAP; + } + @Override public boolean apply(Pony player, Hit data) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java index 77e137bf..4eb6f47a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java @@ -72,6 +72,11 @@ public class UnicornDispellAbility implements Ability { return false; } + @Override + public boolean acceptsQuickAction(Pony player, ActivationType type) { + return type == ActivationType.NONE || (player.getSpecies() != Race.CHANGELING && type == ActivationType.TAP); + } + @Override public double getCostEstimate(Pony player) { return getTarget(player) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java index a352bb61..e05038a9 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java @@ -56,6 +56,11 @@ public class UnicornProjectileAbility extends AbstractSpellCastingAbility { return false; } + @Override + public boolean acceptsQuickAction(Pony player, ActivationType type) { + return type == ActivationType.NONE || type == ActivationType.DOUBLE_TAP; + } + @Override public boolean apply(Pony player, Hit data) { TypedActionResult> thrown = player.getCharms().getSpellInHand(true); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java index 4297a42c..4d1e0ec0 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java @@ -1,10 +1,14 @@ package com.minelittlepony.unicopia.client.gui; +import java.util.Optional; + import com.minelittlepony.unicopia.Unicopia; +import com.minelittlepony.unicopia.ability.Ability; import com.minelittlepony.unicopia.ability.AbilityDispatcher; import com.minelittlepony.unicopia.ability.AbilitySlot; import com.minelittlepony.unicopia.ability.ActivationType; import com.minelittlepony.unicopia.client.KeyBindingsHandler; +import com.minelittlepony.unicopia.client.UnicopiaClient; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.DrawContext; @@ -132,7 +136,9 @@ class Slot { void renderLabel(DrawContext context, AbilityDispatcher abilities, float tickDelta) { - if (abilities.getStat(aSlot).getAbility(Unicopia.getConfig().hudPage.get()).isEmpty()) { + Optional> ability = abilities.getStat(aSlot).getAbility(Unicopia.getConfig().hudPage.get()); + + if (ability.isEmpty()) { return; } @@ -155,6 +161,9 @@ class Slot { ActivationType activation = KeyBindingsHandler.INSTANCE.getForcedActivationType(); if (activation.isResult()) { label = label.append("+T" + activation.getTapCount()); + if (!ability.get().acceptsQuickAction(UnicopiaClient.getClientPony(), activation)) { + label = label.formatted(Formatting.RED); + } } context.drawText(uHud.font, label, 0, 0, 0xFFFFFF, true);