diff --git a/src/main/scala/extracells/part/PartOreDictExporter.java b/src/main/scala/extracells/part/PartOreDictExporter.java index b785e2a..7fefd8e 100644 --- a/src/main/scala/extracells/part/PartOreDictExporter.java +++ b/src/main/scala/extracells/part/PartOreDictExporter.java @@ -75,10 +75,11 @@ public void setFilter(String filter) { * Call when the filter string has changed to parse and recompile the filter. */ private void updateFilter() { - if (!this.filter.trim().isEmpty()) { - //ArrayList matchingNames = new ArrayList<>(); - Predicate matcher = null; - + Predicate matcher = null; + if (filter.contains("\\") || filter.contains("^") || filter.contains("$") || filter.contains("+") || filter.contains("(") || filter.contains(")") || filter.contains("[") || filter.contains("]")) { + final Predicate test = Pattern.compile(filter).asPredicate(); + matcher = (is) -> is != null && IntStream.of(OreDictionary.getOreIDs(is)).mapToObj(OreDictionary::getOreName).anyMatch(test); + } else if (!this.filter.trim().isEmpty()) { String[] filters = this.filter.split("[&|]"); String lastFilter = null; @@ -108,31 +109,21 @@ private void updateFilter() { } } } + } - if (matcher == null) { - //filterPredicate = null; - oreDictFilteredItems = new ItemStack[0]; - return; - } - - //Mod name and path evaluation can only be done during tick, can't precompile whitelist for this. - if (!this.filter.contains("@") && !this.filter.contains("~")) { - //Precompiled whitelist of oredict itemstacks. - ArrayList filtered = new ArrayList<>(); - for (String name : OreDictionary.getOreNames()) - for (ItemStack s : OreDictionary.getOres(name)) - if (matcher.test(s)) { - filtered.add(s); - } - oreDictFilteredItems = filtered.toArray(oreDictFilteredItems); + // Mod name and path evaluation are disabled in this version + if (matcher != null && !this.filter.contains("@") && !this.filter.contains("~")) { + //Precompiled whitelist of oredict itemstacks. + ArrayList filtered = new ArrayList<>(); + for (String name : OreDictionary.getOreNames()) + for (ItemStack s : OreDictionary.getOres(name)) + if (matcher.test(s)) { + filtered.add(s); + } + oreDictFilteredItems = filtered.toArray(oreDictFilteredItems); - } else { - // mod filtering disabled - //filterPredicate = matcher; - this.oreDictFilteredItems = new ItemStack[0]; - } } else { - //this.filterPredicate = null; + // mod filtering disabled this.oreDictFilteredItems = new ItemStack[0]; } }