Fixed ability cooldown not ticking when there is not ability in the slot. Fixes #366

This commit is contained in:
Sollace 2024-06-23 16:57:47 +01:00
parent bf5a29e8d5
commit d4e3feacee
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 17 additions and 6 deletions

View file

@ -172,6 +172,16 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
} }
public void tick() { public void tick() {
Optional<Ability<?>> activeAbility = getActiveAbility();
if (activeAbility.isEmpty()) {
if (warmup > 0) {
warmup--;
}
if (cooldown > 0) {
cooldown--;
}
}
getActiveAbility().ifPresent(ability -> { getActiveAbility().ifPresent(ability -> {
if (warmup > 0) { if (warmup > 0) {
warmup--; warmup--;

View file

@ -23,8 +23,6 @@ class ManaRingSlot extends Slot {
protected void renderContents(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { protected void renderContents(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) {
MatrixStack matrices = context.getMatrices(); MatrixStack matrices = context.getMatrices();
matrices.push(); matrices.push();
matrices.translate(24.125, 24.75, 0); matrices.translate(24.125, 24.75, 0);

View file

@ -89,11 +89,16 @@ class Slot {
bSwap &= abilities.isFilled(bSlot); bSwap &= abilities.isFilled(bSlot);
} }
int page = Unicopia.getConfig().hudPage.get();
AbilityDispatcher.Stat stat = abilities.getStat(bSwap ? bSlot : aSlot); AbilityDispatcher.Stat stat = abilities.getStat(bSwap ? bSlot : aSlot);
if (stat.getAbility(Unicopia.getConfig().hudPage.get()).isEmpty()) { if (stat.getAbility(page).isEmpty()) {
if (aSlot != AbilitySlot.PRIMARY
|| (!abilities.getStat(AbilitySlot.SECONDARY).getAbility(page).isEmpty()
&& !abilities.getStat(AbilitySlot.TERTIARY).getAbility(page).isEmpty())) {
return; return;
} }
}
RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderColor(1, 1, 1, 1);
RenderSystem.enableBlend(); RenderSystem.enableBlend();
@ -104,8 +109,6 @@ class Slot {
// background // background
context.drawTexture(UHud.HUD_TEXTURE, 0, 0, backgroundU, backgroundV, size, size, 128, 128); context.drawTexture(UHud.HUD_TEXTURE, 0, 0, backgroundU, backgroundV, size, size, 128, 128);
int iconPosition = ((size - iconSize + slotPadding + 1) / 2); int iconPosition = ((size - iconSize + slotPadding + 1) / 2);
int sz = iconSize - slotPadding; int sz = iconSize - slotPadding;
uHud.renderAbilityIcon(context, stat, iconPosition, iconPosition, sz, sz, sz, sz); uHud.renderAbilityIcon(context, stat, iconPosition, iconPosition, sz, sz, sz, sz);