From 80f9f9d009886ef4279095608ea6e03139865bdd Mon Sep 17 00:00:00 2001 From: LAX1DUDE Date: Fri, 29 Apr 2022 22:34:51 -0700 Subject: [PATCH] removed native multiplayer --- .../eaglercraft/beta/GuiNoMultiplayer.java | 34 ++++ .../java/net/minecraft/src/GuiConnecting.java | 3 +- .../java/net/minecraft/src/GuiMainMenu.java | 3 +- .../net/minecraft/src/NetClientHandler.java | 2 +- .../net/minecraft/src/NetworkManager.java | 175 +----------------- .../minecraft/src/NetworkMasterThread.java | 34 ---- .../minecraft/src/NetworkReaderThread.java | 31 ---- .../minecraft/src/NetworkWriterThread.java | 26 --- .../minecraft/src/ThreadConnectToServer.java | 48 ----- 9 files changed, 45 insertions(+), 311 deletions(-) create mode 100644 src/main/java/net/lax1dude/eaglercraft/beta/GuiNoMultiplayer.java delete mode 100644 src/main/java/net/minecraft/src/NetworkMasterThread.java delete mode 100644 src/main/java/net/minecraft/src/NetworkReaderThread.java delete mode 100644 src/main/java/net/minecraft/src/NetworkWriterThread.java delete mode 100644 src/main/java/net/minecraft/src/ThreadConnectToServer.java diff --git a/src/main/java/net/lax1dude/eaglercraft/beta/GuiNoMultiplayer.java b/src/main/java/net/lax1dude/eaglercraft/beta/GuiNoMultiplayer.java new file mode 100644 index 0000000..1aecab8 --- /dev/null +++ b/src/main/java/net/lax1dude/eaglercraft/beta/GuiNoMultiplayer.java @@ -0,0 +1,34 @@ +package net.lax1dude.eaglercraft.beta; + +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.StringTranslate; + +public class GuiNoMultiplayer extends GuiScreen { + + private final GuiScreen parent; + + public GuiNoMultiplayer(GuiScreen parent) { + this.parent = parent; + } + + public void initGui() { + controlList.add(new GuiButton(0, (width - 200) / 2, height / 4 + 85, StringTranslate.getInstance().translateKey("gui.toMenu"))); + } + + public void actionPerformed(GuiButton bnt) { + if(bnt.id == 0) { + mc.displayGuiScreen(parent); + } + } + + public void drawScreen(int mx, int my, float f) { + drawDefaultBackground(); + drawCenteredString(fontRenderer, "Multiplayer is not supported yet", width / 2, height / 4 - 10, 0xFFFFFF); + drawCenteredString(fontRenderer, "Minecraft Beta public servers are VERY INSECURE!", width / 2, height / 4 + 15, 0xFFCCCC); + drawCenteredString(fontRenderer, "Just watch some of Team Avolition's old videos", width / 2, height / 4 + 26, 0xFFCCCC); + drawCenteredString(fontRenderer, "I will add it soon, just shut up and be patient", width / 2, height / 4 + 52, 0x888888); + super.drawScreen(mx, my, f); + } + +} diff --git a/src/main/java/net/minecraft/src/GuiConnecting.java b/src/main/java/net/minecraft/src/GuiConnecting.java index cd32054..87c8e56 100644 --- a/src/main/java/net/minecraft/src/GuiConnecting.java +++ b/src/main/java/net/minecraft/src/GuiConnecting.java @@ -4,7 +4,6 @@ package net.minecraft.src; // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) braces deadcode -import java.util.List; import net.minecraft.client.Minecraft; public class GuiConnecting extends GuiScreen { @@ -12,7 +11,7 @@ public class GuiConnecting extends GuiScreen { public GuiConnecting(Minecraft minecraft, String s, int i) { cancelled = false; minecraft.changeWorld1(null); - (new ThreadConnectToServer(this, minecraft, s, i)).start(); + //(new ThreadConnectToServer(this, minecraft, s, i)).start(); } public void updateScreen() { diff --git a/src/main/java/net/minecraft/src/GuiMainMenu.java b/src/main/java/net/minecraft/src/GuiMainMenu.java index 08a9c6d..6f0433d 100644 --- a/src/main/java/net/minecraft/src/GuiMainMenu.java +++ b/src/main/java/net/minecraft/src/GuiMainMenu.java @@ -12,6 +12,7 @@ import java.util.*; import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.adapter.Tessellator; +import net.lax1dude.eaglercraft.beta.GuiNoMultiplayer; public class GuiMainMenu extends GuiScreen { @@ -90,7 +91,7 @@ public class GuiMainMenu extends GuiScreen { mc.displayGuiScreen(new GuiSelectWorld(this)); } if (guibutton.id == 2) { - mc.displayGuiScreen(new GuiMultiplayer(this)); + mc.displayGuiScreen(new GuiNoMultiplayer(this)); } //if (guibutton.id == 3) { // mc.displayGuiScreen(new GuiTexturePacks(this)); diff --git a/src/main/java/net/minecraft/src/NetClientHandler.java b/src/main/java/net/minecraft/src/NetClientHandler.java index 2c16caa..93030a8 100644 --- a/src/main/java/net/minecraft/src/NetClientHandler.java +++ b/src/main/java/net/minecraft/src/NetClientHandler.java @@ -24,7 +24,7 @@ public class NetClientHandler extends NetHandler { } catch (IOException e) { throw new UnexpectedThrowable(e); } - netManager = new NetworkManager(socket, "Client", this); + //netManager = new NetworkManager(socket, "Client", this); } public void processReadPackets() { diff --git a/src/main/java/net/minecraft/src/NetworkManager.java b/src/main/java/net/minecraft/src/NetworkManager.java index 50bf002..66a5af6 100644 --- a/src/main/java/net/minecraft/src/NetworkManager.java +++ b/src/main/java/net/minecraft/src/NetworkManager.java @@ -4,168 +4,39 @@ package net.minecraft.src; // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) braces deadcode -import java.io.*; -import java.net.Socket; -import java.net.SocketAddress; -import java.util.*; - -import net.lax1dude.eaglercraft.compat.UnexpectedThrowable; public class NetworkManager { - public NetworkManager(Socket socket, String s, NetHandler nethandler) { - sendQueueLock = new Object(); - isRunning = true; - readPackets = Collections.synchronizedList(new ArrayList()); - dataPackets = Collections.synchronizedList(new ArrayList()); - chunkDataPackets = Collections.synchronizedList(new ArrayList()); - isServerTerminating = false; - isTerminating = false; - terminationReason = ""; - timeSinceLastRead = 0; - sendQueueByteLength = 0; - chunkDataSendCounter = 0; - field_20100_w = 50; - networkSocket = socket; - remoteSocketAddress = socket.getRemoteSocketAddress(); - netHandler = nethandler; - try { - socket.setTrafficClass(24); - socketInputStream = new DataInputStream(socket.getInputStream()); - socketOutputStream = new DataOutputStream(socket.getOutputStream()); - } catch (IOException e) { - throw new UnexpectedThrowable(e); - } - readThread = new NetworkReaderThread(this, (new StringBuilder()).append(s).append(" read thread").toString()); - writeThread = new NetworkWriterThread(this, (new StringBuilder()).append(s).append(" write thread").toString()); - readThread.start(); - writeThread.start(); + public NetworkManager(String s, NetHandler nethandler) { + } public void addToSendQueue(Packet packet) { - if (isServerTerminating) { - return; - } - synchronized (sendQueueLock) { - sendQueueByteLength += packet.getPacketSize() + 1; - if (packet.isChunkDataPacket) { - chunkDataPackets.add(packet); - } else { - dataPackets.add(packet); - } - } + } private void sendPacket() { - try { - boolean flag = true; - if (!dataPackets.isEmpty() && (chunkDataSendCounter == 0 || System.currentTimeMillis() - - ((Packet) dataPackets.get(0)).creationTimeMillis >= (long) chunkDataSendCounter)) { - flag = false; - Packet packet; - synchronized (sendQueueLock) { - packet = (Packet) dataPackets.remove(0); - sendQueueByteLength -= packet.getPacketSize() + 1; - } - Packet.writePacket(packet, socketOutputStream); - } - if ((flag || field_20100_w-- <= 0) && !chunkDataPackets.isEmpty() - && (chunkDataSendCounter == 0 || System.currentTimeMillis() - - ((Packet) chunkDataPackets.get(0)).creationTimeMillis >= (long) chunkDataSendCounter)) { - flag = false; - Packet packet1; - synchronized (sendQueueLock) { - packet1 = (Packet) chunkDataPackets.remove(0); - sendQueueByteLength -= packet1.getPacketSize() + 1; - } - Packet.writePacket(packet1, socketOutputStream); - field_20100_w = 50; - } - if (flag) { - Thread.sleep(10L); - } - } catch (InterruptedException interruptedexception) { - } catch (Exception exception) { - if (!isTerminating) { - onNetworkError(exception); - } - } + } private void readPacket() { - try { - Packet packet = Packet.readPacket(socketInputStream); - if (packet != null) { - readPackets.add(packet); - } else { - networkShutdown("disconnect.endOfStream", new Object[0]); - } - } catch (Exception exception) { - if (!isTerminating) { - onNetworkError(exception); - } - } - } - private void onNetworkError(Exception exception) { - exception.printStackTrace(); - networkShutdown("disconnect.genericReason", new Object[] { - (new StringBuilder()).append("Internal exception: ").append(exception.toString()).toString() }); } public void networkShutdown(String s, Object aobj[]) { - if (!isRunning) { - return; - } - isTerminating = true; - terminationReason = s; - field_20101_t = aobj; - (new NetworkMasterThread(this)).start(); - isRunning = false; - try { - socketInputStream.close(); - socketInputStream = null; - } catch (Throwable throwable) { - } - try { - socketOutputStream.close(); - socketOutputStream = null; - } catch (Throwable throwable1) { - } - try { - networkSocket.close(); - networkSocket = null; - } catch (Throwable throwable2) { - } + } public void processReadPackets() { - if (sendQueueByteLength > 0x100000) { - networkShutdown("disconnect.overflow", new Object[0]); - } - if (readPackets.isEmpty()) { - if (timeSinceLastRead++ == 1200) { - networkShutdown("disconnect.timeout", new Object[0]); - } - } else { - timeSinceLastRead = 0; - } - Packet packet; - for (int i = 100; !readPackets.isEmpty() && i-- >= 0; packet.processPacket(netHandler)) { - packet = (Packet) readPackets.remove(0); - } - if (isTerminating && readPackets.isEmpty()) { - netHandler.handleErrorMessage(terminationReason, field_20101_t); - } } static boolean isRunning(NetworkManager networkmanager) { - return networkmanager.isRunning; + return false; } static boolean isServerTerminating(NetworkManager networkmanager) { - return networkmanager.isServerTerminating; + return false; } static void readNetworkPacket(NetworkManager networkmanager) { @@ -176,36 +47,4 @@ public class NetworkManager { networkmanager.sendPacket(); } - static Thread getReadThread(NetworkManager networkmanager) { - return networkmanager.readThread; - } - - static Thread getWriteThread(NetworkManager networkmanager) { - return networkmanager.writeThread; - } - - public static final Object threadSyncObject = new Object(); - public static int numReadThreads; - public static int numWriteThreads; - private Object sendQueueLock; - private Socket networkSocket; - private final SocketAddress remoteSocketAddress; - private DataInputStream socketInputStream; - private DataOutputStream socketOutputStream; - private boolean isRunning; - private List readPackets; - private List dataPackets; - private List chunkDataPackets; - private NetHandler netHandler; - private boolean isServerTerminating; - private Thread writeThread; - private Thread readThread; - private boolean isTerminating; - private String terminationReason; - private Object field_20101_t[]; - private int timeSinceLastRead; - private int sendQueueByteLength; - public int chunkDataSendCounter; - private int field_20100_w; - } diff --git a/src/main/java/net/minecraft/src/NetworkMasterThread.java b/src/main/java/net/minecraft/src/NetworkMasterThread.java deleted file mode 100644 index 4aaba38..0000000 --- a/src/main/java/net/minecraft/src/NetworkMasterThread.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.minecraft.src; -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. - -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -class NetworkMasterThread extends Thread { - - NetworkMasterThread(NetworkManager networkmanager) { - netManager = networkmanager; - } - - public void run() { - try { - Thread.sleep(5000L); - if (NetworkManager.getReadThread(netManager).isAlive()) { - try { - NetworkManager.getReadThread(netManager).stop(); - } catch (Throwable throwable) { - } - } - if (NetworkManager.getWriteThread(netManager).isAlive()) { - try { - NetworkManager.getWriteThread(netManager).stop(); - } catch (Throwable throwable1) { - } - } - } catch (InterruptedException interruptedexception) { - interruptedexception.printStackTrace(); - } - } - - final NetworkManager netManager; /* synthetic field */ -} diff --git a/src/main/java/net/minecraft/src/NetworkReaderThread.java b/src/main/java/net/minecraft/src/NetworkReaderThread.java deleted file mode 100644 index ef69865..0000000 --- a/src/main/java/net/minecraft/src/NetworkReaderThread.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.minecraft.src; -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. - -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -class NetworkReaderThread extends Thread { - - NetworkReaderThread(NetworkManager networkmanager, String s) { - super(s); - netManager = networkmanager; - } - - public void run() { - synchronized (NetworkManager.threadSyncObject) { - NetworkManager.numReadThreads++; - } - while (NetworkManager.isRunning(netManager) && !NetworkManager.isServerTerminating(netManager)) { - NetworkManager.readNetworkPacket(netManager); - try { - sleep(0L); - } catch (InterruptedException interruptedexception) { - } - } - synchronized (NetworkManager.threadSyncObject) { - NetworkManager.numReadThreads--; - } - } - - final NetworkManager netManager; /* synthetic field */ -} diff --git a/src/main/java/net/minecraft/src/NetworkWriterThread.java b/src/main/java/net/minecraft/src/NetworkWriterThread.java deleted file mode 100644 index 10272b4..0000000 --- a/src/main/java/net/minecraft/src/NetworkWriterThread.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.minecraft.src; -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. - -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -class NetworkWriterThread extends Thread { - - NetworkWriterThread(NetworkManager networkmanager, String s) { - super(s); - netManager = networkmanager; - } - - public void run() { - synchronized (NetworkManager.threadSyncObject) { - NetworkManager.numWriteThreads++; - } - for (; NetworkManager.isRunning(netManager); NetworkManager.sendNetworkPacket(netManager)) { - } - synchronized (NetworkManager.threadSyncObject) { - NetworkManager.numWriteThreads--; - } - } - - final NetworkManager netManager; /* synthetic field */ -} diff --git a/src/main/java/net/minecraft/src/ThreadConnectToServer.java b/src/main/java/net/minecraft/src/ThreadConnectToServer.java deleted file mode 100644 index 116cbf8..0000000 --- a/src/main/java/net/minecraft/src/ThreadConnectToServer.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.minecraft.src; -// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. - -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode - -import net.minecraft.client.Minecraft; - -class ThreadConnectToServer extends Thread { - - ThreadConnectToServer(GuiConnecting guiconnecting, Minecraft minecraft, String s, int i) { - connectingGui = guiconnecting; - mc = minecraft; - hostName = s; - port = i; - } - - public void run() { - // try - // { - GuiConnecting.setNetClientHandler(connectingGui, new NetClientHandler(mc, hostName, port)); - if (GuiConnecting.isCancelled(connectingGui)) { - return; - } - GuiConnecting.getNetClientHandler(connectingGui).addToSendQueue(new Packet2Handshake(mc.session.username)); - // } - /* - * catch(UnknownHostException unknownhostexception) { - * if(GuiConnecting.isCancelled(connectingGui)) { return; } - * mc.displayGuiScreen(new GuiConnectFailed("connect.failed", - * "disconnect.genericReason", new Object[] { (new - * StringBuilder()).append("Unknown host '").append(hostName).append("'"). - * toString() })); } catch(ConnectException connectexception) { - * if(GuiConnecting.isCancelled(connectingGui)) { return; } - * mc.displayGuiScreen(new GuiConnectFailed("connect.failed", - * "disconnect.genericReason", new Object[] { connectexception.getMessage() })); - * } catch(Exception exception) { if(GuiConnecting.isCancelled(connectingGui)) { - * return; } exception.printStackTrace(); mc.displayGuiScreen(new - * GuiConnectFailed("connect.failed", "disconnect.genericReason", new Object[] { - * exception.toString() })); } - */ - } - - final Minecraft mc; /* synthetic field */ - final String hostName; /* synthetic field */ - final int port; /* synthetic field */ - final GuiConnecting connectingGui; /* synthetic field */ -}