Fix fuzzy lookup with primitive-backed network list (#1163)

This commit is contained in:
Bryan Koch authored and GitHub committed 2026-04-03 10:57:28 +02:00
1 parent fa44bcafb5
commit ada1f64b86
1 file changed
+27 -3
@@ -245,7 +245,12 @@ public class NetworkItemList<T extends IAEStack> implements IItemList<T> {
@Override
public Collection<T> findFuzzy(final T input, final FuzzyMode fuzzy) {
return buildFinalItemList().findFuzzy(input, fuzzy);
final IAEStackType<T> stackType = getStackType();
if (stackType == null) {
return Collections.emptyList();
}
return buildFinalItemList(stackType.createList()).findFuzzy(input, fuzzy);
}
@Override
@@ -255,8 +260,27 @@ public class NetworkItemList<T extends IAEStack> implements IItemList<T> {
@Override
public @Nullable IAEStackType<T> getStackType() {
IItemList<T> list = networkItemLists.values().stream().findAny().orElse(null);
return list == null ? null : list.getStackType();
return findStackType(new HashSet<>());
}
private @Nullable IAEStackType<T> findStackType(Set<NetworkItemList<T>> visitedLists) {
if (!visitedLists.add(this)) {
return null;
}
for (IItemList<T> list : networkItemLists.values()) {
final IAEStackType<T> stackType;
if (list instanceof NetworkItemList) {
stackType = ((NetworkItemList<T>) list).findStackType(visitedLists);
} else {
stackType = list.getStackType();
}
if (stackType != null) {
return stackType;
}
}
return null;
}
static class NetworkItemStack<U extends IAEStack> {