mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
fix: IndexOutOfRange on packet reading (Forge)
Add two missing forge Command Packet Parsers, which won't affect the vanilla parsers.
The ids of the two Command Packet Parsers `forge:enum` and `forge:modid` [Forge once added in order](19f8d2a793/src/main/java/net/minecraftforge/common/ForgeMod.java (L175)) are the maximum value of the Vanilla Parser id plus 1 or plus 2. `forge:enum` has a [String Type argument](https://wiki.vg/Command_Data#forge:enum).
The specific id is from [wiki.vg](https://wiki.vg/Command_Data) or Forge-generated minecraft source code.
This commit is contained in:
parent
9a147b57e5
commit
e569ffe0cc
1 changed files with 36 additions and 1 deletions
|
|
@ -29,7 +29,19 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
|
|||
Parser? parser = null;
|
||||
if ((flags & 0x03) == 2)
|
||||
{
|
||||
if (protocolVersion <= Protocol18Handler.MC_1_19_2_Version)
|
||||
if (protocolVersion switch
|
||||
{
|
||||
Protocol18Handler.MC_1_19_Version => parserId == 50,
|
||||
Protocol18Handler.MC_1_19_2_Version => parserId == 50,
|
||||
Protocol18Handler.MC_1_19_3_Version => parserId == 50,
|
||||
Protocol18Handler.MC_1_19_4_Version => parserId == 50,
|
||||
Protocol18Handler.MC_1_20_Version => parserId == 51,
|
||||
Protocol18Handler.MC_1_20_2_Version => parserId == 51,
|
||||
_ => false
|
||||
})
|
||||
parser = new ParserForgeEnum(dataTypes, packetData);
|
||||
|
||||
else if (protocolVersion <= Protocol18Handler.MC_1_19_2_Version)
|
||||
parser = parserId switch
|
||||
{
|
||||
1 => new ParserFloat(dataTypes, packetData),
|
||||
|
|
@ -644,5 +656,28 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
|
|||
return "minecraft:time";
|
||||
}
|
||||
}
|
||||
|
||||
internal class ParserForgeEnum : Parser
|
||||
{
|
||||
public ParserForgeEnum(DataTypes dataTypes, Queue<byte> packetData)
|
||||
{
|
||||
dataTypes.ReadNextString(packetData);
|
||||
}
|
||||
|
||||
public override bool Check(string text)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetArgCnt()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return "forge:enum";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue