mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-25 22:44:27 +00:00
Added a new filter. #<oredict> will return all the items under this specific oredict entry.
This commit is contained in:
1 parent
7463c054c7
commit
389f2e7dfc
1 file changed
+21
-3
@@ -5,6 +5,7 @@ import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.ItemList.EverythingItemFilter;
|
||||
import codechicken.nei.ItemList.PatternItemFilter;
|
||||
@@ -23,7 +24,8 @@ public class ModNameFilter implements ISearchProvider{
|
||||
public static class Filter implements ItemFilter {
|
||||
|
||||
Pattern pattern;
|
||||
|
||||
boolean oreDictSearch = false;
|
||||
|
||||
public Filter(String searchText) {
|
||||
switch(NEIClientConfig.getIntSetting("inventory.searchmode")) {
|
||||
case 0://plain
|
||||
@@ -38,7 +40,13 @@ public class ModNameFilter implements ISearchProvider{
|
||||
}
|
||||
|
||||
try {
|
||||
pattern = Pattern.compile(searchText);
|
||||
if (searchText.startsWith("#") && searchText.length() > 1){
|
||||
pattern = Pattern.compile(searchText.substring(1));
|
||||
oreDictSearch = true;
|
||||
} else {
|
||||
pattern = Pattern.compile(searchText);
|
||||
oreDictSearch = false;
|
||||
}
|
||||
} catch (PatternSyntaxException ignored) {}
|
||||
}
|
||||
|
||||
@@ -46,7 +54,17 @@ public class ModNameFilter implements ISearchProvider{
|
||||
public boolean matches(ItemStack item) {
|
||||
if (pattern == null || pattern.toString().equals(""))
|
||||
return true;
|
||||
return pattern.matcher(ItemInfo.getSearchName(item)).find() || pattern.matcher(ModIdentification.nameFromStack(item).toLowerCase()).find();
|
||||
|
||||
if (oreDictSearch){
|
||||
int[] ids = OreDictionary.getOreIDs(item);
|
||||
for (int id : ids){
|
||||
if (pattern.matcher(OreDictionary.getOreName(id)).find())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return pattern.matcher(ItemInfo.getSearchName(item)).find() || pattern.matcher(ModIdentification.nameFromStack(item).toLowerCase()).find();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user