Fix NPE problem when modid is mismatched.
Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
parent
4a09a2420d
commit
0c5ced1bbf
2 changed files with 16 additions and 5 deletions
|
@ -75,6 +75,16 @@ public abstract class ModContainer
|
|||
(incoming, isNetwork)->Objects.equals(incoming, this.modInfo.getVersion().toString())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Errored container state, used for filtering. Does nothing.
|
||||
*/
|
||||
ModContainer()
|
||||
{
|
||||
this.modLoadingStage = ModLoadingStage.ERROR;
|
||||
modId = "BROKEN";
|
||||
namespace = "BROKEN";
|
||||
modInfo = null;
|
||||
}
|
||||
/**
|
||||
* @return the modid for this mod
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraftforge.fml.loading.LoadingModList;
|
|||
import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||
import net.minecraftforge.fml.network.FMLNetworkConstants;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
|
@ -282,7 +283,7 @@ public class ModLoader
|
|||
loadingExceptions.add(new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingclasses", null, modFile.getFilePath()));
|
||||
}
|
||||
// remove errored mod containers
|
||||
return containers.stream().filter(obj -> !(obj instanceof ErroredModContainer)).collect(Collectors.toList());
|
||||
return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private ModContainer buildModContainerFromTOML(final ModFile modFile, final TransformingClassLoader modClassLoader, final Map<String, IModInfo> modInfoMap, final Map.Entry<String, ? extends IModLanguageProvider.IModLanguageLoader> idToProviderEntry) {
|
||||
|
@ -297,7 +298,7 @@ public class ModLoader
|
|||
// exceptions are caught and added to the error list for later handling
|
||||
loadingExceptions.add(mle);
|
||||
// return an errored container instance here, because we tried and failed building a container.
|
||||
return new ErroredModContainer(mle);
|
||||
return new ErroredModContainer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,9 +342,9 @@ public class ModLoader
|
|||
return runningDataGen;
|
||||
}
|
||||
|
||||
static class ErroredModContainer extends ModContainer {
|
||||
public ErroredModContainer(final ModLoadingException mle) {
|
||||
super(mle.getModInfo());
|
||||
private static class ErroredModContainer extends ModContainer {
|
||||
public ErroredModContainer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue