Skip to content

Commit

Permalink
Ticking Skill small change
Browse files Browse the repository at this point in the history
  • Loading branch information
minheragon12345 committed Dec 10, 2024
1 parent 2a80d6d commit 98cdec2
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ManasSkillInstance> optional = storage.getSkill(skill);
Optional<ManasSkillInstance> 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;
}
}

0 comments on commit 98cdec2

Please sign in to comment.