removed native multiplayer
This commit is contained in:
parent
dbdbd8caad
commit
80f9f9d009
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ package net.minecraft.src;
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
||||||
// Decompiler options: packimports(3) braces deadcode
|
// Decompiler options: packimports(3) braces deadcode
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class GuiConnecting extends GuiScreen {
|
public class GuiConnecting extends GuiScreen {
|
||||||
|
@ -12,7 +11,7 @@ public class GuiConnecting extends GuiScreen {
|
||||||
public GuiConnecting(Minecraft minecraft, String s, int i) {
|
public GuiConnecting(Minecraft minecraft, String s, int i) {
|
||||||
cancelled = false;
|
cancelled = false;
|
||||||
minecraft.changeWorld1(null);
|
minecraft.changeWorld1(null);
|
||||||
(new ThreadConnectToServer(this, minecraft, s, i)).start();
|
//(new ThreadConnectToServer(this, minecraft, s, i)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.*;
|
||||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
import net.lax1dude.eaglercraft.TextureLocation;
|
import net.lax1dude.eaglercraft.TextureLocation;
|
||||||
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
||||||
|
import net.lax1dude.eaglercraft.beta.GuiNoMultiplayer;
|
||||||
|
|
||||||
public class GuiMainMenu extends GuiScreen {
|
public class GuiMainMenu extends GuiScreen {
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ public class GuiMainMenu extends GuiScreen {
|
||||||
mc.displayGuiScreen(new GuiSelectWorld(this));
|
mc.displayGuiScreen(new GuiSelectWorld(this));
|
||||||
}
|
}
|
||||||
if (guibutton.id == 2) {
|
if (guibutton.id == 2) {
|
||||||
mc.displayGuiScreen(new GuiMultiplayer(this));
|
mc.displayGuiScreen(new GuiNoMultiplayer(this));
|
||||||
}
|
}
|
||||||
//if (guibutton.id == 3) {
|
//if (guibutton.id == 3) {
|
||||||
// mc.displayGuiScreen(new GuiTexturePacks(this));
|
// mc.displayGuiScreen(new GuiTexturePacks(this));
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class NetClientHandler extends NetHandler {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UnexpectedThrowable(e);
|
throw new UnexpectedThrowable(e);
|
||||||
}
|
}
|
||||||
netManager = new NetworkManager(socket, "Client", this);
|
//netManager = new NetworkManager(socket, "Client", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processReadPackets() {
|
public void processReadPackets() {
|
||||||
|
|
|
@ -4,168 +4,39 @@ package net.minecraft.src;
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
||||||
// Decompiler options: packimports(3) braces deadcode
|
// 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 class NetworkManager {
|
||||||
|
|
||||||
public NetworkManager(Socket socket, String s, NetHandler nethandler) {
|
public NetworkManager(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 void addToSendQueue(Packet packet) {
|
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() {
|
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() {
|
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[]) {
|
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() {
|
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) {
|
static boolean isRunning(NetworkManager networkmanager) {
|
||||||
return networkmanager.isRunning;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isServerTerminating(NetworkManager networkmanager) {
|
static boolean isServerTerminating(NetworkManager networkmanager) {
|
||||||
return networkmanager.isServerTerminating;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void readNetworkPacket(NetworkManager networkmanager) {
|
static void readNetworkPacket(NetworkManager networkmanager) {
|
||||||
|
@ -176,36 +47,4 @@ public class NetworkManager {
|
||||||
networkmanager.sendPacket();
|
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;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 */
|
|
||||||
}
|
|
|
@ -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 */
|
|
||||||
}
|
|
|
@ -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 */
|
|
||||||
}
|
|
|
@ -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 */
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user