diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 7b95750b..0af06344 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -8,7 +8,7 @@ namespace MinecraftClient.Commands public class Move : Command { public override string CmdName { get { return "move"; } } - public override string CmdUsage { get { return "move [-f]"; } } + public override string CmdUsage { get { return "move [-f]"; } } public override string CmdDesc { get { return "walk or start walking. \"-f\": force unsafe movements like falling or touching fire"; } } public override string Run(McClient handler, string command, Dictionary localVars) @@ -35,6 +35,14 @@ namespace MinecraftClient.Commands handler.SetTerrainEnabled(false); return Translations.Get("cmd.move.disable"); } + else if (args[0] == "gravity") + { + if (args.Count >= 2) + Settings.GravityEnabled = (args[1] == "on"); + if (Settings.GravityEnabled) + return Translations.Get("cmd.move.gravity.enabled"); + else return Translations.Get("cmd.move.gravity.disabled"); + } else if (handler.GetTerrainEnabled()) { if (args.Count == 1) diff --git a/MinecraftClient/Mapping/Movement.cs b/MinecraftClient/Mapping/Movement.cs index 8590899b..6c947343 100644 --- a/MinecraftClient/Mapping/Movement.cs +++ b/MinecraftClient/Mapping/Movement.cs @@ -21,21 +21,24 @@ namespace MinecraftClient.Mapping /// Updated location after applying gravity public static Location HandleGravity(World world, Location location, ref double motionY) { - Location onFoots = new Location(location.X, Math.Floor(location.Y), location.Z); - Location belowFoots = Move(location, Direction.Down); - if (location.Y > Math.Truncate(location.Y) + 0.0001) + if (Settings.GravityEnabled) { - belowFoots = location; - belowFoots.Y = Math.Truncate(location.Y); + Location onFoots = new Location(location.X, Math.Floor(location.Y), location.Z); + Location belowFoots = Move(location, Direction.Down); + if (location.Y > Math.Truncate(location.Y) + 0.0001) + { + belowFoots = location; + belowFoots.Y = Math.Truncate(location.Y); + } + if (!IsOnGround(world, location) && !IsSwimming(world, location)) + { + while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1) + belowFoots = Move(belowFoots, Direction.Down); + location = Move2Steps(location, belowFoots, ref motionY, true).Dequeue(); + } + else if (!(world.GetBlock(onFoots).Type.IsSolid())) + location = Move2Steps(location, onFoots, ref motionY, true).Dequeue(); } - if (!IsOnGround(world, location) && !IsSwimming(world, location)) - { - while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1) - belowFoots = Move(belowFoots, Direction.Down); - location = Move2Steps(location, belowFoots, ref motionY, true).Dequeue(); - } - else if (!(world.GetBlock(onFoots).Type.IsSolid())) - location = Move2Steps(location, onFoots, ref motionY, true).Dequeue(); return location; } diff --git a/MinecraftClient/Resources/lang/de.ini b/MinecraftClient/Resources/lang/de.ini index eda6a17d..e5a9e4b0 100644 --- a/MinecraftClient/Resources/lang/de.ini +++ b/MinecraftClient/Resources/lang/de.ini @@ -311,6 +311,9 @@ cmd.move.dir_fail=Kann nicht in diese Richtung laufen. cmd.move.walk=Gehe nach {0} cmd.move.fail=Konnte Pfad nach {0} nicht berechnen. cmd.move.suggestforce=Weg nach {0} konnte nicht berechnet werden. Benutze den -f Parameter, um unsichere Wege zu aktivieren. +cmd.move.gravity.enabled=Gravitation ist aktiv. +cmd.move.gravity.disabled=Gravitation ist deaktiviert. + # Reco cmd.reco.desc=Starte neu und verbinde erneut zum Server. diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 5784f441..089fad6b 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -311,6 +311,8 @@ cmd.move.dir_fail=Cannot move in that direction. cmd.move.walk=Walking to {0} cmd.move.fail=Failed to compute path to {0} cmd.move.suggestforce=Failed to compute a safe path to {0}. Try -f parameter to allow unsafe movements. +cmd.move.gravity.enabled=Gravity is enabled. +cmd.move.gravity.disabled=Gravity is disabled. # Reco cmd.reco.desc=restart and reconnect to the server. diff --git a/MinecraftClient/Resources/lang/fr.ini b/MinecraftClient/Resources/lang/fr.ini index 53e127bb..a42399ab 100644 --- a/MinecraftClient/Resources/lang/fr.ini +++ b/MinecraftClient/Resources/lang/fr.ini @@ -311,6 +311,8 @@ cmd.move.dir_fail=Impossible de se déplacer dans cette direction. cmd.move.walk=Marche vers {0} cmd.move.fail=Échec de calcul du chemin vers {0} cmd.move.suggestforce=Échec de calcul du chemin vers {0}. Utilisez -f pour autoriser les mouvements risqués. +cmd.move.gravity.enabled=La gravité est activée. +cmd.move.gravity.disabled=La gravité est désactivée. # Reco cmd.reco.desc=Relancer le programme et se reconnecter au serveur diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index ac790230..4d5f907b 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -93,6 +93,7 @@ namespace MinecraftClient public static bool DisplayChatLinks = true; public static bool DisplayInventoryLayout = true; public static bool TerrainAndMovements = false; + public static bool GravityEnabled = true; public static bool InventoryHandling = false; public static string PrivateMsgsCmdName = "tell"; public static CacheType SessionCaching = CacheType.Disk;