diff --git a/src/main/java/gregtech/api/worldgen/config/WorldConfigUtils.java b/src/main/java/gregtech/api/worldgen/config/WorldConfigUtils.java index b066e59bab..5d63a2eccf 100644 --- a/src/main/java/gregtech/api/worldgen/config/WorldConfigUtils.java +++ b/src/main/java/gregtech/api/worldgen/config/WorldConfigUtils.java @@ -36,18 +36,18 @@ public static Predicate createWorldPredicate(JsonElement element) allPredicates.add(wp -> wp.isNether() || wp.getDimensionType() == DimensionType.NETHER); continue; } - Function stringSupplier; + Function stringSupplier = null; if (stringValue.startsWith("dimension_id:")) { String filterValue = stringValue.substring(13); if (filterValue.indexOf(':') == -1) { int dimensionId = Integer.parseInt(filterValue); - return provider -> provider.getDimension() == dimensionId; + allPredicates.add(provider -> provider.getDimension() == dimensionId); } else { int indexOf = filterValue.indexOf(':'); int indexOfExclusive = indexOf + 1; int minDimensionId = indexOf == 0 ? -Integer.MAX_VALUE : Integer.parseInt(filterValue.substring(0, indexOf)); int maxDimensionId = indexOfExclusive == filterValue.length() ? Integer.MAX_VALUE : Integer.parseInt(filterValue.substring(indexOfExclusive)); - return provider -> provider.getDimension() >= minDimensionId && provider.getDimension() <= maxDimensionId; + allPredicates.add(provider -> provider.getDimension() >= minDimensionId && provider.getDimension() <= maxDimensionId); } } else if (stringValue.startsWith("name:")) { stringSupplier = provider -> provider.getDimensionType().getName(); @@ -56,12 +56,16 @@ public static Predicate createWorldPredicate(JsonElement element) stringSupplier = provider -> provider.getClass().getSimpleName(); stringValue = stringValue.substring(15); } else throw new IllegalArgumentException("Unknown world predicate: " + stringValue); - if (stringValue.startsWith("*")) { - Pattern pattern = Pattern.compile(stringValue.substring(1)); - return provider -> pattern.matcher(stringSupplier.apply(provider)).matches(); - } else { - String finalStringValue = stringValue; - return provider -> finalStringValue.equalsIgnoreCase(stringSupplier.apply(provider)); + if (stringSupplier != null) { + if (stringValue.startsWith("*")) { + Pattern pattern = Pattern.compile(stringValue.substring(1)); + Function finalStringSupplier = stringSupplier; + allPredicates.add(provider -> pattern.matcher(finalStringSupplier.apply(provider)).matches()); + } else { + String finalStringValue = stringValue; + Function finalStringSupplier1 = stringSupplier; + allPredicates.add(provider -> finalStringValue.equalsIgnoreCase(finalStringSupplier1.apply(provider))); + } } }