Some tweaks to get the launcher working.
This commit is contained in:
parent
94e1a8e0a4
commit
09e2aeaec4
5 changed files with 62 additions and 5 deletions
|
@ -105,7 +105,7 @@ project(':forge') {
|
|||
}
|
||||
dependencies {
|
||||
api 'net.minecraft:client:1.13:extra'
|
||||
api 'cpw.mods:modlauncher:0.1.0-rc.3' //Pinned until cpw fixes getCommonSupertype
|
||||
api 'cpw.mods:modlauncher:0.1.0-rc.4+' //Pinned until cpw fixes getCommonSupertype
|
||||
api 'net.minecraftforge:accesstransformers:0.10+:shadowed'
|
||||
api 'net.minecraftforge:eventbus:0.1+:service'
|
||||
api 'net.minecraftforge:forgespi:0.1+'
|
||||
|
@ -117,6 +117,7 @@ project(':forge') {
|
|||
api 'java3d:vecmath:1.5.2'
|
||||
}
|
||||
|
||||
/*
|
||||
configurations {
|
||||
ecj
|
||||
}
|
||||
|
@ -124,6 +125,7 @@ project(':forge') {
|
|||
dependencies {
|
||||
ecj 'org.eclipse.jdt.core.compiler:ecj:4.6.1'
|
||||
}
|
||||
*/
|
||||
|
||||
/* Forge compiles, no longer need eclipse compiler
|
||||
compileJava {
|
||||
|
@ -177,6 +179,7 @@ project(':forge') {
|
|||
|
||||
include 'net/minecraftforge/'
|
||||
exclude 'net/minecraftforge/server/terminalconsole/'
|
||||
exclude 'net/minecraftforge/api/' // exclude API here because it's validated in the SPI build
|
||||
exclude 'net/minecraftforge/fml/common/versioning/ComparableVersion.java'
|
||||
exclude 'net/minecraftforge/fml/common/versioning/InvalidVersionSpecificationException.java'
|
||||
exclude 'net/minecraftforge/fml/common/versioning/Restriction.java'
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2018.
|
||||
*
|
||||
* 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.client.extensions;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -23,10 +23,15 @@ import com.electronwill.nightconfig.core.file.FileConfig;
|
|||
import net.minecraftforge.fml.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
|
||||
{
|
||||
|
@ -35,12 +40,17 @@ public class DefaultModInfos
|
|||
FileConfig forgemod;
|
||||
try
|
||||
{
|
||||
minecraftmod = FileConfig.of(Paths.get(DefaultModInfos.class.getClassLoader().getResource("minecraftmod.toml").toURI()));
|
||||
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));
|
||||
forgemod = FileConfig.of(Paths.get(DefaultModInfos.class.getClassLoader().getResource("forgemod.toml").toURI()));
|
||||
minecraftmod.load();
|
||||
forgemod.load();
|
||||
}
|
||||
catch (URISyntaxException | NullPointerException e)
|
||||
catch (IOException | URISyntaxException | NullPointerException e)
|
||||
{
|
||||
throw new RuntimeException("Missing toml configs for minecraft and forge!", e);
|
||||
}
|
||||
|
|
|
@ -23,11 +23,32 @@ import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
|||
import cpw.mods.modlauncher.api.ITransformingClassLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class FMLClientLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService
|
||||
{
|
||||
private static final Path forgePath;
|
||||
private static final Path mcPath;
|
||||
private static final List<String> SKIPPACKAGES = Arrays.asList(
|
||||
"joptsimple.", "org.lwjgl.", "com.mojang.", "com.google.",
|
||||
"org.apache.commons.", "io.netty.", "net.minecraftforge.fml.loading.", "net.minecraftforge.fml.language.",
|
||||
"net.minecraftforge.eventbus.", "it.unimi.dsi.fastutil.", "net.minecraftforge.api.",
|
||||
"paulscode.sound.", "com.ibm.icu.", "sun.", "gnu.trove.", "com.electronwill.nightconfig.",
|
||||
"net.minecraftforge.fml.common.versioning."
|
||||
);
|
||||
static {
|
||||
try {
|
||||
forgePath = Paths.get(FMLClientLaunchProvider.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||
mcPath = forgePath.resolveSibling("minecraft.jar");
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException("Unable to locate myself!");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String name()
|
||||
{
|
||||
|
@ -37,13 +58,16 @@ public class FMLClientLaunchProvider extends FMLCommonLaunchHandler implements I
|
|||
@Override
|
||||
public Path[] identifyTransformationTargets()
|
||||
{
|
||||
return new Path[0];
|
||||
return new Path[] {mcPath, forgePath};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Callable<Void> launchService(String[] arguments, ITransformingClassLoader launchClassLoader)
|
||||
{
|
||||
return () -> {
|
||||
super.beforeStart(launchClassLoader, forgePath);
|
||||
launchClassLoader.addTargetPackageFilter(cn -> SKIPPACKAGES.stream().noneMatch(cn::startsWith));
|
||||
Class.forName("net.minecraft.client.main.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments);
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -62,7 +63,7 @@ public class ModDiscoverer {
|
|||
|
||||
FMLLoader.getLanguageLoadingProvider().addAdditionalLanguages(modFiles.get(ModFile.Type.LANGPROVIDER));
|
||||
BackgroundScanHandler backgroundScanHandler = new BackgroundScanHandler();
|
||||
final List<ModFile> mods = modFiles.get(ModFile.Type.MOD);
|
||||
final List<ModFile> mods = modFiles.getOrDefault(ModFile.Type.MOD, Collections.emptyList());
|
||||
for (Iterator<ModFile> iterator = mods.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
ModFile mod = iterator.next();
|
||||
|
|
Loading…
Reference in a new issue