mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
add NEI Highlighting for Text on AE2FC Fluid Storage Cells
This commit is contained in:
1 parent
a8155c8b17
commit
b2eafe5c88
2 files changed
+63
-1
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package com.glodblock.github.nei;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import codechicken.nei.SearchField;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
|
||||
import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
|
||||
public class NEIItemFilter implements SearchField.ISearchProvider {
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter(String searchText) {
|
||||
Pattern pattern = SearchField.getPattern(searchText);
|
||||
return pattern == null ? null : new Filter(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimary() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Filter implements ItemFilter {
|
||||
|
||||
Pattern pattern;
|
||||
|
||||
public Filter(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack itemStack) {
|
||||
if (itemStack.getItem() instanceof IStorageFluidCell) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
|
||||
.getCellInventory(itemStack, null, StorageChannel.FLUIDS);
|
||||
if (inventory instanceof IFluidCellInventoryHandler) {
|
||||
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
if (cellInventory != null) {
|
||||
for (IAEFluidStack fluid : cellInventory.getContents()) {
|
||||
if (fluid != null) {
|
||||
return pattern.matcher(fluid.getFluidStack().getLocalizedName().toLowerCase()).find();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class NEI_FC_Config implements IConfigureNEI {
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
API.registerNEIGuiHandler(new NEIGuiHandler());
|
||||
|
||||
API.addSearchProvider(new NEIItemFilter());
|
||||
for (String identifier : FluidRecipe.getSupportRecipes()) {
|
||||
API.registerGuiOverlayHandler(
|
||||
GuiPatternPortableCell.class,
|
||||
|
||||
Reference in new issue
Block a user