mirror of
https://github.com/GTNewHorizons/NotEnoughCharacters.git
synced 2026-11-21 04:42:09 +00:00
Search item id with & prefix
This commit is contained in:
1 parent
e7fcbc1ffa
commit
848d7546f8
1 file changed
+21
-1
@@ -5,6 +5,7 @@ import codechicken.nei.api.ItemInfo;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import me.towdium.pinin.Keyboard;
|
||||
import me.towdium.pinin.PinIn;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class NecharSearchFilter implements ItemFilter {
|
||||
protected boolean invalid = false;
|
||||
|
||||
protected String mod = null;
|
||||
|
||||
protected String id = null;
|
||||
protected String dict = null;
|
||||
|
||||
protected List<String> keywords = new LinkedList<>();
|
||||
@@ -40,6 +41,15 @@ public class NecharSearchFilter implements ItemFilter {
|
||||
return;
|
||||
}
|
||||
|
||||
case '&':
|
||||
if (id == null) {
|
||||
id = piece.substring(1).toLowerCase();
|
||||
continue;
|
||||
} else {
|
||||
invalid = true;
|
||||
return;
|
||||
}
|
||||
|
||||
case '$':
|
||||
if (dict == null) {
|
||||
dict = piece.substring(1).toLowerCase();
|
||||
@@ -58,6 +68,7 @@ public class NecharSearchFilter implements ItemFilter {
|
||||
public boolean matches(ItemStack itemStack) {
|
||||
return !invalid
|
||||
&& matchesMod(itemStack)
|
||||
&& matchesId(itemStack)
|
||||
&& matchesDict(itemStack)
|
||||
&& matchesKeywords(itemStack);
|
||||
}
|
||||
@@ -71,6 +82,15 @@ public class NecharSearchFilter implements ItemFilter {
|
||||
return itemId != null && itemId.modId.toLowerCase().contains(mod);
|
||||
}
|
||||
|
||||
protected boolean matchesId(ItemStack itemStack) {
|
||||
if (id == null || id.isEmpty())
|
||||
return true;
|
||||
|
||||
String itemId = Item.itemRegistry.getNameForObject(itemStack.getItem());
|
||||
|
||||
return itemId.toLowerCase().contains(id);
|
||||
}
|
||||
|
||||
protected boolean matchesDict(ItemStack itemStack) {
|
||||
if (dict == null || dict.isEmpty())
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user