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) { 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) { if(var1.id == 3) {

View File

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

View File

@ -1,6 +1,5 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Set; 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); this.C = new ChunkProviderClient(this);
return this.C; return this.C;
} }

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long