This commit is contained in:
ReinforceZwei 2023-03-24 19:50:04 +08:00
commit c36dec435d

View file

@ -803,6 +803,169 @@ namespace MinecraftClient.Protocol.Handlers
return data; return data;
} }
// Currently not handled. Reading data only
protected void ReadParticleData(Queue<byte> cache, ItemPalette itemPalette)
{
if (protocolversion < Protocol18Handler.MC_1_13_Version)
return;
int ParticleID = ReadNextVarInt(cache);
// Refernece:
// 1.19.3 - https://wiki.vg/index.php?title=Data_types&oldid=17986
// 1.18 - https://wiki.vg/index.php?title=Data_types&oldid=17180
// 1.17 - https://wiki.vg/index.php?title=Data_types&oldid=16740
// 1.15 - https://wiki.vg/index.php?title=Data_types&oldid=15338
// 1.13 - https://wiki.vg/index.php?title=Data_types&oldid=14271
switch (ParticleID)
{
case 2:
// 1.18 +
if (protocolversion > Protocol18Handler.MC_1_17_1_Version)
ReadNextVarInt(cache); // Block state (minecraft:block)
break;
case 3:
if (protocolversion < Protocol18Handler.MC_1_17_Version
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
ReadNextVarInt(cache); // Block State (minecraft:block before 1.18, minecraft:block_marker after 1.18)
break;
case 4:
if (protocolversion == Protocol18Handler.MC_1_17_Version
|| protocolversion == Protocol18Handler.MC_1_17_1_Version)
ReadNextVarInt(cache); // Block State (minecraft:block)
break;
case 11:
// 1.13 - 1.14.4
if (protocolversion < Protocol18Handler.MC_1_15_Version)
ReadDustParticle(cache);
break;
case 14:
// 1.15 - 1.16.5 and 1.18 - 1.19.4
if ((protocolversion >= Protocol18Handler.MC_1_15_Version && protocolversion < Protocol18Handler.MC_1_17_Version)
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
ReadDustParticle(cache);
break;
case 15:
if (protocolversion == Protocol18Handler.MC_1_17_Version || protocolversion == Protocol18Handler.MC_1_17_1_Version)
ReadDustParticle(cache);
else
{
if (protocolversion > Protocol18Handler.MC_1_17_1_Version)
ReadDustParticleColorTransition(cache);
}
break;
case 16:
if (protocolversion == Protocol18Handler.MC_1_17_Version || protocolversion == Protocol18Handler.MC_1_17_1_Version)
ReadDustParticleColorTransition(cache);
break;
case 20:
// 1.13 - 1.14.4
if (protocolversion < Protocol18Handler.MC_1_15_Version)
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
break;
case 23:
// 1.15 - 1.16.5
if (protocolversion >= Protocol18Handler.MC_1_15_Version && protocolversion < Protocol18Handler.MC_1_17_Version)
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
break;
case 24:
// 1.18 - 1.19.2 onwards
if (protocolversion > Protocol18Handler.MC_1_17_1_Version && protocolversion < Protocol18Handler.MC_1_19_3_Version)
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
break;
case 25:
// 1.17 - 1.17.1 and 1.19.3 onwards
if (protocolversion == Protocol18Handler.MC_1_17_Version
|| protocolversion == Protocol18Handler.MC_1_17_1_Version
|| protocolversion >= Protocol18Handler.MC_1_19_3_Version)
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
break;
case 27:
// 1.13 - 1.14.4
if (protocolversion < Protocol18Handler.MC_1_15_Version)
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
break;
case 30:
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
ReadNextFloat(cache); // Roll (minecraft:sculk_charge)
break;
case 32:
// 1.15 - 1.16.5
if (protocolversion >= Protocol18Handler.MC_1_15_Version && protocolversion < Protocol18Handler.MC_1_17_Version)
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
break;
case 36:
// 1.17 - 1.17.1
if (protocolversion == Protocol18Handler.MC_1_17_Version || protocolversion == Protocol18Handler.MC_1_17_1_Version)
{
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
}
else if (protocolversion > Protocol18Handler.MC_1_17_1_Version && protocolversion < Protocol18Handler.MC_1_19_3_Version)
{
// minecraft:vibration
ReadNextLocation(cache); // Origin (Starting Position)
ReadNextLocation(cache); // Desitination (Ending Position)
ReadNextVarInt(cache); // Ticks
}
break;
case 37:
// minecraft:vibration
if (protocolversion == Protocol18Handler.MC_1_17_Version
|| protocolversion == Protocol18Handler.MC_1_17_1_Version)
{
ReadNextDouble(cache); // Origin X
ReadNextDouble(cache); // Origin Y
ReadNextDouble(cache); // Origin Z
ReadNextDouble(cache); // Destination X
ReadNextDouble(cache); // Destination Y
ReadNextDouble(cache); // Destination Z
ReadNextInt(cache); // Ticks
}
break;
case 39:
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
break;
case 40:
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
{
string positionSourceType = ReadNextString(cache);
if (positionSourceType == "minecraft:block")
{
ReadNextLocation(cache);
}
else if (positionSourceType == "minecraft:entity")
{
ReadNextVarInt(cache);
ReadNextFloat(cache);
}
ReadNextVarInt(cache);
}
break;
}
}
private void ReadDustParticle(Queue<byte> cache)
{
ReadNextFloat(cache); // Red
ReadNextFloat(cache); // Green
ReadNextFloat(cache); // Blue
ReadNextFloat(cache); // Scale
}
private void ReadDustParticleColorTransition(Queue<byte> cache)
{
ReadNextFloat(cache); // From red
ReadNextFloat(cache); // From green
ReadNextFloat(cache); // From blue
ReadNextFloat(cache); // Scale
ReadNextFloat(cache); // To red
ReadNextFloat(cache); // To green
ReadNextFloat(cache); // To Blue
}
/// <summary> /// <summary>
/// Read a single villager trade from a cache of bytes and remove it from the cache /// Read a single villager trade from a cache of bytes and remove it from the cache
/// </summary> /// </summary>
@ -1000,8 +1163,7 @@ namespace MinecraftClient.Protocol.Handlers
} }
else else
{ {
throw new System.IO.InvalidDataException("GetNbt: Cannot encode data type " + obj.GetType().Name + throw new System.IO.InvalidDataException("GetNbt: Cannot encode data type " + obj.GetType().Name + " into NBT!");
" into NBT!");
} }
} }