mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-10-25 20:22:20 +00:00
Restore NEI highlighting when searching for fluid in cells (#299)
Co-authored-by: boubou19 <miisterunknown@gmail.com>
This commit is contained in:
1 parent
a57cb5db52
commit
a70854c832
2 files changed
+18
-7
No files matched your search
+17
-6
@@ -3,6 +3,7 @@ package com.glodblock.github.nei;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
|
||||
@@ -13,9 +14,10 @@ import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import codechicken.nei.SearchField;
|
||||
import codechicken.nei.SearchTokenParser;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
|
||||
public class NEIItemFilter implements SearchField.ISearchProvider {
|
||||
public class NEISearchFilter implements SearchTokenParser.ISearchParserProvider {
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter(String searchText) {
|
||||
@@ -24,8 +26,18 @@ public class NEIItemFilter implements SearchField.ISearchProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimary() {
|
||||
return false;
|
||||
public char getPrefix() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumChatFormatting getHighlightedColor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchTokenParser.SearchMode getSearchMode() {
|
||||
return SearchTokenParser.SearchMode.ALWAYS;
|
||||
}
|
||||
|
||||
public static class Filter implements ItemFilter {
|
||||
@@ -40,13 +52,13 @@ public class NEIItemFilter implements SearchField.ISearchProvider {
|
||||
public boolean matches(ItemStack itemStack) {
|
||||
if (itemStack.getItem() instanceof IStorageFluidCell) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
|
||||
.getCellInventory(itemStack, null, StorageChannel.FLUIDS);
|
||||
.getCellInventory(itemStack, null, StorageChannel.FLUIDS);
|
||||
if (inventory instanceof final IFluidCellInventoryHandler handler) {
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
if (cellInventory != null) {
|
||||
for (IAEFluidStack fluid : cellInventory.getContents()) {
|
||||
boolean result = pattern.matcher(fluid.getFluidStack().getLocalizedName().toLowerCase())
|
||||
.find();
|
||||
.find();
|
||||
if (result) return true;
|
||||
}
|
||||
|
||||
@@ -57,5 +69,4 @@ public class NEIItemFilter implements SearchField.ISearchProvider {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class NEI_FC_Config implements IConfigureNEI {
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
API.registerNEIGuiHandler(new AE2FC_NEIGuiHandler());
|
||||
API.addSearchProvider(new NEIItemFilter());
|
||||
API.addSearchProvider(new NEISearchFilter());
|
||||
API.registerStackStringifyHandler(new FCStackStringifyHandler());
|
||||
API.registerUsageHandler(new NEICellViewHandler());
|
||||
|
||||
|
||||
Reference in new issue
Block a user