mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
shows Items|Fluids storage disks with NEI search inventories mode of Search Field (#324)
This commit is contained in:
1 parent
81c975ce12
commit
e471c1b38c
1 file changed
+30
-1
@@ -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<IAEFluidStack> 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<IAEItemStack> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user