Update client-side multiplayer code

This commit is contained in:
PeytonPlayz595 2024-03-27 00:50:56 -04:00
parent e7cbfb0e89
commit de3b03d9de
8 changed files with 8316 additions and 8281 deletions

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,15 @@ public class GuiMainMenu extends GuiScreen {
}
if(var1.id == 2) {
this.mc.displayGuiScreen(new GuiMultiplayer(this));
try {
this.mc.displayGuiScreen(new GuiMultiplayer(this));
} catch(Exception e) {
//Shit
this.mc.gameSettings.field_12259_z = "";
this.mc.gameSettings.username = "";
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiMultiplayer(this));
}
}
if(var1.id == 3) {

View File

@ -21,7 +21,12 @@ public class NetClientHandler extends NetHandler {
public void processReadPackets() {
if(!this.disconnected) {
this.netManager.readPacket();
Thread thread = new Thread(new Runnable() {
public void run() {
NetClientHandler.this.netManager.readPacket();
}
});
thread.start();
}
}

View File

@ -47,18 +47,23 @@ public class NetworkManager {
}
public void addToSendQueue(Packet var1) {
if(!this.isServerTerminating) {
Object var2 = this.sendQueueLock;
synchronized(var2) {
this.sendQueueByteLength += var1.getPacketSize() + 1;
if(var1.isChunkDataPacket) {
this.chunkDataPackets.add(var1);
} else {
this.dataPackets.add(var1);
Thread thread = new Thread(new Runnable () {
public void run() {
if(!NetworkManager.this.isServerTerminating) {
Object var2 = NetworkManager.this.sendQueueLock;
synchronized(var2) {
NetworkManager.this.sendQueueByteLength += var1.getPacketSize() + 1;
if(var1.isChunkDataPacket) {
NetworkManager.this.chunkDataPackets.add(var1);
} else {
NetworkManager.this.dataPackets.add(var1);
}
NetworkManager.this.sendPacket();
}
}
this.sendPacket();
}
}
});
thread.start();
}
private ByteArrayOutputStream sendBuffer;
@ -79,7 +84,9 @@ public class NetworkManager {
sendBuffer = new ByteArrayOutputStream();
DataOutputStream yee = new DataOutputStream(sendBuffer);
Packet.writePacket(var2, yee);
yee.flush();
GL11.writePacket(sendBuffer.toByteArray());
sendBuffer.flush();
}
if((var1 || this.chunkDataSendCounter-- <= 0) && !this.chunkDataPackets.isEmpty()) {
@ -93,7 +100,9 @@ public class NetworkManager {
sendBuffer = new ByteArrayOutputStream();
DataOutputStream yee = new DataOutputStream(sendBuffer);
Packet.writePacket(var2, yee);
yee.flush();
GL11.writePacket(sendBuffer.toByteArray());
sendBuffer.flush();
this.chunkDataSendCounter = 50;
}
@ -142,7 +151,7 @@ public class NetworkManager {
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
int var1 = 100;
while(stream.hasRemaining() && var1-- >= 0) {
while(stream.hasRemaining() && var1-- > 0) {
stream.mark();
try {
Packet pkt = Packet.readPacket(packetStream);
@ -159,8 +168,10 @@ public class NetworkManager {
continue;
} catch(NullPointerException e) {
continue;
} catch(Throwable e2) {
e2.printStackTrace();
} catch(Exception e) {
continue;
} catch(Throwable t) {
continue;
}
}

View File

@ -1,6 +1,5 @@
package net.minecraft.src;
import java.io.File;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
@ -64,7 +63,8 @@ public class WorldClient extends World {
}
protected IChunkProvider func_4081_a(File var1) {
@Override
protected IChunkProvider func_4081_a(String var1) {
this.C = new ChunkProviderClient(this);
return this.C;
}

View File

@ -107,8 +107,8 @@ public class SoundManager {
try {
GL11.setListenerPos((float)x, (float)y, (float)z, (float)player.motionX, (float)player.motionY, (float)player.motionZ, (float)pitch, (float)yaw);
} catch(Throwable t) {
System.err.println("Unable to set listener pos!");
} catch(Exception e) {
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long