Switch to the MCPHackers launchwrapper
This commit is contained in:
parent
6d1e4d58fc
commit
71c280c1e2
2 changed files with 46 additions and 72 deletions
|
@ -1,9 +1,5 @@
|
|||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* This generated file contains a sample Java application project to get you started.
|
||||
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.5/userguide/building_java_projects.html in the Gradle documentation.
|
||||
*/
|
||||
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
|
||||
plugins {
|
||||
// Apply the application plugin to add support for building a CLI application in Java.
|
||||
|
@ -12,6 +8,31 @@ plugins {
|
|||
id 'java'
|
||||
}
|
||||
|
||||
project.ext.lwjglVersion = "2.9.3"
|
||||
project.ext.set('nativeLibsDir', "$buildDir/libs/natives")
|
||||
|
||||
|
||||
switch (OperatingSystem.current()) {
|
||||
case OperatingSystem.LINUX:
|
||||
project.ext.lwjglNatives = "natives-linux"
|
||||
def osArch = System.getProperty("os.arch")
|
||||
if (osArch.startsWith("arm") || osArch.startsWith("aarch64")) {
|
||||
project.ext.lwjglNatives += osArch.contains("64") || osArch.startsWith("armv8") ? "-arm64" : "-arm32"
|
||||
} else if (osArch.startsWith("ppc")) {
|
||||
project.ext.lwjglNatives += "-ppc64le"
|
||||
} else if (osArch.startsWith("riscv")) {
|
||||
project.ext.lwjglNatives += "-riscv64"
|
||||
}
|
||||
break
|
||||
case OperatingSystem.MAC_OS:
|
||||
project.ext.lwjglNatives = "natives-macos"
|
||||
break
|
||||
case OperatingSystem.WINDOWS:
|
||||
project.ext.lwjglNatives = "natives-windows"
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
configurations {
|
||||
provided
|
||||
natives
|
||||
|
@ -37,12 +58,16 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
provided ("net.java.jinput:jinput-platform:2.0.7")
|
||||
provided platform("net.java.jinput:jinput-platform:2.0.7")
|
||||
provided ("net.java.jutils:jutils:1.0.0")
|
||||
provided ("org.lwjgl.lwjgl:lwjgl:2.9.3")
|
||||
provided ("org.lwjgl.lwjgl:lwjgl_util:2.9.3")
|
||||
provided ("org.lwjgl.lwjgl:lwjgl-platform:2.9.3")
|
||||
provided ("dev.zontreck:LibAC:1.5.11")
|
||||
|
||||
|
||||
provided "org.lwjgl.lwjgl:lwjgl:$lwjglVersion"
|
||||
provided "org.lwjgl.lwjgl:lwjgl_util:$lwjglVersion"
|
||||
provided platform("org.lwjgl.lwjgl:lwjgl-platform:$lwjglVersion-$lwjglNatives")
|
||||
|
||||
|
||||
provided 'org.mcphackers:launchwrapper:1.0'
|
||||
}
|
||||
|
||||
// Apply a specific Java toolchain to ease working on different environments.
|
||||
|
@ -54,16 +79,18 @@ java {
|
|||
|
||||
application {
|
||||
// Define the main class for the application.
|
||||
mainClass = 'com.mojang.minecraft.Minecraft'
|
||||
mainClass = 'org.mcphackers.launchwrapper.Launch'
|
||||
}
|
||||
|
||||
jar {
|
||||
duplicatesStrategy = "exclude"
|
||||
manifest {
|
||||
attributes (
|
||||
'Main-Class': application.mainClass,
|
||||
'Multi-Release': 'true',
|
||||
'Class-Path': configurations.provided.files.collect{"lib/${it.name}"}.join(' ')
|
||||
'Multi-Release': 'true'
|
||||
)
|
||||
}from {
|
||||
configurations.provided.collect { it.isDirectory() ? it : zipTree(it)}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +101,7 @@ task copyToLib(type: Copy) {
|
|||
}
|
||||
|
||||
task copyNatives(type: Copy) {
|
||||
into "${buildDir}/libs/natives"
|
||||
into project.nativeLibsDir
|
||||
duplicatesStrategy = "exclude"
|
||||
configurations.provided.asFileTree.each {
|
||||
if(it.isFile())
|
||||
|
@ -87,6 +114,8 @@ task jarjar(type: Jar) {
|
|||
'Main-Class': application.mainClass,
|
||||
'Multi-Release': 'true'
|
||||
)
|
||||
}from {
|
||||
configurations.provided.collect { it.isDirectory() ? it : zipTree(it)}
|
||||
}
|
||||
archiveClassifier = "AIO"
|
||||
duplicatesStrategy = "exclude"
|
||||
|
@ -99,8 +128,9 @@ task jarjar(type: Jar) {
|
|||
with copyNatives
|
||||
}
|
||||
|
||||
|
||||
run {
|
||||
jvmArgs("-Djava.library.path=./natives")
|
||||
jvmArgs ["-Djava.library.path=${project.nativeLibsDir}",]
|
||||
}
|
||||
|
||||
jar.finalizedBy(jarjar)
|
||||
|
|
|
@ -43,10 +43,6 @@ import java.time.Instant;
|
|||
import java.util.*;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import dev.zontreck.ariaslib.args.*;
|
||||
import dev.zontreck.ariaslib.http.HTTPMethod;
|
||||
import dev.zontreck.ariaslib.http.HTTPRequestBuilder;
|
||||
import dev.zontreck.ariaslib.http.HTTPResponse;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.input.Controllers;
|
||||
|
@ -1199,56 +1195,4 @@ public final class Minecraft implements Runnable {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Minecraft minecraft = new Minecraft((Canvas)null, 800, 600, false);
|
||||
|
||||
Random rng = new Random();
|
||||
rng.setSeed(Instant.now().getEpochSecond());
|
||||
|
||||
Arguments defaults = ArgumentsBuilder.builder().withArgument(new StringArgument("username", "Player" + String.valueOf(rng.nextInt()).substring(5)))
|
||||
.build();
|
||||
|
||||
Arguments parser = ArgumentsParser.parseArguments(args, defaults);
|
||||
StringArgument unArg = (StringArgument) parser.getArg("username");
|
||||
|
||||
if(parser.hasArg("username")) minecraft.user = new User(unArg.getValue(), System.getProperty("minecraft.auth_token"));
|
||||
|
||||
if(parser.hasArg("server"))
|
||||
{
|
||||
IntegerArgument serverArg = (IntegerArgument) parser.getArg("server");
|
||||
|
||||
// Acquire the server ip and port from Aria's Creations
|
||||
HTTPResponse response = null;
|
||||
try {
|
||||
response = HTTPRequestBuilder.builder()
|
||||
.withURL("https://api.zontreck.com/crafting/yggdrasil/legacy/server.php")
|
||||
.withContentType("application/x-www-form-urlencoded")
|
||||
.withMethod(HTTPMethod.POST)
|
||||
.withBody("id=" + serverArg.getValue() +
|
||||
"&username=" + minecraft.user.name)
|
||||
.build();
|
||||
} catch (MalformedURLException e) {
|
||||
System.out.println("An error occured: " + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if(response.getResponseCode()==200)
|
||||
{
|
||||
System.out.println("Response is valid, server found at: " + response.getResponseBody());
|
||||
String[] lReply = response.getResponseBody().split(";");
|
||||
minecraft.server = lReply[0];
|
||||
minecraft.port = Integer.parseInt(lReply[1]);
|
||||
minecraft.user.mpPass = lReply[2];
|
||||
}else {
|
||||
System.out.println("Server could not be found!\nID: " + serverArg.getValue()+ "\nHTTP Response: " + response.getResponseBody());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
new Thread(minecraft).start();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue