Fall back to the default swing anim for weapons with none

310 cache weapons have empty attack anim lists, which threw
IndexOutOfBoundsException in getSwingAnimation when a guard swung one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-26 08:24:10 -04:00
1 parent 3fc5e7253a
commit 093b68258b
1 file changed
+18 -34
+18 -34
View File
@@ -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<int[]> 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) {