diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 680c5e7b..af5a85a8 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -28,6 +28,7 @@ import org.pmw.tinylog.Logger; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; +import java.util.ArrayList; import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -602,42 +603,25 @@ public enum CombatManager { } //declare variables - int anim; - int random; + mbEnums.EquipSlotType hand; + ArrayList anims; - //Item can only be equipped in one slot, return animation for that slot - if (wb.getItemEqSlotsOr().size() == 1) { - if (wb.getItemEqSlotsOr().iterator().next().equals(mbEnums.EquipSlotType.RHELD)) { - anim = weapon.weapon_attack_anim_right.get(0)[0]; - if (dpj != null) { - random = ThreadLocalRandom.current().nextInt(weapon.weapon_attack_anim_right.size()); - anim = weapon.weapon_attack_anim_right.get(random)[0]; - } - } else { - anim = weapon.weapon_attack_anim_left.get(0)[0]; - if (dpj != null) { - random = ThreadLocalRandom.current().nextInt(weapon.weapon_attack_anim_left.size()); - anim = weapon.weapon_attack_anim_left.get(random)[0]; - } - } - return anim; - } + //Item can only be equipped in one slot, use the animations for that slot + if (wb.getItemEqSlotsOr().size() == 1) + hand = wb.getItemEqSlotsOr().iterator().next(); + else + hand = slot; - //Item can be equipped in either hand, and should have animation sets for each hand - if (slot.equals(mbEnums.EquipSlotType.RHELD)) { - anim = weapon.weapon_attack_anim_right.get(0)[0]; - if (dpj != null) { - random = ThreadLocalRandom.current().nextInt(weapon.weapon_attack_anim_right.size()); - anim = weapon.weapon_attack_anim_right.get(random)[0]; - } - } else { - anim = weapon.weapon_attack_anim_left.get(0)[0]; - if (dpj != null) { - random = ThreadLocalRandom.current().nextInt(weapon.weapon_attack_anim_left.size()); - anim = weapon.weapon_attack_anim_left.get(random)[0]; - } - } - return anim; + anims = hand.equals(mbEnums.EquipSlotType.RHELD) ? weapon.weapon_attack_anim_right : weapon.weapon_attack_anim_left; + + // Many cache weapons have no swing anims; GUESS: the client falls back to the default too + if (anims.isEmpty()) + return 75; + + if (dpj != null) + return anims.get(ThreadLocalRandom.current().nextInt(anims.size()))[0]; + + return anims.get(0)[0]; } public static int getPassiveAnimation(mbEnums.PassiveType passiveType) {