Minecraft 1.20.2

If only it was as simple as #64
This commit is contained in:
LOOHP
2023-09-24 15:56:36 +01:00
parent 10c5915d71
commit 32499372bf
21 changed files with 52011 additions and 50367 deletions
@@ -34,12 +34,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class Channel implements AutoCloseable {
private final ClientConnection client;
private final List<Pair<Key, ChannelPacketHandler>> handlers;
private final AtomicBoolean valid;
protected final DataInputStream input;
protected final DataOutputStream output;
public Channel(DataInputStream input, DataOutputStream output) {
public Channel(ClientConnection client, DataInputStream input, DataOutputStream output) {
this.client = client;
this.input = input;
this.output = output;
this.handlers = new CopyOnWriteArrayList<>();
@@ -89,7 +91,13 @@ public class Channel implements AutoCloseable {
}
protected boolean writePacket(PacketOut packet) throws IOException {
if (client.getClientState() == ClientConnection.ClientState.DISCONNECTED) {
return false;
}
ensureOpen();
if (packet.getPacketState() != client.getClientState()) {
return false;
}
ChannelPacketWrite write = new ChannelPacketWrite(packet);
for (Pair<Key, ChannelPacketHandler> pair : handlers) {
write = pair.getSecond().write(write);