Update #52 - Fixed various issues with the client

This commit is contained in:
lax1dude
2025-06-15 21:43:43 -07:00
parent 325a6826bf
commit f3281c037f
94 changed files with 882 additions and 506 deletions

View File

@ -70,7 +70,7 @@ public class ClientV5MessageHandler extends ClientV4MessageHandler {
}
public void handleServer(SPacketClientStateFlagV5EAG packet) {
StateFlags.setFlag(new EaglercraftUUID(packet.uuidMost, packet.uuidLeast), packet.state);
StateFlags.setFlag(netHandler, new EaglercraftUUID(packet.uuidMost, packet.uuidLeast), packet.state);
}
public void handleServer(SPacketDisplayWebViewURLV5EAG packet) {

View File

@ -17,6 +17,7 @@
package net.lax1dude.eaglercraft.v1_8.socket.protocol.client;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.minecraft.client.network.NetHandlerPlayClient;
public class StateFlags {
@ -29,18 +30,23 @@ public class StateFlags {
public static final EaglercraftUUID DISABLE_SKIN_URL_LOOKUP = new EaglercraftUUID(0xC41D641BE2DA4094L,
0xB1B2DFF2E9D08180L);
public static final EaglercraftUUID SET_MAX_MULTI_PACKET = new EaglercraftUUID(0x877BC5F5A2154DDBL,
0xB493BE790A763E90L);
public static boolean eaglerPlayerFlag = false;
public static boolean eaglerPlayerFlagSupervisor = false;
public static boolean disableSkinURLLookup = false;
public static void setFlag(EaglercraftUUID flag, int value) {
public static void setFlag(NetHandlerPlayClient handler, EaglercraftUUID flag, int value) {
if (flag.equals(EAGLER_PLAYER_FLAG_PRESENT)) {
eaglerPlayerFlag = (value & 1) != 0;
eaglerPlayerFlagSupervisor = (value & 2) != 0;
} else if (flag.equals(DISABLE_SKIN_URL_LOOKUP)) {
disableSkinURLLookup = value != 0;
} else if (flag.equals(SET_MAX_MULTI_PACKET)) {
handler.getEaglerMessageController().setMaxMultiPacket(value);
}
}

View File

@ -57,6 +57,9 @@ public class InjectedMessageController extends MessageController {
byteInputStreamSingleton.feedBuffer(data, offset);
inputStreamSingleton.readByte();
if(data[offset + 1] == (byte) 0xFF) {
if(inputStreamSingleton.available() > 32768) {
throw new IOException("Impossible large multi-packet received: " + inputStreamSingleton.available());
}
inputStreamSingleton.readByte();
int count = inputStreamSingleton.readVarInt();
for(int i = 0, j, k; i < count; ++i) {
@ -134,7 +137,7 @@ public class InjectedMessageController extends MessageController {
lastLen = GamePacketOutputBuffer.getVarIntSize(i) + i;
totalLen += lastLen;
++sendCount;
}while(totalLen < 32760 && sendCount < total - start);
}while(totalLen < 32760 && sendCount < total - start && sendCount < maxMultiPacket);
if(totalLen >= 32760) {
--sendCount;
totalLen -= lastLen;

View File

@ -138,7 +138,7 @@ public class LegacyMessageController extends MessageController {
lastLen = GamePacketOutputBuffer.getVarIntSize(i) + i;
totalLen += lastLen;
++sendCount;
}while(totalLen < 32760 && sendCount < total - start);
}while(totalLen < 32760 && sendCount < total - start && sendCount < maxMultiPacket);
if(totalLen >= 32760) {
--sendCount;
totalLen -= lastLen;

View File

@ -37,6 +37,7 @@ public abstract class MessageController {
protected final int sendDirection;
protected final int receiveDirection;
protected List<GameMessagePacket> sendQueue;
protected int maxMultiPacket = 64;
public MessageController(GamePluginMessageProtocol protocol, GameMessageHandler handler, int direction) {
this.protocol = protocol;
@ -57,6 +58,10 @@ public abstract class MessageController {
return sendQueue != null;
}
public void setMaxMultiPacket(int max) {
this.maxMultiPacket = max;
}
public void sendPacket(GameMessagePacket packet) {
if(sendQueue != null) {
sendQueue.add(packet);

View File

@ -227,9 +227,11 @@ public class PacketBufferInputWrapper implements GamePacketInputBuffer {
}
@Override
public byte[] readByteArrayMC() throws IOException {
public byte[] readByteArrayMC(int maxLen) throws IOException {
try {
return buffer.readByteArray();
return buffer.readByteArray(maxLen);
}catch(DecoderException ex) {
throw new IOException(ex.getMessage());
}catch(IndexOutOfBoundsException ex) {
throw new EOFException();
}