Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix separate multi dimensions in worldgen jsons #110

Merged
merged 2 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-GTCEU.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
- Fix Solar covers not properly outputting power to GT cables
- Fix Crowbar action on Powered Rails throwing errors in the log
- Fix Fluid Regulator "Keep Exact" mode not working
- Fix worldgen JSONs only using the first dimension listed in `dimension_filter`

### CraftTweaker
- Materials can now automatically generate IDs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ public static Predicate<WorldProvider> createWorldPredicate(JsonElement element)
allPredicates.add(wp -> wp.isNether() || wp.getDimensionType() == DimensionType.NETHER);
continue;
}
Function<WorldProvider, String> stringSupplier;
Function<WorldProvider, String> 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();
Expand All @@ -56,12 +56,16 @@ public static Predicate<WorldProvider> 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<WorldProvider, String> finalStringSupplier = stringSupplier;
allPredicates.add(provider -> pattern.matcher(finalStringSupplier.apply(provider)).matches());
} else {
String finalStringValue = stringValue;
Function<WorldProvider, String> finalStringSupplier1 = stringSupplier;
allPredicates.add(provider -> finalStringValue.equalsIgnoreCase(finalStringSupplier1.apply(provider)));
}
}
}

Expand Down