Skip to content

Commit

Permalink
Store a stream reference directly instead of predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Feb 4, 2024
1 parent c04f4d3 commit 1fc7676
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ModValidator {
private static final Logger LOGGER = LogUtils.getLogger();
Expand Down Expand Up @@ -72,7 +73,7 @@ public ITransformationService.Resource getPluginResources() {
}

public ITransformationService.Resource getModResources() {
Predicate<IModFile> shouldLoadResource;
Stream<ModFile> modFileStream = this.candidateMods.stream();
if (FMLEnvironment.production) {
// In production, only allow game libraries and/or mods in the loading mod list
// This prevents custom mixins from loading if there is a dependency error
Expand All @@ -81,13 +82,9 @@ public ITransformationService.Resource getModResources() {
Set<IModFile> validMods = new HashSet<>();
validMods.addAll(this.loadingModList.getModFiles().stream().map(ModFileInfo::getFile).toList());
validMods.addAll(this.gameLibraries);
shouldLoadResource = validMods::contains;
} else {
// In dev, allow any candidate mod to be loaded, as otherwise the --mixin.config argument
// will throw if there is a dependency error due to the mixin config being filtered.
shouldLoadResource = file -> true;
modFileStream = modFileStream.filter(validMods::contains);
}
return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().filter(shouldLoadResource).map(IModFile::getSecureJar).toList());
return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, modFileStream.map(IModFile::getSecureJar).toList());
}

private List<EarlyLoadingException.ExceptionData> validateLanguages() {
Expand Down

0 comments on commit 1fc7676

Please sign in to comment.