mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implemented 1.20.2 fully, needs more testing
This commit is contained in:
parent
4f957cee7e
commit
93112d2c02
3 changed files with 2662 additions and 2532 deletions
|
|
@ -786,7 +786,7 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
var playerInventory = GetPlayerInventory();
|
var playerInventory = GetPlayerInventory();
|
||||||
|
|
||||||
if (playerInventory.Items.TryGetValue(GetCurrentSlot() - 36, out Item value) && value.Type == itemType)
|
if (playerInventory.Items.TryGetValue(GetCurrentSlot() - 36, out var value) && value.Type == itemType)
|
||||||
return true; // Already selected
|
return true; // Already selected
|
||||||
|
|
||||||
// Search the full inventory
|
// Search the full inventory
|
||||||
|
|
|
||||||
|
|
@ -521,7 +521,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
data = protocolversion >= Protocol18Handler.MC_1_19_Version
|
data = protocolversion >= Protocol18Handler.MC_1_19_Version
|
||||||
? ReadNextVarInt(cache) : ReadNextInt(cache);
|
? ReadNextVarInt(cache)
|
||||||
|
: ReadNextInt(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In 1.8 those 3 fields for Velocity are optional
|
// In 1.8 those 3 fields for Velocity are optional
|
||||||
|
|
@ -541,7 +542,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
ReadNextShort(cache);
|
ReadNextShort(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Entity(entityID, entityType, new Location(entityX, entityY, entityZ), entityYaw, entityPitch, data);
|
return new Entity(entityID, entityType, new Location(entityX, entityY, entityZ), entityYaw, entityPitch,
|
||||||
|
data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -563,12 +565,15 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
throw new System.IO.InvalidDataException("Failed to decode NBT: Does not start with TAG_Compound");
|
throw new System.IO.InvalidDataException("Failed to decode NBT: Does not start with TAG_Compound");
|
||||||
ReadNextByte(cache); // Tag type (TAG_Compound)
|
ReadNextByte(cache); // Tag type (TAG_Compound)
|
||||||
|
|
||||||
|
if (protocolversion < Protocol18Handler.MC_1_20_2_Version)
|
||||||
|
{
|
||||||
// NBT root name
|
// NBT root name
|
||||||
string rootName = Encoding.ASCII.GetString(ReadData(ReadNextUShort(cache), cache));
|
var rootName = Encoding.ASCII.GetString(ReadData(ReadNextUShort(cache), cache));
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(rootName))
|
if (!string.IsNullOrEmpty(rootName))
|
||||||
nbtData[""] = rootName;
|
nbtData[""] = rootName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
@ -646,7 +651,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
/// <exception cref="System.IO.InvalidDataException"></exception>
|
/// <exception cref="System.IO.InvalidDataException"></exception>
|
||||||
public Dictionary<int, object?> ReadNextMetadata(Queue<byte> cache, ItemPalette itemPalette, EntityMetadataPalette metadataPalette)
|
public Dictionary<int, object?> ReadNextMetadata(Queue<byte> cache, ItemPalette itemPalette,
|
||||||
|
EntityMetadataPalette metadataPalette)
|
||||||
{
|
{
|
||||||
Dictionary<int, object?> data = new();
|
Dictionary<int, object?> data = new();
|
||||||
byte key = ReadNextByte(cache);
|
byte key = ReadNextByte(cache);
|
||||||
|
|
@ -668,7 +674,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException)
|
catch (KeyNotFoundException)
|
||||||
{
|
{
|
||||||
throw new System.IO.InvalidDataException("Unknown Metadata Type ID " + typeId + ". Is this up to date for new MC Version?");
|
throw new System.IO.InvalidDataException("Unknown Metadata Type ID " + typeId +
|
||||||
|
". Is this up to date for new MC Version?");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocolversion <= Protocol18Handler.MC_1_8_Version)
|
if (protocolversion <= Protocol18Handler.MC_1_8_Version)
|
||||||
|
|
@ -737,6 +744,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
value = ReadNextLocation(cache);
|
value = ReadNextLocation(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EntityMetaDataType.Direction: // Direction (VarInt)
|
case EntityMetaDataType.Direction: // Direction (VarInt)
|
||||||
value = ReadNextVarInt(cache);
|
value = ReadNextVarInt(cache);
|
||||||
|
|
@ -746,6 +754,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
value = ReadNextUUID(cache);
|
value = ReadNextUUID(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EntityMetaDataType.BlockId: // BlockID (VarInt)
|
case EntityMetaDataType.BlockId: // BlockID (VarInt)
|
||||||
value = ReadNextVarInt(cache);
|
value = ReadNextVarInt(cache);
|
||||||
|
|
@ -773,6 +782,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
value = ReadNextVarInt(cache);
|
value = ReadNextVarInt(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EntityMetaDataType.Pose: // Pose
|
case EntityMetaDataType.Pose: // Pose
|
||||||
value = ReadNextVarInt(cache);
|
value = ReadNextVarInt(cache);
|
||||||
|
|
@ -795,6 +805,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Dimension and blockPos, currently not in use
|
// Dimension and blockPos, currently not in use
|
||||||
value = new Tuple<string, Location>(ReadNextString(cache), ReadNextLocation(cache));
|
value = new Tuple<string, Location>(ReadNextString(cache), ReadNextLocation(cache));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EntityMetaDataType.PaintingVariant: // Painting Variant
|
case EntityMetaDataType.PaintingVariant: // Painting Variant
|
||||||
value = ReadNextVarInt(cache);
|
value = ReadNextVarInt(cache);
|
||||||
|
|
@ -824,6 +835,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
data[key] = value;
|
data[key] = value;
|
||||||
key = ReadNextByte(cache);
|
key = ReadNextByte(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -856,7 +868,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case 3:
|
case 3:
|
||||||
if (protocolversion < Protocol18Handler.MC_1_17_Version
|
if (protocolversion < Protocol18Handler.MC_1_17_Version
|
||||||
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
||||||
ReadNextVarInt(cache); // Block State (minecraft:block before 1.18, minecraft:block_marker after 1.18)
|
ReadNextVarInt(
|
||||||
|
cache); // Block State (minecraft:block before 1.18, minecraft:block_marker after 1.18)
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
||||||
|
|
@ -870,31 +883,37 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
// 1.15 - 1.16.5 and 1.18 - 1.19.4
|
// 1.15 - 1.16.5 and 1.18 - 1.19.4
|
||||||
if ((protocolversion >= Protocol18Handler.MC_1_15_Version && protocolversion < Protocol18Handler.MC_1_17_Version)
|
if ((protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
||||||
|
protocolversion < Protocol18Handler.MC_1_17_Version)
|
||||||
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
||||||
ReadDustParticle(cache);
|
ReadDustParticle(cache);
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version || protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
||||||
|
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||||
ReadDustParticle(cache);
|
ReadDustParticle(cache);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
if (protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
||||||
ReadDustParticleColorTransition(cache);
|
ReadDustParticleColorTransition(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version || protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
||||||
|
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||||
ReadDustParticleColorTransition(cache);
|
ReadDustParticleColorTransition(cache);
|
||||||
break;
|
break;
|
||||||
case 23:
|
case 23:
|
||||||
// 1.15 - 1.16.5
|
// 1.15 - 1.16.5
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_15_Version && protocolversion < Protocol18Handler.MC_1_17_Version)
|
if (protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
||||||
|
protocolversion < Protocol18Handler.MC_1_17_Version)
|
||||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
// 1.18 - 1.19.2 onwards
|
// 1.18 - 1.19.2 onwards
|
||||||
if (protocolversion > Protocol18Handler.MC_1_17_1_Version && protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
if (protocolversion > Protocol18Handler.MC_1_17_1_Version &&
|
||||||
|
protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
||||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
|
|
@ -915,22 +934,26 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
// 1.15 - 1.16.5
|
// 1.15 - 1.16.5
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_15_Version && protocolversion < Protocol18Handler.MC_1_17_Version)
|
if (protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
||||||
|
protocolversion < Protocol18Handler.MC_1_17_Version)
|
||||||
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
// 1.17 - 1.17.1
|
// 1.17 - 1.17.1
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version || protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
||||||
|
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||||
{
|
{
|
||||||
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
||||||
}
|
}
|
||||||
else if (protocolversion > Protocol18Handler.MC_1_17_1_Version && protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
else if (protocolversion > Protocol18Handler.MC_1_17_1_Version &&
|
||||||
|
protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
||||||
{
|
{
|
||||||
// minecraft:vibration
|
// minecraft:vibration
|
||||||
ReadNextLocation(cache); // Origin (Starting Position)
|
ReadNextLocation(cache); // Origin (Starting Position)
|
||||||
ReadNextLocation(cache); // Desitination (Ending Position)
|
ReadNextLocation(cache); // Desitination (Ending Position)
|
||||||
ReadNextVarInt(cache); // Ticks
|
ReadNextVarInt(cache); // Ticks
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 37:
|
case 37:
|
||||||
// minecraft:vibration
|
// minecraft:vibration
|
||||||
|
|
@ -945,6 +968,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
ReadNextDouble(cache); // Destination Z
|
ReadNextDouble(cache); // Destination Z
|
||||||
ReadNextInt(cache); // Ticks
|
ReadNextInt(cache); // Ticks
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 39:
|
case 39:
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
|
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
|
||||||
|
|
@ -966,6 +990,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
ReadNextVarInt(cache);
|
ReadNextVarInt(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1186,7 +1211,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.IO.InvalidDataException("GetNbt: Cannot encode data type " + obj.GetType().Name + " into NBT!");
|
throw new System.IO.InvalidDataException("GetNbt: Cannot encode data type " + obj.GetType().Name +
|
||||||
|
" into NBT!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue