From 3e6e2700440fc86b75a46186b3954cabccec84aa Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 14 Dec 2015 16:02:03 +1100 Subject: [PATCH] Fix water/lava parkour being more difficult than classicube. Big thanks to venom983 to lots of assistance with testing. --- ClassicalSharp/Entities/Entity.cs | 5 +++-- ClassicalSharp/Entities/EntityList.cs | 2 +- ClassicalSharp/Entities/LocalPlayer.cs | 6 +++++- ClassicalSharp/Physics/BoundingBox.cs | 6 ++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ClassicalSharp/Entities/Entity.cs b/ClassicalSharp/Entities/Entity.cs index e2cda00ce..beea68d28 100644 --- a/ClassicalSharp/Entities/Entity.cs +++ b/ClassicalSharp/Entities/Entity.cs @@ -97,11 +97,12 @@ namespace ClassicalSharp { /// Constant offset used to avoid floating point roundoff errors. public const float Adjustment = 0.001f; + static readonly Vector3 liqExpand = new Vector3( 0.25f/16f, 0/16f, 0.25f/16f ); /// Determines whether any of the blocks that intersect the /// bounding box of this entity are lava or still lava. protected bool TouchesAnyLava() { - BoundingBox bounds = CollisionBounds; + BoundingBox bounds = CollisionBounds.Expand( liqExpand ); // Even though we collide with lava 3 blocks above our feet, vanilla client thinks // that we do not.. so we have to maintain compatibility here. bounds.Max.Y -= 4/16f; @@ -119,7 +120,7 @@ namespace ClassicalSharp { /// Determines whether any of the blocks that intersect the /// bounding box of this entity are water or still water. protected bool TouchesAnyWater() { - BoundingBox bounds = CollisionBounds; + BoundingBox bounds = CollisionBounds.Expand( liqExpand ); bounds.Max.Y -= 4/16f; return TouchesAny( bounds, b => b == (byte)Block.Water || b == (byte)Block.StillWater ); diff --git a/ClassicalSharp/Entities/EntityList.cs b/ClassicalSharp/Entities/EntityList.cs index 54828b39c..7ef488d9d 100644 --- a/ClassicalSharp/Entities/EntityList.cs +++ b/ClassicalSharp/Entities/EntityList.cs @@ -63,7 +63,7 @@ namespace ClassicalSharp { if( NamesMode != NameMode.AllNames ) closestId = GetClosetPlayer( game.LocalPlayer ); - if( NamesMode == NameMode.HoveredOnly ) + if( NamesMode == NameMode.HoveredOnly || !game.LocalPlayer.CanSeeAllNames ) return; for( int i = 0; i < Players.Length; i++ ) { diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index f21a5a0ad..cc0abbf46 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -36,6 +36,9 @@ namespace ClassicalSharp { /// Whether the player is allowed to use pushback block placing. public bool CanPushbackBlocks = true; + /// Whether the player is allowed to see all entity name tags. + public bool CanSeeAllNames = true; + float jumpVel = 0.42f; /// Returns the height that the client can currently jump up to.
/// Note that when speeding is enabled the client is able to jump much further.
@@ -175,7 +178,7 @@ namespace ClassicalSharp { } else if( pastJumpPoint ) { // either A) jump bob in water B) climb up solid on side if( canLiquidJump || (collideX || collideZ) ) - Velocity.Y += touchLava ? 0.40f : 0.10f; + Velocity.Y += touchLava ? 0.20f : 0.10f; canLiquidJump = false; } } else if( useLiquidGravity ) { @@ -314,6 +317,7 @@ namespace ClassicalSharp { inv.CanPlace[(int)Block.StillWater] = value == 0x64; inv.CanPlace[(int)Block.Lava] = value == 0x64; inv.CanPlace[(int)Block.StillLava] = value == 0x64; + CanSeeAllNames = value == 0x64; } internal Vector3 lastPos, nextPos; diff --git a/ClassicalSharp/Physics/BoundingBox.cs b/ClassicalSharp/Physics/BoundingBox.cs index 84b42ee44..3d1f3c97c 100644 --- a/ClassicalSharp/Physics/BoundingBox.cs +++ b/ClassicalSharp/Physics/BoundingBox.cs @@ -23,6 +23,12 @@ namespace ClassicalSharp { public BoundingBox Offset( Vector3 amount ) { return new BoundingBox( Min + amount, Max + amount ); } + + /// Returns a new bounding box, with the minimum and maximum coordinates + /// of the original bounding box expanded away from origin the given vector. + public BoundingBox Expand( Vector3 amount ) { + return new BoundingBox( Min - amount, Max + amount ); + } /// Determines whether this bounding box intersects /// the given bounding box on any axes.