2018-04-07 22:15:32 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
2018-04-07 22:15:32 +00:00
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2018-04-08 00:38:43 +00:00
|
|
|
import cpw.mods.modlauncher.api.IEnvironment;
|
2018-04-07 22:15:32 +00:00
|
|
|
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
2018-06-06 15:37:56 +00:00
|
|
|
import cpw.mods.modlauncher.api.ITransformingClassLoader;
|
2019-02-05 02:23:58 +00:00
|
|
|
import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder;
|
2018-06-21 19:37:32 +00:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
2018-12-31 21:33:54 +00:00
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
2018-08-27 17:10:07 +00:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2018-04-07 22:15:32 +00:00
|
|
|
|
|
|
|
import java.nio.file.Path;
|
2018-12-31 21:33:54 +00:00
|
|
|
import java.util.ArrayList;
|
2019-01-04 16:44:57 +00:00
|
|
|
import java.util.Collections;
|
2018-06-11 01:12:46 +00:00
|
|
|
import java.util.List;
|
2018-12-31 21:33:54 +00:00
|
|
|
import java.util.Map;
|
2018-04-07 22:15:32 +00:00
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
|
2018-12-31 21:33:54 +00:00
|
|
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
2018-04-08 00:38:43 +00:00
|
|
|
|
2018-06-06 15:37:56 +00:00
|
|
|
public class FMLDevClientLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService
|
2018-04-07 22:15:32 +00:00
|
|
|
{
|
2018-08-27 17:10:07 +00:00
|
|
|
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
2018-12-31 21:33:54 +00:00
|
|
|
private Path compiledClasses;
|
2019-01-02 02:35:23 +00:00
|
|
|
private Path resources;
|
2018-08-27 17:10:07 +00:00
|
|
|
|
2018-04-07 22:15:32 +00:00
|
|
|
@Override
|
|
|
|
public String name()
|
|
|
|
{
|
2018-07-01 20:10:13 +00:00
|
|
|
return "fmldevclient";
|
2018-04-07 22:15:32 +00:00
|
|
|
}
|
|
|
|
|
2019-01-02 02:35:23 +00:00
|
|
|
@Override
|
2019-01-01 21:50:04 +00:00
|
|
|
public Path getForgePath(final String mcVersion, final String forgeVersion, final String forgeGroup) {
|
2018-12-31 21:33:54 +00:00
|
|
|
// In forge dev, we just find the path for ForgeVersion for everything
|
|
|
|
compiledClasses = LibraryFinder.findJarPathFor("net/minecraftforge/versions/forge/ForgeVersion.class", "forge");
|
2019-01-02 02:35:23 +00:00
|
|
|
resources = LibraryFinder.findJarPathFor("assets/minecraft/lang/en_us.json", "mcassets");
|
2018-12-31 21:33:54 +00:00
|
|
|
return compiledClasses;
|
|
|
|
}
|
|
|
|
|
2019-01-02 02:35:23 +00:00
|
|
|
@Override
|
|
|
|
public Path[] getMCPaths(final String mcVersion, final String mcpVersion, final String forgeVersion, final String forgeGroup) {
|
2018-12-31 21:33:54 +00:00
|
|
|
// In forge dev, we just find the path for ForgeVersion for everything
|
2019-01-02 02:35:23 +00:00
|
|
|
return new Path[] { compiledClasses, resources };
|
2018-06-23 02:45:01 +00:00
|
|
|
}
|
|
|
|
|
2019-02-05 02:23:58 +00:00
|
|
|
@Override
|
|
|
|
public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder)
|
|
|
|
{
|
|
|
|
super.configureTransformationClassLoader(builder);
|
|
|
|
builder.addTransformationPath(LibraryFinder.findJarPathFor("com/mojang/realmsclient/RealmsVersion.class", "realms"));
|
|
|
|
}
|
|
|
|
|
2018-04-07 22:15:32 +00:00
|
|
|
@Override
|
2018-06-06 15:37:56 +00:00
|
|
|
public Callable<Void> launchService(String[] arguments, ITransformingClassLoader launchClassLoader)
|
2018-04-07 22:15:32 +00:00
|
|
|
{
|
|
|
|
return () -> {
|
2018-08-27 17:10:07 +00:00
|
|
|
LOGGER.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments);
|
2018-10-05 03:24:02 +00:00
|
|
|
super.beforeStart(launchClassLoader);
|
2018-10-04 23:28:45 +00:00
|
|
|
launchClassLoader.addTargetPackageFilter(getPackagePredicate());
|
2018-06-06 15:37:56 +00:00
|
|
|
Class.forName("net.minecraft.client.main.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments);
|
2018-04-07 22:15:32 +00:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
}
|
2018-04-08 00:38:43 +00:00
|
|
|
|
2018-12-31 21:33:54 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
2018-04-08 00:38:43 +00:00
|
|
|
@Override
|
2018-12-31 21:33:54 +00:00
|
|
|
public void setup(IEnvironment environment, final Map<String, ?> arguments)
|
2018-04-08 00:38:43 +00:00
|
|
|
{
|
2018-12-31 21:33:54 +00:00
|
|
|
// we're injecting forge into the exploded dir finder
|
|
|
|
final Path forgemodstoml = LibraryFinder.findJarPathFor("META-INF/mods.toml", "forgemodstoml");
|
2019-01-04 16:44:57 +00:00
|
|
|
((Map<String, List<Pair<Path,List<Path>>>>) arguments).computeIfAbsent("explodedTargets", a->new ArrayList<>()).
|
|
|
|
add(Pair.of(forgemodstoml, Collections.singletonList(compiledClasses)));
|
2019-01-26 17:55:08 +00:00
|
|
|
|
|
|
|
processModClassesEnvironmentVariable((Map<String, List<Pair<Path, List<Path>>>>) arguments);
|
2018-04-08 00:38:43 +00:00
|
|
|
}
|
2018-06-06 15:37:56 +00:00
|
|
|
|
|
|
|
@Override
|
2018-06-21 19:37:32 +00:00
|
|
|
public Dist getDist()
|
2018-06-06 15:37:56 +00:00
|
|
|
{
|
2018-06-21 19:37:32 +00:00
|
|
|
return Dist.CLIENT;
|
2018-06-06 15:37:56 +00:00
|
|
|
}
|
2019-01-01 21:50:04 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void validatePaths(final Path forgePath, final Path[] mcPaths, final String forgeVersion, final String mcVersion, final String mcpVersion) {
|
|
|
|
}
|
2018-04-07 22:15:32 +00:00
|
|
|
}
|