Fix some packet reading issues with DefineBlockExt.

This commit is contained in:
UnknownShadow200 2015-12-24 16:51:13 +11:00
parent 76ee17523d
commit 95bc4a3c03
3 changed files with 16 additions and 8 deletions

View File

@ -41,6 +41,8 @@ namespace ClassicalSharp {
CpePlayerClick = 34, CpePlayerClick = 34,
CpeDefineBlock = 35, CpeDefineBlock = 35,
CpeRemoveBlockDefinition = 36, CpeRemoveBlockDefinition = 36,
CpeDefineBlockExt = 37,
CpeBulkBlockUpdate = 38,
} }
public enum CpeMessage { public enum CpeMessage {

View File

@ -2,6 +2,7 @@
using ClassicalSharp.Hotkeys; using ClassicalSharp.Hotkeys;
using ClassicalSharp.Network; using ClassicalSharp.Network;
using ClassicalSharp.TexturePack; using ClassicalSharp.TexturePack;
using OpenTK;
using OpenTK.Input; using OpenTK.Input;
namespace ClassicalSharp { namespace ClassicalSharp {
@ -63,7 +64,7 @@ namespace ClassicalSharp {
"HackControl", "MessageTypes", "PlayerClick", "HackControl", "MessageTypes", "PlayerClick",
"FullCP437", "LongerMessages", "FullCP437", "LongerMessages",
// proposals // proposals
"BlockDefinitions", "BlockDefinitionsExt", "BulkBlockUpdate", "BlockDefinitions", "BlockDefinitionsExt",
}; };
void HandleCpeExtInfo() { void HandleCpeExtInfo() {
@ -409,13 +410,17 @@ namespace ClassicalSharp {
void HandleCpeDefineBlockExt() { void HandleCpeDefineBlockExt() {
byte block = HandleCpeDefineBlockCommonStart(); byte block = HandleCpeDefineBlockCommonStart();
BlockInfo info = game.BlockInfo; BlockInfo info = game.BlockInfo;
Vector3 min, max;
info.MinBB[block].X = Math.Min( 15/16f, reader.ReadUInt8() / 16f ); min.X = reader.ReadUInt8() / 16f; Utils.Clamp( ref min.X, 0, 15/16f );
info.MinBB[block].Y = Math.Min( 15/16f, reader.ReadUInt8() / 16f ); min.Y = reader.ReadUInt8() / 16f; Utils.Clamp( ref min.Y, 0, 15/16f );
info.MinBB[block].Z = Math.Min( 15/16f, reader.ReadUInt8() / 16f ); min.Z = reader.ReadUInt8() / 16f; Utils.Clamp( ref min.Z, 0, 15/16f );
info.MaxBB[block].X = Math.Min( 1, reader.ReadUInt8() / 16f ); max.X = reader.ReadUInt8() / 16f; Utils.Clamp( ref max.X, 1/16f, 1 );
info.MaxBB[block].Y = Math.Min( 1, reader.ReadUInt8() / 16f ); max.Y = reader.ReadUInt8() / 16f; Utils.Clamp( ref max.Y, 1/16f, 1 );
info.MaxBB[block].Z = Math.Min( 1, reader.ReadUInt8() / 16f ); max.Z = reader.ReadUInt8() / 16f; Utils.Clamp( ref max.Z, 1/16f, 1 );
info.MinBB[block] = min;
info.MaxBB[block] = max;
HandleCpeDefineBlockCommonEnd( block ); HandleCpeDefineBlockCommonEnd( block );
} }

View File

@ -149,7 +149,8 @@ namespace ClassicalSharp {
readonly int[] packetSizes = { readonly int[] packetSizes = {
131, 1, 1, 1028, 7, 9, 8, 74, 10, 7, 5, 4, 2, 131, 1, 1, 1028, 7, 9, 8, 74, 10, 7, 5, 4, 2,
66, 65, 2, 67, 69, 3, 2, 3, 134, 196, 130, 3, 66, 65, 2, 67, 69, 3, 2, 3, 134, 196, 130, 3,
8, 86, 2, 4, 66, 69, 2, 8, 138, 0, 80, 2, 1282, 8, 86, 2, 4, 66, 69, 2, 8, 138, 0, 80, 2, 85,
1282,
}; };
NetWriter writer; NetWriter writer;