Compare commits

...

10 commits

11 changed files with 120 additions and 79 deletions

View file

@ -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
@ -27,21 +48,26 @@ configurations {
repositories {
// Use Maven Central for resolving dependencies.
maven {
url = "https://maven.zontreck.dev/repository/internal"
url = "https://maven.zontreck.com/repository/internal"
name = "Aria's Creations Caches"
}
maven {
url = "https://maven.zontreck.dev/repository/zontreck"
url = "https://maven.zontreck.com/repository/zontreck"
name = "Aria's Creations"
}
}
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 "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.
@ -53,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)}
}
}
@ -73,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())
@ -86,13 +114,13 @@ task jarjar(type: Jar) {
'Main-Class': application.mainClass,
'Multi-Release': 'true'
)
}from {
configurations.provided.collect { it.isDirectory() ? it : zipTree(it)}
}
archiveClassifier = "AIO"
duplicatesStrategy = "exclude"
from { configurations.provided.collect { it.isDirectory() ? it : zipTree(it) } }
exclude 'META-INF/*'
exclude 'META-INF/*'
exclude 'META-INF/*'
with jar
@ -100,6 +128,11 @@ task jarjar(type: Jar) {
with copyNatives
}
run {
jvmArgs ["-Djava.library.path=${project.nativeLibsDir}",]
}
jar.finalizedBy(jarjar)
jar.finalizedBy(copyToLib)
jar.finalizedBy(copyNatives)

View file

@ -270,13 +270,13 @@ public final class SocketConnection {
}
public final void sendPacket(Packet var1, Object... var2) {
public final void sendPacket(Packet packetType, Object... args) {
if(this.connected) {
this.writeBuffer.put(var1.id);
this.writeBuffer.put(packetType.id);
for(int var3 = 0; var3 < var2.length; ++var3) {
Class var10001 = var1.fields[var3];
Object var6 = var2[var3];
for(int i = 0; i < args.length; ++i) {
Class var10001 = packetType.fields[i];
Object var6 = args[i];
Class var5 = var10001;
SocketConnection var4 = this;
if(this.connected) {

View file

@ -36,13 +36,13 @@ import java.awt.Robot;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.net.MalformedURLException;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.TreeSet;
import java.time.Instant;
import java.util.*;
import javax.swing.JOptionPane;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Controllers;
@ -1195,25 +1195,4 @@ public final class Minecraft implements Runnable {
}
public static void main(String[] args)
{
Minecraft minecraft = new Minecraft((Canvas)null, 800, 600, false);
if(args.length>0){
// Hack: Add back multiplayer support!
String username = args[0];
minecraft.user = new User(username, args[1]);
if(args.length>2){
minecraft.server = args[2];
minecraft.port = Integer.parseInt(args[3]);
}
}
new Thread(minecraft).start();
}
}

View file

@ -13,10 +13,10 @@ public final class ConnectionManager {
public boolean processData = false;
public HashMap players = new HashMap();
public ConnectionManager(Minecraft var1, String var2, int var3, String var4, String var5) {
var1.hideGui = true;
this.minecraft = var1;
(new ConnectionThread(this, var2, var3, var4, var5, var1)).start();
public ConnectionManager(Minecraft instance, String server, int port, String username, String mpass) {
instance.hideGui = true;
this.minecraft = instance;
(new ConnectionThread(this, server, port, username, mpass, instance)).start();
}
public final void sendBlockChange(int var1, int var2, int var3, int var4, int var5) {

View file

@ -13,13 +13,13 @@ final class ConnectionThread extends Thread {
private Minecraft minecraft;
private ConnectionManager connectionManager;
ConnectionThread(ConnectionManager var1, String var2, int var3, String var4, String var5, Minecraft var6) {
this.connectionManager = var1;
this.ip = var2;
this.port = var3;
this.username = var4;
this.mpPass = var5;
this.minecraft = var6;
ConnectionThread(ConnectionManager instance, String server, int port, String username, String mpass, Minecraft game) {
this.connectionManager = instance;
this.ip = server;
this.port = port;
this.username = username;
this.mpPass = mpass;
this.minecraft = game;
}
public final void run() {

View file

@ -145,7 +145,7 @@ public class NetworkPlayer extends Entity {
var2 = 0.05F;
GL11.glScalef(var2, -var2, var2);
GL11.glTranslatef((float)(-var9.width(this.name)) / 2.0F, 0.0F, 0.0F);
if(this.name.equalsIgnoreCase("Notch")) {
if(this.name.equalsIgnoreCase("zontreck")) {
var9.draw(this.name, 0, 0, 16776960);
} else {
var9.draw(this.name, 0, 0, 16777215);

View file

@ -27,16 +27,17 @@ configurations {
repositories {
// Use Maven Central for resolving dependencies.
maven {
url = "https://maven.zontreck.dev/repository/internal"
url = "https://maven.zontreck.com/repository/internal"
name = "Aria's Creations Caches"
}
maven {
url = "https://maven.zontreck.dev/repository/zontreck"
url = "https://maven.zontreck.com/repository/zontreck"
name = "Aria's Creations"
}
}
dependencies {
provided ("dev.zontreck:LibAC:1.5.11")
}
// Apply a specific Java toolchain to ease working on different environments.
@ -86,8 +87,6 @@ task jarjar(type: Jar) {
duplicatesStrategy = "exclude"
from { configurations.provided.collect { it.isDirectory() ? it : zipTree(it) } }
exclude 'META-INF/*'
exclude 'META-INF/*'
exclude 'META-INF/*'
with jar

View file

@ -21,7 +21,7 @@ final class HeartbeatThread extends Thread {
HttpURLConnection var1 = null;
try {
URL var2 = new URL("http://www.minecraft.net/heartbeat.jsp");
URL var2 = new URL("https://api.zontreck.com/crafting/yggdrasil/legacy/heartbeat_2.php");
var1 = (HttpURLConnection)var2.openConnection();
var1.setRequestMethod("POST");
var1.setDoOutput(true);
@ -38,13 +38,13 @@ final class HeartbeatThread extends Thread {
var9.close();
BufferedReader var10 = new BufferedReader(new InputStreamReader(var1.getInputStream()));
String var3 = var10.readLine();
if(!MinecraftServer.a(this.minecraft).equals(var3)) {
if(!MinecraftServer.getServerURL(this.minecraft).equals(var3)) {
MinecraftServer.logger.info("To connect directly to this server, surf to: " + var3);
PrintWriter var4 = new PrintWriter(new FileWriter("externalurl.txt"));
var4.println(var3);
var4.close();
MinecraftServer.logger.info("(This is also in externalurl.txt)");
MinecraftServer.a(this.minecraft, var3);
MinecraftServer.setServerURL(this.minecraft, var3);
}
var10.close();

View file

@ -1,5 +1,7 @@
package com.mojang.minecraft.server;
import dev.zontreck.ariaslib.util.Hashing;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -11,14 +13,7 @@ public final class MPPassCalculator {
this.salt = var1;
}
public final String calcMPass(String var1) {
try {
String var3 = this.salt + var1;
MessageDigest var4 = MessageDigest.getInstance("MD5");
var4.update(var3.getBytes(), 0, var3.length());
return (new BigInteger(1, var4.digest())).toString(16);
} catch (NoSuchAlgorithmException var2) {
throw new RuntimeException(var2);
}
public final String calcMPass(String username) {
return Hashing.md5(this.salt + username);
}
}

View file

@ -16,6 +16,7 @@ import java.net.URLEncoder;
import java.nio.channels.SocketChannel;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -50,6 +51,7 @@ public class MinecraftServer implements Runnable {
private String serverURL = "";
public MPPassCalculator mpPassCalculator = new MPPassCalculator(this.salt);
public boolean verifyNames = false;
public String id;
public MinecraftServer() throws IOException {
try {
@ -58,13 +60,26 @@ public class MinecraftServer implements Runnable {
logger.warning("Failed to load server.properties!");
}
Random rng = new Random();
rng.setSeed(Instant.now().getEpochSecond());
int id = 0;
while(id <= 0)
{
id = rng.nextInt();
if(("" + id).length() > 5)
id = Integer.parseInt(("" + id).substring(0,5));
}
this.id = "" + id;
try {
this.serverName = this.properties.getProperty("server-name", "Minecraft Server");
this.motd = this.properties.getProperty("motd", "Welcome to my Minecraft Server!");
this.port = Integer.parseInt(this.properties.getProperty("port", "25565"));
this.maxPlayers = Integer.parseInt(this.properties.getProperty("max-players", "16"));
this.isPublic = Boolean.parseBoolean(this.properties.getProperty("public", "true"));
this.verifyNames = Boolean.parseBoolean(this.properties.getProperty("verify-names", "false"));
this.verifyNames = Boolean.parseBoolean(this.properties.getProperty("verify-names", "true"));
if(this.maxPlayers < 1) {
this.maxPlayers = 1;
}
@ -174,6 +189,24 @@ public class MinecraftServer implements Runnable {
logger.severe("Failed to save the level! " + var10);
}
}
if(var7 % 900 == 0) {
logger.info("Sending heartbeat");
logger.info("Server ID is : " + this.id);
HashMap var9 = new HashMap();
var9.put("name", this.serverName);
var9.put("users", Integer.valueOf(this.playerList.size()));
var9.put("max", Integer.valueOf(this.maxPlayers));
var9.put("public", Boolean.valueOf(this.isPublic));
var9.put("port", Integer.valueOf(this.port));
var9.put("salt", this.salt);
var9.put("version", Byte.valueOf((byte)4));
var9.put("id", this.id);
String var12 = assembleHeartbeat(var9);
(new HeartbeatThread(this, var12)).start();
}
}
while(System.nanoTime() - var3 > (long)var2) {
@ -568,11 +601,11 @@ public class MinecraftServer implements Runnable {
}
}
static String a(MinecraftServer var0) {
static String getServerURL(MinecraftServer var0) {
return var0.serverURL;
}
static String a(MinecraftServer var0, String var1) {
static String setServerURL(MinecraftServer var0, String var1) {
return var0.serverURL = var1;
}

View file

@ -61,9 +61,11 @@ public final class PlayerInstance {
String var14 = (String)var2[2];
if(this.minecraft.verifyNames && !var14.equals(this.minecraft.mpPassCalculator.calcMPass(var16))) {
this.kick("Illegal name.");
logger.info("Illegal name kick");
} else {
PlayerInstance var15 = this.minecraft.getPlayerByName(var16);
if(var15 != null) {
logger.info("Login from another computer");
var15.kick("You logged in from another computer.");
}