diff --git a/Network/Enums.cs b/Network/Enums.cs index 739c35f70..edb5766d4 100644 --- a/Network/Enums.cs +++ b/Network/Enums.cs @@ -51,4 +51,13 @@ namespace ClassicalSharp { BottomRight3 = 13, Announcement = 100, } + + public enum CpeBlockFace { + XMax, + XMin, + YMax, + YMin, + ZMax, + ZMin, + } } diff --git a/Network/NetworkProcessor.cs b/Network/NetworkProcessor.cs index e96285886..7c410df99 100644 --- a/Network/NetworkProcessor.cs +++ b/Network/NetworkProcessor.cs @@ -174,18 +174,18 @@ namespace ClassicalSharp { WriteUInt8( version ); } - private static void MakePlayerClick( byte button, byte action, short yaw, short pitch, byte targetEntity, - Vector3I targetPos, byte targetFace ) { + private static void MakePlayerClick( byte button, bool buttonDown, float yaw, float pitch, byte targetEntity, + Vector3I targetPos, CpeBlockFace targetFace ) { WriteUInt8( (byte)PacketId.CpePlayerClick ); WriteUInt8( button ); - WriteUInt8( action ); - WriteInt16( yaw ); - WriteInt16( pitch ); + WriteUInt8( buttonDown ? (byte)0 : (byte)1 ); + WriteInt16( (short)Utils.DegreesToPacked( yaw, 65536 ) ); + WriteInt16( (short)Utils.DegreesToPacked( pitch, 65536 ) ); WriteUInt8( targetEntity ); WriteInt16( (short)targetPos.X ); WriteInt16( (short)targetPos.Y ); WriteInt16( (short)targetPos.Z ); - WriteUInt8( targetFace ); + WriteUInt8( (byte)targetFace ); } static void WriteString( string value ) { diff --git a/OpenTK/Input/MouseButton.cs b/OpenTK/Input/MouseButton.cs index 9800d7807..98a3bb0c9 100644 --- a/OpenTK/Input/MouseButton.cs +++ b/OpenTK/Input/MouseButton.cs @@ -41,14 +41,14 @@ namespace OpenTK.Input /// Left = 0, /// - /// The middle mouse button. - /// - Middle, - /// /// The right mouse button. /// Right, /// + /// The middle mouse button. + /// + Middle, + /// /// The first extra mouse button. /// Button1, diff --git a/Physics/Picking.cs b/Physics/Picking.cs index a814e53f8..79ddd0b80 100644 --- a/Physics/Picking.cs +++ b/Physics/Picking.cs @@ -120,6 +120,7 @@ namespace ClassicalSharp { public Vector3I BlockPos; public Vector3I TranslatedPos; public bool Valid = true; + public CpeBlockFace BlockFace; public void UpdateBlockPos( Vector3 p1, Vector3 p2, Vector3 origin, Vector3 dir, float t0, float t1 ) { Min = Vector3.Min( p1, p2 ); @@ -130,20 +131,22 @@ namespace ClassicalSharp { Vector3I normal = Vector3I.Zero; Vector3 intersect = origin + dir * t0; float dist = float.PositiveInfinity; - TestAxis( intersect.X - Min.X, ref dist, -Vector3I.UnitX, ref normal ); - TestAxis( intersect.X - Max.X, ref dist, Vector3I.UnitX, ref normal ); - TestAxis( intersect.Y - Min.Y, ref dist, -Vector3I.UnitY, ref normal ); - TestAxis( intersect.Y - Max.Y, ref dist, Vector3I.UnitY, ref normal ); - TestAxis( intersect.Z - Min.Z, ref dist, -Vector3I.UnitZ, ref normal ); - TestAxis( intersect.Z - Max.Z, ref dist, Vector3I.UnitZ, ref normal ); + TestAxis( intersect.X - Min.X, ref dist, -Vector3I.UnitX, ref normal, CpeBlockFace.XMin ); + TestAxis( intersect.X - Max.X, ref dist, Vector3I.UnitX, ref normal, CpeBlockFace.XMax ); + TestAxis( intersect.Y - Min.Y, ref dist, -Vector3I.UnitY, ref normal, CpeBlockFace.YMin ); + TestAxis( intersect.Y - Max.Y, ref dist, Vector3I.UnitY, ref normal, CpeBlockFace.YMax ); + TestAxis( intersect.Z - Min.Z, ref dist, -Vector3I.UnitZ, ref normal, CpeBlockFace.ZMin ); + TestAxis( intersect.Z - Max.Z, ref dist, Vector3I.UnitZ, ref normal, CpeBlockFace.ZMax ); TranslatedPos = BlockPos + normal; } - static void TestAxis( float dAxis, ref float dist, Vector3I nAxis, ref Vector3I normal ) { + void TestAxis( float dAxis, ref float dist, Vector3I nAxis, ref Vector3I normal, + CpeBlockFace fAxis) { dAxis = Math.Abs( dAxis ); if( dAxis < dist ) { dist = dAxis; normal = nAxis; + BlockFace = fAxis; } } }