From e471c1b38cb16cc208db1a8cce3f7e20dc532298 Mon Sep 17 00:00:00 2001 From: NeOzay <69015205+NeOzay@users.noreply.github.com> Date: Fri, 8 Aug 2025 18:10:04 +0200 Subject: [PATCH] shows Items|Fluids storage disks with NEI search inventories mode of Search Field (#324) --- .../glodblock/github/nei/NEISearchFilter.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/glodblock/github/nei/NEISearchFilter.java b/src/main/java/com/glodblock/github/nei/NEISearchFilter.java index c8fdfc98..a4c2da51 100644 --- a/src/main/java/com/glodblock/github/nei/NEISearchFilter.java +++ b/src/main/java/com/glodblock/github/nei/NEISearchFilter.java @@ -1,5 +1,6 @@ package com.glodblock.github.nei; +import java.util.ArrayList; import java.util.regex.Pattern; import net.minecraft.item.ItemStack; @@ -10,9 +11,15 @@ import com.glodblock.github.common.storage.IFluidCellInventoryHandler; import com.glodblock.github.common.storage.IStorageFluidCell; import appeng.api.AEApi; +import appeng.api.implementations.items.IStorageCell; +import appeng.api.storage.ICellInventory; import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; +import appeng.me.storage.CellInventoryHandler; +import appeng.util.IterationCounter; import codechicken.nei.SearchField; import codechicken.nei.SearchTokenParser; import codechicken.nei.api.ItemFilter; @@ -56,7 +63,10 @@ public class NEISearchFilter implements SearchTokenParser.ISearchParserProvider if (inventory instanceof final IFluidCellInventoryHandler handler) { final IFluidCellInventory cellInventory = handler.getCellInv(); if (cellInventory != null) { - for (IAEFluidStack fluid : cellInventory.getContents()) { + final ArrayList out = new ArrayList<>(); + handler.getPartitionInv().forEach(out::add); + out.addAll(cellInventory.getContents()); + for (IAEFluidStack fluid : out) { boolean result = pattern.matcher(fluid.getFluidStack().getLocalizedName().toLowerCase()) .find(); if (result) return true; @@ -65,6 +75,25 @@ public class NEISearchFilter implements SearchTokenParser.ISearchParserProvider } } } + + if (itemStack.getItem() instanceof IStorageCell) { + final IMEInventoryHandler inventory = AEApi.instance().registries().cell() + .getCellInventory(itemStack, null, StorageChannel.ITEMS); + if (inventory instanceof final CellInventoryHandler handler) { + final ICellInventory cellInventory = handler.getCellInv(); + if (cellInventory != null) { + final IItemList out = AEApi.instance().storage().createItemFilterList(); + for (IAEItemStack item : handler.getPartitionList().getItems()) + out.add(item); + cellInventory.getAvailableItems(out, IterationCounter.fetchNewId()); + for ( IAEItemStack item : out) { + boolean result = pattern.matcher(item.getItemStack().getDisplayName().toLowerCase()) + .find(); + if (result) return true; + } + } + } + } return false; }