Skip to content

Commit

Permalink
Remove broken containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed May 3, 2024
1 parent db7f6bf commit 475657f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
9 changes: 0 additions & 9 deletions loader/src/main/java/net/neoforged/fml/ModContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ public ModContainer(IModInfo info) {
this.modInfo = info;
}

/**
* Errored container state, used for filtering. Does nothing.
*/
ModContainer() {
modId = "BROKEN";
namespace = "BROKEN";
modInfo = null;
}

/**
* @return the modid for this mod
*/
Expand Down
20 changes: 4 additions & 16 deletions loader/src/main/java/net/neoforged/fml/ModLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
Expand All @@ -24,7 +25,6 @@
import java.util.stream.Collectors;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.event.IModBusEvent;
import net.neoforged.fml.event.lifecycle.FMLConstructModEvent;
import net.neoforged.fml.event.lifecycle.ParallelDispatchEvent;
Expand All @@ -42,7 +42,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

/**
* Contains the logic to load mods, i.e. turn the {@link LoadingModList} into the {@link ModList},
Expand Down Expand Up @@ -242,7 +241,7 @@ private static List<ModContainer> buildMods(final IModFile modFile) {
.getMods()
.stream()
.map(info -> buildModContainerFromTOML(info, modFile.getScanResult()))
.filter(o -> o != null && !(o instanceof ErroredModContainer))
.filter(Objects::nonNull)
.toList();
}

Expand All @@ -252,8 +251,8 @@ private static ModContainer buildModContainerFromTOML(final IModInfo modInfo, fi
} catch (ModLoadingException mle) {
// exceptions are caught and added to the error list for later handling
loadingIssues.addAll(mle.getIssues());
// return an errored container instance here, because we tried and failed building a container.
return new ErroredModContainer();
// return a null container here because we tried and failed building a container.
return null;
}
}

Expand Down Expand Up @@ -337,15 +336,4 @@ public static List<ModLoadingIssue> getLoadingIssues() {
public static void addLoadingIssue(ModLoadingIssue issue) {
loadingIssues.add(issue);
}

private static class ErroredModContainer extends ModContainer {
public ErroredModContainer() {
super();
}

@Override
public @Nullable IEventBus getEventBus() {
return null;
}
}
}

0 comments on commit 475657f

Please sign in to comment.