diff --git a/ClassicalSharp/Network/Enums.cs b/ClassicalSharp/Network/Enums.cs index ebd02165c..cb96fa891 100644 --- a/ClassicalSharp/Network/Enums.cs +++ b/ClassicalSharp/Network/Enums.cs @@ -40,10 +40,7 @@ namespace ClassicalSharp { CpeExtAddEntity2 = 33, CpePlayerClick = 34, CpeDefineBlock = 35, - CpeDefineLiquid = 36, - CpeRemoveBlockDefinition = 37, - - Max, + CpeRemoveBlockDefinition = 36, } public enum CpeMessage { diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs index 362d36135..bbcc92c57 100644 --- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs +++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs @@ -282,7 +282,7 @@ namespace ClassicalSharp { AddEntity( entityId, displayName, skinName, true ); } - void HandleCpeDefineBlockOrLiquid() { + void HandleCpeDefineBlock() { byte block = reader.ReadUInt8(); BlockInfo info = game.BlockInfo; info.ResetBlockInfo( block ); @@ -294,32 +294,30 @@ namespace ClassicalSharp { info.SetTop( reader.ReadUInt8(), (Block)block ); info.SetSide( reader.ReadUInt8(), (Block)block ); info.SetBottom( reader.ReadUInt8(), (Block)block ); - reader.ReadUInt8(); // opacity hint, but we ignore this. info.BlocksLight[block] = reader.ReadUInt8() == 0; reader.ReadUInt8(); // walk sound, but we ignore this. info.EmitsLight[block] = reader.ReadUInt8() != 0; - if( lastOpcode == PacketId.CpeDefineBlock ) { - byte shape = reader.ReadUInt8(); - if( shape == 1 ) info.Height[block] = 1; - else if( shape == 2 ) info.Height[block] = 0.5f; - // TODO: upside down slab not properly supported - else if( shape == 3 ) info.Height[block] = 0.5f; - else if( shape == 4 ) info.IsSprite[block] = true; - - byte blockDraw = reader.ReadUInt8(); - if( blockDraw == 0 ) info.IsOpaque[block] = true; - else if( blockDraw == 1 ) info.IsTransparent[block] = true; - else if( blockDraw == 2 ) info.IsTranslucent[block] = true; - else if( blockDraw == 3 ) info.IsTranslucent[block] = true; - - Console.WriteLine( block + " : " + shape + "," + blockDraw ); - } else { - byte fogDensity = reader.ReadUInt8(); - info.FogDensity[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f; - info.FogColour[block] = new FastColour( - reader.ReadUInt8(), reader.ReadUInt8(), reader.ReadUInt8() ); - } + + byte shape = reader.ReadUInt8(); + if( shape == 1 ) info.Height[block] = 1; + else if( shape == 2 ) info.Height[block] = 0.5f; + // TODO: upside down slab not properly supported + else if( shape == 3 ) info.Height[block] = 0.5f; + else if( shape == 4 ) info.IsSprite[block] = true; + + byte blockDraw = reader.ReadUInt8(); + if( blockDraw == 0 ) info.IsOpaque[block] = true; + else if( blockDraw == 1 ) info.IsTransparent[block] = true; + else if( blockDraw == 2 ) info.IsTransparent[block] = true; // TODO: hide neighbours + else if( blockDraw == 3 ) info.IsTranslucent[block] = true; + + Console.WriteLine( block + " : " + shape + "," + blockDraw ); + + byte fogDensity = reader.ReadUInt8(); + info.FogDensity[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f; + info.FogColour[block] = new FastColour( + reader.ReadUInt8(), reader.ReadUInt8(), reader.ReadUInt8() ); info.SetupCullingCache(); } diff --git a/ClassicalSharp/Network/NetworkProcessor.cs b/ClassicalSharp/Network/NetworkProcessor.cs index 832248157..82bf8e713 100644 --- a/ClassicalSharp/Network/NetworkProcessor.cs +++ b/ClassicalSharp/Network/NetworkProcessor.cs @@ -440,7 +440,6 @@ namespace ClassicalSharp { int maxHandledPacket; void SetupHandlers() { - maxHandledPacket = (int)PacketId.Max; handlers = new Action[] { HandleHandshake, HandlePing, HandleLevelInit, HandleLevelDataChunk, HandleLevelFinalise, null, HandleSetBlock, HandleAddEntity, HandleEntityTeleport, HandleRelPosAndOrientationUpdate, @@ -453,9 +452,9 @@ namespace ClassicalSharp { HandleCpeEnvColours, HandleCpeMakeSelection, HandleCpeRemoveSelection, HandleCpeSetBlockPermission, HandleCpeChangeModel, HandleCpeEnvSetMapApperance, HandleCpeEnvWeatherType, HandleCpeHackControl, HandleCpeExtAddEntity2, - null, HandleCpeDefineBlockOrLiquid, HandleCpeDefineBlockOrLiquid, - HandleCpeRemoveBlockDefinition + null, HandleCpeDefineBlock, HandleCpeRemoveBlockDefinition, }; + maxHandledPacket = handlers.Length; } } } \ No newline at end of file diff --git a/ClassicalSharp/Utils/FastColour.cs b/ClassicalSharp/Utils/FastColour.cs index 05821666a..6ce240f82 100644 --- a/ClassicalSharp/Utils/FastColour.cs +++ b/ClassicalSharp/Utils/FastColour.cs @@ -56,7 +56,6 @@ namespace ClassicalSharp { result.R = (byte)( value.R * t ); result.G = (byte)( value.G * t ); result.B = (byte)( value.B * t ); - result.A = 50; return result; }