Turned minecraft into a proper Mod, with a "dummy" language provider.
Also fixed the "translations" not being available early if an exception occurs by force loading the forge and MC ones. Closes #5984 Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
parent
44f3f9e2d0
commit
5048739b7f
18 changed files with 257 additions and 134 deletions
35
build.gradle
35
build.gradle
|
@ -243,6 +243,33 @@ project(':forge') {
|
|||
source sourceSets.userdev
|
||||
}
|
||||
|
||||
cpw_forge_client {
|
||||
taskName 'cpw_forge_client'
|
||||
|
||||
main 'net.minecraftforge.userdev.LaunchTesting'
|
||||
workingDirectory project.file('run')
|
||||
|
||||
environment 'target', 'fmldevclient'
|
||||
environment 'assetIndex', '{asset_index}'
|
||||
environment 'assetDirectory', downloadAssets.output
|
||||
environment 'nativesDirectory', extractNatives.output
|
||||
|
||||
environment 'MC_VERSION', MC_VERSION
|
||||
environment 'MCP_VERSION', MCP_VERSION
|
||||
environment 'FORGE_GROUP', project.group
|
||||
environment 'FORGE_SPEC', SPEC_VERSION
|
||||
environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1).toString()
|
||||
environment 'LAUNCHER_VERSION', SPEC_VERSION
|
||||
property 'terminal.ansi', 'true'
|
||||
property 'forge.logging.noansi', 'false'
|
||||
property 'org.lwjgl.system.SharedLibraryExtractDirectory', 'lwjgl_dll'
|
||||
|
||||
ideaModule "${rootProject.name}.${project.name}.userdev"
|
||||
|
||||
source sourceSets.main
|
||||
source sourceSets.userdev
|
||||
}
|
||||
|
||||
forge_test_client {
|
||||
parent runs.forge_client
|
||||
taskName 'forge_test_client'
|
||||
|
@ -342,6 +369,14 @@ project(':forge') {
|
|||
'Implementation-Version': SPEC_VERSION,
|
||||
'Implementation-Vendor': 'Forge'
|
||||
] as LinkedHashMap,
|
||||
'net/minecraftforge/fml/mclanguageprovider/': [
|
||||
'Specification-Title': 'Mod Language Provider',
|
||||
'Specification-Vendor': 'Forge Development LLC',
|
||||
'Specification-Version': '1',
|
||||
'Implementation-Title': 'Minecraft Language Mod Provider',
|
||||
'Implementation-Version': '1',
|
||||
'Implementation-Vendor': 'Forge'
|
||||
] as LinkedHashMap,
|
||||
'net/minecraftforge/fml/loading/': [
|
||||
'Specification-Title': 'Launcher',
|
||||
'Specification-Vendor': 'Forge Development LLC',
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.loading;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.FileConfig;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DefaultModInfos
|
||||
{
|
||||
static {
|
||||
FileConfig minecraftmod;
|
||||
try
|
||||
{
|
||||
final URI jarFileURI = DefaultModInfos.class.getClassLoader().getResource("minecraftmod.toml").toURI();
|
||||
if (Objects.equals(jarFileURI.getScheme(), "jar")) {
|
||||
// Initialize the filesystem for the forge jar, because otherwise this barfs?
|
||||
FileSystems.newFileSystem(jarFileURI, new HashMap<>());
|
||||
}
|
||||
minecraftmod = FileConfig.of(Paths.get(jarFileURI));
|
||||
minecraftmod.load();
|
||||
}
|
||||
catch (IOException | URISyntaxException | NullPointerException e)
|
||||
{
|
||||
throw new RuntimeException("Missing toml config for minecraft!", e);
|
||||
}
|
||||
minecraftModInfo = new ModInfo(null, minecraftmod);
|
||||
}
|
||||
|
||||
public static final IModInfo minecraftModInfo;
|
||||
|
||||
// no construction
|
||||
private DefaultModInfos() {}
|
||||
|
||||
public static List<IModInfo> getModInfos()
|
||||
{
|
||||
return Arrays.asList(minecraftModInfo);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -52,7 +52,7 @@ public class LoadingModList
|
|||
private LoadingModList(final List<ModFile> modFiles, final List<ModInfo> sortedList)
|
||||
{
|
||||
this.modFiles = modFiles.stream().map(ModFile::getModFileInfo).map(ModFileInfo.class::cast).collect(Collectors.toList());
|
||||
this.sortedList = Streams.concat(DefaultModInfos.getModInfos().stream(), sortedList.stream()).
|
||||
this.sortedList = sortedList.stream().
|
||||
map(ModInfo.class::cast).
|
||||
collect(Collectors.toList());
|
||||
this.fileById = this.modFiles.stream().map(ModFileInfo::getMods).flatMap(Collection::stream).
|
||||
|
|
|
@ -144,7 +144,7 @@ public class ModSorter
|
|||
|
||||
private void buildUniqueList()
|
||||
{
|
||||
final Stream<ModInfo> modInfos = Stream.concat(DefaultModInfos.getModInfos().stream(), modFiles.stream().map(ModFile::getModInfos).flatMap(Collection::stream)).map(ModInfo.class::cast);
|
||||
final Stream<ModInfo> modInfos = modFiles.stream().map(ModFile::getModInfos).flatMap(Collection::stream).map(ModInfo.class::cast);
|
||||
final Map<String, List<ModInfo>> modIds = modInfos.collect(Collectors.groupingBy(IModInfo::getModId));
|
||||
|
||||
// TODO: make this figure out dupe handling better
|
||||
|
@ -162,8 +162,8 @@ public class ModSorter
|
|||
|
||||
private void verifyDependencyVersions()
|
||||
{
|
||||
final Map<String, ArtifactVersion> modVersions = Stream.concat(modFiles.stream().map(ModFile::getModInfos).
|
||||
flatMap(Collection::stream), DefaultModInfos.getModInfos().stream()).collect(Collectors.toMap(IModInfo::getModId, IModInfo::getVersion));
|
||||
final Map<String, ArtifactVersion> modVersions = modFiles.stream().map(ModFile::getModInfos).
|
||||
flatMap(Collection::stream).collect(Collectors.toMap(IModInfo::getModId, IModInfo::getVersion));
|
||||
final Map<IModInfo, List<IModInfo.ModVersion>> modVersionDependencies = modFiles.stream().
|
||||
map(ModFile::getModInfos).flatMap(Collection::stream).
|
||||
collect(Collectors.groupingBy(Function.identity(), Java9BackportUtils.flatMapping(e -> e.getDependencies().stream(), Collectors.toList())));
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package net.minecraftforge.fml.loading.moddiscovery;
|
||||
|
||||
import net.minecraftforge.fml.loading.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
|
|
@ -26,15 +26,30 @@ import net.minecraftforge.fml.loading.ModSorter;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipError;
|
||||
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
||||
|
@ -49,6 +64,7 @@ public class ModDiscoverer {
|
|||
locators = ServiceLoader.load(IModLocator.class);
|
||||
locatorList = ServiceLoaderStreamUtils.toList(this.locators);
|
||||
locatorList.forEach(l->l.initArguments(arguments));
|
||||
locatorList.add(new MinecraftLocator());
|
||||
LOGGER.debug(CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(",")));
|
||||
}
|
||||
|
||||
|
@ -88,7 +104,95 @@ public class ModDiscoverer {
|
|||
return backgroundScanHandler;
|
||||
}
|
||||
|
||||
public void addExplodedTarget(final Path compiledClasses, final Path forgemodstoml) {
|
||||
private static class MinecraftLocator implements IModLocator {
|
||||
private final Path mcJar = FMLLoader.getMCPaths()[0];
|
||||
private final FileSystem fileSystem;
|
||||
|
||||
MinecraftLocator() {
|
||||
if (!Files.isDirectory(mcJar)) {
|
||||
try {
|
||||
fileSystem = FileSystems.newFileSystem(mcJar, getClass().getClassLoader());
|
||||
} catch (ZipError | IOException e) {
|
||||
LOGGER.fatal(SCAN,"Invalid Minecraft JAR file - no filesystem created");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
fileSystem = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModFile> scanMods() {
|
||||
return Collections.singletonList(new ModFile(mcJar, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "minecraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path findPath(final ModFile modFile, final String... path) {
|
||||
String[] newPath = Arrays.copyOf(path, path.length);
|
||||
if (path.length == 2 && Objects.equals(path[1], "mods.toml")) {
|
||||
final URI jarFileURI;
|
||||
try {
|
||||
jarFileURI = getClass().getClassLoader().getResource("minecraftmod.toml").toURI();
|
||||
if (Objects.equals(jarFileURI.getScheme(), "jar")) {
|
||||
// Initialize the filesystem for the forge jar, because otherwise this barfs?
|
||||
FileSystems.newFileSystem(jarFileURI, new HashMap<>());
|
||||
}
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
LOGGER.fatal(SCAN, "Unable to read minecraft default mod");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return Paths.get(jarFileURI);
|
||||
}
|
||||
if (Files.isDirectory(mcJar)) return findPathDirectory(modFile, path);
|
||||
return findPathJar(modFile, path);
|
||||
}
|
||||
|
||||
private Path findPathDirectory(final ModFile modFile, final String... path) {
|
||||
if (path.length < 1) {
|
||||
throw new IllegalArgumentException("Missing path");
|
||||
}
|
||||
final Path target = Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length));
|
||||
// try right path first (resources)
|
||||
return mcJar.resolve(target);
|
||||
}
|
||||
|
||||
private Path findPathJar(final ModFile modFile, final String... path) {
|
||||
return fileSystem.getPath(path[0], Arrays.copyOfRange(path, 1, path.length));
|
||||
}
|
||||
@Override
|
||||
public void scanFile(final ModFile modFile, final Consumer<Path> pathConsumer) {
|
||||
LOGGER.debug(SCAN,"Scan started: {}", modFile);
|
||||
Path path;
|
||||
if (Files.isDirectory(mcJar))
|
||||
path = mcJar;
|
||||
else
|
||||
path = fileSystem.getPath("/");
|
||||
try (Stream<Path> files = Files.find(path, Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) {
|
||||
files.forEach(pathConsumer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LOGGER.debug(SCAN,"Scan finished: {}", modFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Manifest> findManifest(final Path file) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArguments(final Map<String, ?> arguments) {
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ModFile modFile) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
modId="minecraft"
|
||||
version="${global.mcVersion}"
|
||||
displayName="Minecraft"
|
||||
logoFile="mcplogo.png"
|
||||
credits="Mojang, deobfuscated by MCP"
|
||||
authors="MCP: Searge,ProfMobius,IngisKahn,Fesh0r,ZeuX,R4wk,LexManos,Bspkrs"
|
||||
description='''
|
||||
Minecraft, decompiled and deobfuscated with MCP technology
|
||||
'''
|
||||
modLoader="minecraft"
|
||||
loaderVersion="1"
|
||||
[[mods]]
|
||||
modId="minecraft"
|
||||
version="${global.mcVersion}"
|
||||
displayName="Minecraft"
|
||||
logoFile="mcplogo.png"
|
||||
credits="Mojang, deobfuscated by MCP"
|
||||
authors="MCP: Searge,ProfMobius,IngisKahn,Fesh0r,ZeuX,R4wk,LexManos,Bspkrs"
|
||||
description='''
|
||||
Minecraft, decompiled and deobfuscated with MCP technology
|
||||
'''
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.fml.loading.DefaultModInfos;
|
||||
|
||||
public class DefaultModContainers
|
||||
{
|
||||
public static final ModContainer MINECRAFT = new ModContainer(DefaultModInfos.minecraftModInfo)
|
||||
{
|
||||
@Override
|
||||
public boolean matches(final Object mod)
|
||||
{
|
||||
return mod == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMod()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -41,7 +41,11 @@ public class ModLoadingContext
|
|||
}
|
||||
|
||||
public ModContainer getActiveContainer() {
|
||||
return activeContainer == null ? DefaultModContainers.MINECRAFT : activeContainer;
|
||||
return activeContainer == null ? ModList.get().getModContainerById("minecraft").orElseThrow(()->new RuntimeException("Where is minecraft???!")) : activeContainer;
|
||||
}
|
||||
|
||||
public String getActiveNamespace() {
|
||||
return activeContainer == null ? "minecraft" : activeContainer.getNamespace();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,12 +20,11 @@
|
|||
package net.minecraftforge.fml;
|
||||
|
||||
import com.google.common.collect.Streams;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +52,7 @@ public class ModLoadingException extends RuntimeException
|
|||
private final List<Object> context;
|
||||
|
||||
public ModLoadingException(final IModInfo modInfo, final ModLoadingStage errorStage, final String i18nMessage, final Throwable originalException, Object... context) {
|
||||
super("Mod Loading Exception : " + i18nMessage + " " + Arrays.toString(Streams.concat(Stream.of(modInfo.getModId(), errorStage, originalException), Stream.of(context)).toArray()), originalException);
|
||||
super("Mod Loading Exception", originalException);
|
||||
this.modInfo = modInfo;
|
||||
this.errorStage = errorStage;
|
||||
this.i18nMessage = i18nMessage;
|
||||
|
@ -75,4 +74,9 @@ public class ModLoadingException extends RuntimeException
|
|||
public String formatToString() {
|
||||
return ForgeI18n.parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, errorStage, getCause()), context.stream()).toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return formatToString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,10 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.resources.DownloadingPackFinder;
|
||||
import net.minecraft.client.resources.ClientResourcePackInfo;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.*;
|
||||
import net.minecraft.resources.IFutureReloadListener;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.ResourcePackList;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
|
@ -31,10 +34,17 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
|
|||
import net.minecraftforge.common.ForgeConfig;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.*;
|
||||
import net.minecraftforge.fml.BrandingControl;
|
||||
import net.minecraftforge.fml.LoadingFailedException;
|
||||
import net.minecraftforge.fml.LogicalSidedProvider;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingWarning;
|
||||
import net.minecraftforge.fml.SidedProvider;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.client.gui.LoadingErrorScreen;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.packs.ResourcePackLoader;
|
||||
import net.minecraftforge.fml.server.LanguageHook;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -64,6 +74,7 @@ public class ClientModLoader
|
|||
ClientModLoader.mc = minecraft;
|
||||
SidedProvider.setClient(()->minecraft);
|
||||
LogicalSidedProvider.setClient(()->minecraft);
|
||||
LanguageHook.loadForgeAndMCLangs();
|
||||
earlyLoaderGUI = new EarlyLoaderGUI(minecraft.mainWindow);
|
||||
createRunnableWithCatch(() -> ModLoader.get().gatherAndInitializeMods(earlyLoaderGUI::renderTick)).run();
|
||||
ResourcePackLoader.loadResourcePacks(defaultResourcePacks);
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package net.minecraftforge.fml.mclanguageprovider;
|
||||
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.forgespi.language.ILifecycleEvent;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.minecraftforge.fml.Logging.LOADING;
|
||||
|
||||
public class MinecraftModLanguageProvider implements IModLanguageProvider {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@Override
|
||||
public String name() {
|
||||
return "minecraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<ModFileScanData> getFileVisitor() {
|
||||
return (sd)->sd.addLanguageLoader(Collections.singletonMap("minecraft", new MinecraftModTarget()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends ILifecycleEvent<R>> void consumeLifecycleEvent(final Supplier<R> consumeEvent) {
|
||||
|
||||
}
|
||||
|
||||
public static class MinecraftModTarget implements IModLanguageLoader {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T loadMod(final IModInfo info, final ClassLoader modClassLoader, final ModFileScanData modFileScanResults) {
|
||||
try {
|
||||
final Class<?> mcModClass = Class.forName("net.minecraftforge.fml.mclanguageprovider.MinecraftModLanguageProvider$MinecraftModContainer", true, modClassLoader);
|
||||
return (T)mcModClass.getConstructor(IModInfo.class).newInstance(info);
|
||||
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
|
||||
LOGGER.fatal(LOADING,"Unable to load MinecraftModContainer, wut?", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class MinecraftModContainer extends ModContainer {
|
||||
private static final String MCMODINSTANCE = "minecraft, the mod";
|
||||
|
||||
public MinecraftModContainer(final IModInfo info) {
|
||||
super(info);
|
||||
contextExtension = ()->null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final Object mod) {
|
||||
return Objects.equals(mod, MCMODINSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMod() {
|
||||
return MCMODINSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import static net.minecraftforge.fml.Logging.CORE;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -56,6 +57,7 @@ public class ResourcePackLoader
|
|||
public static <T extends ResourcePackInfo> void loadResourcePacks(ResourcePackList<T> resourcePacks) {
|
||||
resourcePackList = resourcePacks;
|
||||
modResourcePacks = ModList.get().getModFiles().stream().
|
||||
filter(mf->!Objects.equals(mf.getModLoader(),"minecraft")).
|
||||
map(mf -> new ModFileResourcePack(mf.getFile())).
|
||||
collect(Collectors.toMap(ModFileResourcePack::getModFile, Function.identity()));
|
||||
resourcePacks.addPackFinder(new ModPackFinder());
|
||||
|
@ -69,6 +71,7 @@ public class ResourcePackLoader
|
|||
for (Entry<ModFile, ModFileResourcePack> e : modResourcePacks.entrySet())
|
||||
{
|
||||
IModInfo mod = e.getKey().getModInfos().get(0);
|
||||
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
|
||||
final String name = "mod:" + mod.getModId();
|
||||
final T packInfo = ResourcePackInfo.createResourcePack(name, true, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM);
|
||||
if (packInfo == null) {
|
||||
|
|
|
@ -92,7 +92,7 @@ public class LanguageHook
|
|||
|
||||
}
|
||||
|
||||
static void loadForgeAndMCLangs() {
|
||||
public static void loadForgeAndMCLangs() {
|
||||
modTable = new HashMap<>(5000);
|
||||
final InputStream mc = Thread.currentThread().getContextClassLoader().getResourceAsStream("assets/minecraft/lang/en_us.json");
|
||||
final InputStream forge = Thread.currentThread().getContextClassLoader().getResourceAsStream("assets/forge/lang/en_us.json");
|
||||
|
|
|
@ -304,7 +304,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
|
|||
|
||||
int add(int id, V value)
|
||||
{
|
||||
final String owner = ModLoadingContext.get().getActiveContainer().getNamespace();
|
||||
final String owner = ModLoadingContext.get().getActiveNamespace();
|
||||
return add(id, value, owner);
|
||||
}
|
||||
|
||||
|
|
|
@ -936,7 +936,7 @@ public class GameData
|
|||
int index = name.lastIndexOf(':');
|
||||
String oldPrefix = index == -1 ? "" : name.substring(0, index).toLowerCase(Locale.ROOT);
|
||||
name = index == -1 ? name : name.substring(index + 1);
|
||||
String prefix = ModLoadingContext.get().getActiveContainer().getNamespace();
|
||||
String prefix = ModLoadingContext.get().getActiveNamespace();
|
||||
if (warnOverrides && !oldPrefix.equals(prefix) && oldPrefix.length() > 0)
|
||||
{
|
||||
LogManager.getLogger().info("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class ObjectHolderRegistry
|
|||
|
||||
// double pass - get all the class level annotations first, then the field level annotations
|
||||
annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType())).filter(a -> a.getTargetType() == ElementType.TYPE)
|
||||
.forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), null, (String)data.getAnnotationData().get("value"), true, data.getClassType().getClassName().startsWith("net.minecraft.")));
|
||||
.forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), null, (String)data.getAnnotationData().get("value"), true, data.getClassType().getClassName().startsWith("net.minecraft.")));
|
||||
|
||||
annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType())).filter(a -> a.getTargetType() == ElementType.FIELD)
|
||||
.forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), data.getMemberName(), (String)data.getAnnotationData().get("value"), false, false));
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider
|
||||
net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider
|
||||
net.minecraftforge.fml.mclanguageprovider.MinecraftModLanguageProvider
|
Loading…
Reference in a new issue