perf(slashblade-allweapon): 加速弹体命中去重

原因 / Cause:
四类弹体每次实体扫描后都以 ArrayList.removeAll 进行已命中排除,候选与历史命中数增长时成员检查退化为线性。

修复 / Fix:
将仅作成员记录的 alreadyHitEntity 从 ArrayList 替换为 HashSet,保留原有 add、clear、addAll 与 removeAll 调用顺序。

性能收益 / Performance:
实体扫描结果排除已命中目标时,成员检查由线性查找降为均摊常数时间,降低多弹体和多目标场景的去重开销。

兼容性 / Compatibility:
不改变 AABB、selector、攻击顺序、命中冷却或弹体生命周期;集合未被迭代,命中列表的顺序和重复值不参与行为。

验证 / Validation:
Java 25 下执行 Gradle 9.4.0 build --no-daemon --console=plain 成功(test 为 NO-SOURCE)。

Refs #1
This commit is contained in:
layue13 committed 2026-09-05 16:12:44 +08:00
1 parent 2164f25770
commit c3284030a3
4 files changed
+12 -8

No files matched your search

@@ -30,10 +30,11 @@ package com.moe.allweapon.Entityadd;
import cpw.mods.fml.common.registry.IThrowableEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import mods.flammpfeil.slashblade.ItemSlashBlade;
import mods.flammpfeil.slashblade.ability.StylishRankManager;
import net.minecraft.block.Block;
@@ -58,7 +59,7 @@ extends Entity
implements IThrowableEntity {
protected Entity thrower;
protected ItemStack blade = null;
protected List<Entity> alreadyHitEntity = new ArrayList<Entity>();
protected Set<Entity> alreadyHitEntity = new HashSet<Entity>();
protected float AttackLevel = 0.0f;
private int i;
private Long startTime = new Date().getTime();