Server run profile, also setup logging for client profile.
This commit is contained in:
parent
2b23eb96fb
commit
1c9b5fae5e
17
build.gradle
17
build.gradle
|
@ -163,6 +163,8 @@ project(':forge') {
|
||||||
installer 'org.apache.maven:maven-artifact:3.5.3'
|
installer 'org.apache.maven:maven-artifact:3.5.3'
|
||||||
installer 'net.jodah:typetools:0.5.0'
|
installer 'net.jodah:typetools:0.5.0'
|
||||||
installer 'java3d:vecmath:1.5.2'
|
installer 'java3d:vecmath:1.5.2'
|
||||||
|
installer 'org.apache.logging.log4j:log4j-api:2.11.1'
|
||||||
|
installer 'org.apache.logging.log4j:log4j-core:2.11.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
task runclient(type: JavaExec, dependsOn: [":forge:downloadAssets", ":forge:extractNatives"]) {
|
task runclient(type: JavaExec, dependsOn: [":forge:downloadAssets", ":forge:extractNatives"]) {
|
||||||
|
@ -344,7 +346,16 @@ project(':forge') {
|
||||||
type: 'release',
|
type: 'release',
|
||||||
mainClass: 'cpw.mods.modlauncher.Launcher',
|
mainClass: 'cpw.mods.modlauncher.Launcher',
|
||||||
inheritsFrom: MC_VERSION,
|
inheritsFrom: MC_VERSION,
|
||||||
logging: [:],
|
logging: [ client: [
|
||||||
|
argument: '-Dlog4j.configurationFile=${path}',
|
||||||
|
file: [
|
||||||
|
id:'client-1.12.xml',
|
||||||
|
sha1:'ef4f57b922df243d0cef096efe808c72db042149',
|
||||||
|
size:877,
|
||||||
|
url:'https://launcher.mojang.com/v1/objects/ef4f57b922df243d0cef096efe808c72db042149/client-1.12.xml'
|
||||||
|
],
|
||||||
|
type: 'log4j2-xml'
|
||||||
|
]],
|
||||||
arguments: [
|
arguments: [
|
||||||
game: ['--launchTarget', 'fmlclient']
|
game: ['--launchTarget', 'fmlclient']
|
||||||
],
|
],
|
||||||
|
@ -545,7 +556,9 @@ project(':forge') {
|
||||||
artifacts.each { key, lib ->
|
artifacts.each { key, lib ->
|
||||||
classpath += "libraries/${lib.downloads.artifact.path} "
|
classpath += "libraries/${lib.downloads.artifact.path} "
|
||||||
}
|
}
|
||||||
classpath += "minecraft_server.${MC_VERSION}.jar"
|
classpath += "libraries/net/minecraft/server/${MC_VERSION}/server-${MC_VERSION}-data.jar "
|
||||||
|
classpath += "libraries/net/minecraft/server/${MC_VERSION}/server-${MC_VERSION}-extra.jar"
|
||||||
|
|
||||||
|
|
||||||
manifest.attributes([
|
manifest.attributes([
|
||||||
'Main-Class': 'net.minecraftforge.server.ServerMain',
|
'Main-Class': 'net.minecraftforge.server.ServerMain',
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
--- a/net/minecraft/client/gui/GuiConnecting.java
|
||||||
|
+++ b/net/minecraft/client/gui/GuiConnecting.java
|
||||||
|
@@ -62,6 +62,7 @@
|
||||||
|
GuiConnecting.this.field_146371_g.func_150719_a(new NetHandlerLoginClient(GuiConnecting.this.field_146371_g, GuiConnecting.this.field_146297_k, GuiConnecting.this.field_146374_i, (p_209549_1_) -> {
|
||||||
|
GuiConnecting.this.func_209514_a(p_209549_1_);
|
||||||
|
}));
|
||||||
|
+ net.minecraftforge.fml.network.NetworkHooks.registerClientLoginChannel(GuiConnecting.this.field_146371_g);
|
||||||
|
GuiConnecting.this.field_146371_g.func_179290_a(new CPacketHandshake(p_146367_1_, p_146367_2_, EnumConnectionState.LOGIN));
|
||||||
|
GuiConnecting.this.field_146371_g.func_179290_a(new CPacketLoginStart(GuiConnecting.this.field_146297_k.func_110432_I().func_148256_e()));
|
||||||
|
} catch (UnknownHostException unknownhostexception) {
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* 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.fml.loading;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.IEnvironment;
|
||||||
|
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
||||||
|
import cpw.mods.modlauncher.api.ITransformingClassLoader;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||||
|
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
public class FMLServerLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "fmlserver";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path[] identifyTransformationTargets()
|
||||||
|
{
|
||||||
|
Path libsPath = findLibsPath();
|
||||||
|
Path patchedBinariesPath = libsPath.resolve(Paths.get("net","minecraftforge","forge",MCPVersion.getMCVersion()+"-"+ForgeVersion.getVersion(),"forge-"+MCPVersion.getMCVersion()+"-"+ForgeVersion.getVersion()+"-server.jar"));
|
||||||
|
Path srgMcPath = libsPath.resolve(Paths.get("net","minecraft", "server", MCPVersion.getMCPandMCVersion(), "server-"+MCPVersion.getMCPandMCVersion()+"-srg.jar"));
|
||||||
|
LOGGER.info("SRG MC at {} is {}", srgMcPath.toString(), Files.exists(srgMcPath) ? "present" : "missing");
|
||||||
|
LOGGER.info("Forge patches at {} is {}", patchedBinariesPath.toString(), Files.exists(patchedBinariesPath) ? "present" : "missing");
|
||||||
|
LOGGER.info("Forge at {} is {}", getForgePath().toString(), Files.exists(getForgePath()) ? "present" : "missing");
|
||||||
|
if (!(Files.exists(srgMcPath) && Files.exists(patchedBinariesPath) && Files.exists(getForgePath()))) {
|
||||||
|
throw new RuntimeException("Failed to find patched jars");
|
||||||
|
}
|
||||||
|
return new Path[] {getForgePath(), patchedBinariesPath, srgMcPath};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Callable<Void> launchService(String[] arguments, ITransformingClassLoader launchClassLoader)
|
||||||
|
{
|
||||||
|
return () -> {
|
||||||
|
super.beforeStart(launchClassLoader);
|
||||||
|
launchClassLoader.addTargetPackageFilter(getPackagePredicate());
|
||||||
|
Class.forName("net.minecraft.server.MinecraftServer", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup(final IEnvironment environment) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dist getDist()
|
||||||
|
{
|
||||||
|
return Dist.DEDICATED_SERVER;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.minecraftforge.server;
|
||||||
|
|
||||||
|
import com.google.common.collect.ObjectArrays;
|
||||||
|
import cpw.mods.modlauncher.Launcher;
|
||||||
|
|
||||||
|
public class ServerMain {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
final String[] argArray = ObjectArrays.concat(new String[]{"--launchTarget", "fmlserver","--gameDir", "."}, args, String.class);
|
||||||
|
Launcher.main(argArray);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
net.minecraftforge.fml.loading.FMLClientLaunchProvider
|
net.minecraftforge.fml.loading.FMLClientLaunchProvider
|
||||||
|
net.minecraftforge.fml.loading.FMLServerLaunchProvider
|
||||||
net.minecraftforge.fml.loading.FMLDevClientLaunchProvider
|
net.minecraftforge.fml.loading.FMLDevClientLaunchProvider
|
||||||
net.minecraftforge.fml.loading.FMLDevServerLaunchProvider
|
net.minecraftforge.fml.loading.FMLDevServerLaunchProvider
|
Loading…
Reference in New Issue