diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs
index c88c2c1c7..11322acef 100644
--- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs
+++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs
@@ -61,8 +61,10 @@ namespace ClassicalSharp {
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
(g, v) => ((SinglePlayerServer)network).physics.Enabled = (v == "yes") ),
Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick,
- g => g.PushbackBlockPlacing ? "yes" : "no",
- (g, v) => g.PushbackBlockPlacing = (v == "yes" ) ),
+ g => g.LocalPlayer.PushbackBlockPlacing
+ && g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
+ (g, v) => { if( g.LocalPlayer.CanPushbackBlocks)
+ g.LocalPlayer.PushbackBlockPlacing = v == "yes"; }),
Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
(g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs
index 63913bb94..666710636 100644
--- a/ClassicalSharp/Entities/LocalPlayer.cs
+++ b/ClassicalSharp/Entities/LocalPlayer.cs
@@ -14,28 +14,23 @@ namespace ClassicalSharp {
public int SpeedMultiplier = 10;
public byte UserType;
+ public bool PushbackBlockPlacing;
bool canSpeed = true, canFly = true, canRespawn = true, canNoclip = true;
- /// Whether the player has permission to increase its speed beyond the normal walking speed.
- public bool CanSpeed {
- get { return canSpeed; }
- set { canSpeed = value; }
- }
+ /// Whether the player is allowed to increase its speed beyond the normal walking speed.
+ public bool CanSpeed = true;
- public bool CanFly {
- get { return canFly; }
- set { canFly = value; if( !value ) flying = false; }
- }
+ /// Whether the player is allowed to fly in the world.
+ public bool CanFly = true;
- public bool CanRespawn {
- get { return canRespawn; }
- set { canRespawn = value; }
- }
+ /// Whether the player is allowed to teleport to their respawn point.
+ public bool CanRespawn = true;
- public bool CanNoclip {
- get { return canNoclip; }
- set { canNoclip = value; if( !value ) noClip = false; }
- }
+ /// Whether the player is allowed to pass through all blocks.
+ public bool CanNoclip = true;
+
+ /// Whether the player is allowed to use pushback block placing.
+ public bool CanPushbackBlocks = true;
float jumpVel = 0.42f;
/// Returns the height that the client can currently jump up to.
@@ -214,12 +209,11 @@ namespace ClassicalSharp {
public void ParseHackFlags( string name, string motd ) {
string joined = name + motd;
if( joined.Contains( "-hax" ) ) {
- CanFly = CanNoclip = CanSpeed = CanRespawn = false;
- game.CanUseThirdPersonCamera = false;
- game.SetCamera( false );
+ CanFly = CanNoclip = CanRespawn = CanSpeed =
+ CanPushbackBlocks = game.CanUseThirdPersonCamera = false;
} else { // By default (this is also the case with WoM), we can use hacks.
- CanFly = CanNoclip = CanSpeed = CanRespawn = true;
- game.CanUseThirdPersonCamera = true;
+ CanFly = CanNoclip = CanRespawn = CanSpeed =
+ CanPushbackBlocks = game.CanUseThirdPersonCamera = true;
}
ParseFlag( b => CanFly = b, joined, "fly" );
@@ -228,7 +222,9 @@ namespace ClassicalSharp {
ParseFlag( b => CanRespawn = b, joined, "respawn" );
if( UserType == 0x64 )
- ParseFlag( b => CanFly = CanNoclip = CanRespawn = CanSpeed = b, joined, "ophax" );
+ ParseFlag( b => CanFly = CanNoclip = CanRespawn =
+ CanSpeed = CanPushbackBlocks = b, joined, "ophax" );
+ CheckHacksConsistency();
}
static void ParseFlag( Action action, string joined, string flag ) {
@@ -239,6 +235,17 @@ namespace ClassicalSharp {
}
}
+ /// Disables any hacks if their respective CanHackX value is set to false.
+ public void CheckHacksConsistency() {
+ if( !CanFly ) flying = false;
+ if( !CanNoclip ) noClip = false;
+ if( !CanSpeed) canSpeed = false;
+ if( !CanPushbackBlocks ) PushbackBlockPlacing = false;
+
+ if( !game.CanUseThirdPersonCamera )
+ game.SetCamera( false );
+ }
+
/// Sets the user type of this user. This is used to control permissions for grass,
/// bedrock, water and lava blocks on servers that don't support CPE block permissions.
public void SetUserType( byte value ) {
diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs
index 10d06a293..5df78bfa6 100644
--- a/ClassicalSharp/Game/Game.cs
+++ b/ClassicalSharp/Game/Game.cs
@@ -69,7 +69,7 @@ namespace ClassicalSharp {
public int MouseSensitivity = 30;
public int ChatLines = 12;
public bool HideGui = false, ShowFPS = true;
- public bool PushbackBlockPlacing;
+
public Animations Animations;
internal int CloudsTextureId, RainTextureId, SnowTextureId;
internal bool screenshotRequested;
diff --git a/ClassicalSharp/Game/InputHandler.cs b/ClassicalSharp/Game/InputHandler.cs
index 11f536906..440bd22bb 100644
--- a/ClassicalSharp/Game/InputHandler.cs
+++ b/ClassicalSharp/Game/InputHandler.cs
@@ -116,9 +116,9 @@ namespace ClassicalSharp {
pos.X + 1, pos.Y + height, pos.Z + 1 );
BoundingBox localBB = game.LocalPlayer.CollisionBounds;
- if( !localBB.Intersects( blockBB ) ) return true;
+ if( game.LocalPlayer.noClip || !localBB.Intersects( blockBB ) ) return true;
- if( game.PushbackBlockPlacing ) {
+ if( game.LocalPlayer.PushbackBlockPlacing ) {
return PushbackPlace( selected, blockBB );
} else {
localBB.Min.Y += 0.25f + Entity.Adjustment;
@@ -263,7 +263,7 @@ namespace ClassicalSharp {
}
}
- static int[] viewDistances = { 16, 32, 64, 128, 256, 512 };
+ static int[] viewDistances = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
void KeyDownHandler( object sender, KeyboardKeyEventArgs e ) {
Key key = e.Key;
if( SimulateMouse( key, true ) ) return;
diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs
index 966243441..ee24631e3 100644
--- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs
+++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs
@@ -308,10 +308,8 @@ namespace ClassicalSharp {
game.LocalPlayer.CanSpeed = reader.ReadUInt8() != 0;
game.LocalPlayer.CanRespawn = reader.ReadUInt8() != 0;
game.CanUseThirdPersonCamera = reader.ReadUInt8() != 0;
+ game.LocalPlayer.CheckHacksConsistency();
- if( !game.CanUseThirdPersonCamera ) {
- game.SetCamera( false );
- }
float jumpHeight = reader.ReadInt16() / 32f;
if( jumpHeight < 0 ) jumpHeight = 1.4f;
game.LocalPlayer.CalculateJumpVelocity( jumpHeight );