From d4e3feacee8469b865538102ce339c44fba99174 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 23 Jun 2024 16:57:47 +0100 Subject: [PATCH] Fixed ability cooldown not ticking when there is not ability in the slot. Fixes #366 --- .../unicopia/ability/AbilityDispatcher.java | 10 ++++++++++ .../unicopia/client/gui/ManaRingSlot.java | 2 -- .../com/minelittlepony/unicopia/client/gui/Slot.java | 11 +++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java index 457abd1c..93eacb89 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java @@ -172,6 +172,16 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable { } public void tick() { + Optional> activeAbility = getActiveAbility(); + + if (activeAbility.isEmpty()) { + if (warmup > 0) { + warmup--; + } + if (cooldown > 0) { + cooldown--; + } + } getActiveAbility().ifPresent(ability -> { if (warmup > 0) { warmup--; diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java index d9e88921..fa9f3d05 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java @@ -23,8 +23,6 @@ class ManaRingSlot extends Slot { protected void renderContents(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { MatrixStack matrices = context.getMatrices(); - - matrices.push(); matrices.translate(24.125, 24.75, 0); 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 4d1e0ec0..80b7ef78 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java @@ -89,10 +89,15 @@ class Slot { bSwap &= abilities.isFilled(bSlot); } + int page = Unicopia.getConfig().hudPage.get(); AbilityDispatcher.Stat stat = abilities.getStat(bSwap ? bSlot : aSlot); - if (stat.getAbility(Unicopia.getConfig().hudPage.get()).isEmpty()) { - return; + if (stat.getAbility(page).isEmpty()) { + if (aSlot != AbilitySlot.PRIMARY + || (!abilities.getStat(AbilitySlot.SECONDARY).getAbility(page).isEmpty() + && !abilities.getStat(AbilitySlot.TERTIARY).getAbility(page).isEmpty())) { + return; + } } RenderSystem.setShaderColor(1, 1, 1, 1); @@ -104,8 +109,6 @@ class Slot { // background context.drawTexture(UHud.HUD_TEXTURE, 0, 0, backgroundU, backgroundV, size, size, 128, 128); - - int iconPosition = ((size - iconSize + slotPadding + 1) / 2); int sz = iconSize - slotPadding; uHud.renderAbilityIcon(context, stat, iconPosition, iconPosition, sz, sz, sz, sz);