From 98cdec2ced23ac1cb1c1429988531ef0aa120720 Mon Sep 17 00:00:00 2001 From: Minh Date: Tue, 10 Dec 2024 14:53:47 +0700 Subject: [PATCH] Ticking Skill small change --- .../manasmods/manascore/api/skills/TickingSkill.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java b/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java index 1f21f1ee..99640094 100644 --- a/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java +++ b/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java @@ -6,28 +6,31 @@ import java.util.Optional; +@Getter public class TickingSkill { private int duration = 0; - @Getter private final ManasSkill skill; public TickingSkill(ManasSkill skill) { this.skill = skill; } public boolean tick(SkillStorage storage, LivingEntity entity) { - Optional optional = storage.getSkill(skill); + Optional optional = storage.getSkill(this.getSkill()); if (optional.isEmpty()) return false; ManasSkillInstance instance = optional.get(); if (reachedMaxDuration(instance, entity)) return false; - if (!instance.canInteractSkill(entity)) return false; + if (!instance.canInteractSkill(entity)) { + instance.onRelease(entity, this.getDuration()); + return false; + } return instance.onHeld(entity, this.duration++); } public boolean reachedMaxDuration(ManasSkillInstance instance, LivingEntity entity) { int maxDuration = instance.getMaxHeldTime(entity); if (maxDuration == -1) return false; - return duration >= maxDuration; + return this.getDuration() >= maxDuration; } }