Compare commits

...

5 commits

10 changed files with 131 additions and 105 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

@ -275,13 +275,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

@ -15,6 +15,7 @@ import com.mojang.minecraft.level.levelgen.LevelGen;
import com.mojang.minecraft.level.liquid.Liquid;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.net.ConnectionManager;
import com.mojang.minecraft.net.NetworkPlayer;
import com.mojang.minecraft.net.Packet;
import com.mojang.minecraft.particle.Particle;
import com.mojang.minecraft.particle.ParticleEngine;
@ -39,12 +40,14 @@ import java.awt.Robot;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.net.MalformedURLException;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.Iterator;
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.Sys;
@ -1161,24 +1164,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

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

View file

@ -15,7 +15,7 @@ final class NetworkSkinDownloadThread extends Thread {
HttpURLConnection var1 = null;
try {
URL var2 = new URL("http://www.minecraft.net/skin/" + this.player.name + ".png");
URL var2 = new URL("https://git.zontreck.com/zontreck/zontreck/raw/branch/master/" + this.player.name + ".png");
var1 = (HttpURLConnection)var2.openConnection();
var1.setDoInput(true);
var1.setDoOutput(false);

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

@ -24,9 +24,9 @@ final class ConsoleInput extends Thread {
return;
}
List var3 = MinecraftServer.a(this.minecraft);
List var3 = MinecraftServer.getPlayerList(this.minecraft);
synchronized(var3) {
MinecraftServer.a(this.minecraft).add(var2);
MinecraftServer.getPlayerList(this.minecraft).add(var2);
}
}
} catch (IOException var5) {

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.b(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;
@ -52,6 +53,7 @@ public class MinecraftServer implements Runnable {
public MPPassCalculator mpPassCalculator = new MPPassCalculator(this.salt);
public boolean verifyNames = false;
private int maxConnectCount;
private String id;
public MinecraftServer() throws IOException {
try {
@ -61,12 +63,24 @@ public class MinecraftServer implements Runnable {
}
try {
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;
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;
}
@ -178,20 +192,23 @@ public class MinecraftServer implements Runnable {
}
logger.info("Level saved! Load: " + this.playerList.size() + "/" + this.maxPlayers);
logger.info("Server ID is : " + this.id);
}
/*
if(var7 % 900 == 0) {
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)5));
String var12 = assembleHeartbeat(var9);
(new HeartbeatThread(this, var12)).start();
}*/
HashMap map = new HashMap();
map.put("name", this.serverName);
map.put("users", Integer.valueOf(this.playerList.size()));
map.put("max", Integer.valueOf(this.maxPlayers));
map.put("public", Boolean.valueOf(this.isPublic));
map.put("port", Integer.valueOf(this.port));
map.put("salt", this.salt);
map.put("version", Byte.valueOf((byte)5));
map.put("id", this.id);
String heartbeat = assembleHeartbeat(map);
(new HeartbeatThread(this, heartbeat)).start();
}
}
while(System.nanoTime() - var3 > (long)var2) {
@ -207,19 +224,19 @@ public class MinecraftServer implements Runnable {
}
}
private static String assembleHeartbeat(Map var0) {
private static String assembleHeartbeat(Map parameters) {
try {
String var1 = "";
String ret = "";
String var3;
for(Iterator var2 = var0.keySet().iterator(); var2.hasNext(); var1 = var1 + var3 + "=" + URLEncoder.encode(var0.get(var3).toString(), "UTF-8")) {
var3 = (String)var2.next();
if(var1 != "") {
var1 = var1 + "&";
String temp;
for(Iterator it = parameters.keySet().iterator(); it.hasNext(); ret = ret + temp + "=" + URLEncoder.encode(parameters.get(temp).toString(), "UTF-8")) {
temp = (String)it.next();
if(ret != "") {
ret = ret + "&";
}
}
return var1;
return ret;
} catch (Exception var4) {
var4.printStackTrace();
throw new RuntimeException("Failed to assemble heartbeat! This is pretty fatal");
@ -415,9 +432,9 @@ public class MinecraftServer implements Runnable {
}
}
public final void parseCommand(PlayerInstance var1, String var2) {
logger.info((var1 == null ? "[console]" : var1.name) + " admins: " + var2);
String[] var3 = var2.split(" ");
public final void parseCommand(PlayerInstance player, String command) {
logger.info((player == null ? "[console]" : player.name) + " admins: " + command);
String[] var3 = command.split(" ");
if(var3[0].toLowerCase().equals("ban") && var3.length > 1) {
this.ban(var3[1]);
} else if(var3[0].toLowerCase().equals("kick") && var3.length > 1) {
@ -432,31 +449,31 @@ public class MinecraftServer implements Runnable {
} else if(var3[0].toLowerCase().equals("deop") && var3.length > 1) {
this.deop(var3[1]);
} else if(var3[0].toLowerCase().equals("setspawn")) {
if(var1 != null) {
this.level.setSpawnPos(var1.x / 32, var1.y / 32, var1.z / 32, (float)(var1.yaw * 320 / 256));
if(player != null) {
this.level.setSpawnPos(player.x / 32, player.y / 32, player.z / 32, (float)(player.yaw * 320 / 256));
} else {
logger.info("Can\'t set spawn from console!");
}
} else if(var3[0].toLowerCase().equals("broadcast") && var3.length > 1) {
this.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), var2.substring("broadcast ".length()).trim()});
this.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), command.substring("broadcast ".length()).trim()});
} else if(var3[0].toLowerCase().equals("say") && var3.length > 1) {
this.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), var2.substring("say ".length()).trim()});
this.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), command.substring("say ".length()).trim()});
} else {
if(var3[0].toLowerCase().equals("teleport") && var3.length > 1) {
if(var1 == null) {
if(player == null) {
logger.info("Can\'t teleport from console!");
return;
}
PlayerInstance var4 = this.getPlayerByName(var3[1]);
if(var4 == null) {
var1.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), "No such player"});
player.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), "No such player"});
return;
}
var1.connection.sendPacket(Packet.PLAYER_TELEPORT, new Object[]{Integer.valueOf(-1), Integer.valueOf(var4.x), Integer.valueOf(var4.y), Integer.valueOf(var4.z), Integer.valueOf(var4.yaw), Integer.valueOf(var4.pitch)});
} else if(var1 != null) {
var1.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), "Unknown command!"});
player.connection.sendPacket(Packet.PLAYER_TELEPORT, new Object[]{Integer.valueOf(-1), Integer.valueOf(var4.x), Integer.valueOf(var4.y), Integer.valueOf(var4.z), Integer.valueOf(var4.yaw), Integer.valueOf(var4.pitch)});
} else if(player != null) {
player.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), "Unknown command!"});
}
}
@ -600,7 +617,7 @@ public class MinecraftServer implements Runnable {
return var2;
}
public static void main(String[] var0) {
public static void main(String[] args) {
try {
MinecraftServer var6 = new MinecraftServer();
MinecraftServer var1 = var6;
@ -636,16 +653,15 @@ public class MinecraftServer implements Runnable {
}
}
static List a(MinecraftServer var0) {
static List getPlayerList(MinecraftServer var0) {
return var0.playerList2;
}
static String b(MinecraftServer var0) {
return var0.serverURL;
static String getServerURL(MinecraftServer server) {
return server.serverURL;
}
static String a(MinecraftServer var0, String var1) {
return var0.serverURL = var1;
static String setServerURL(MinecraftServer server, String ip) {
return server.serverURL = ip;
}
static {