diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs
index 101b6845..c7a2c61c 100644
--- a/MinecraftClient/Commands/Move.cs
+++ b/MinecraftClient/Commands/Move.cs
@@ -73,12 +73,14 @@ namespace MinecraftClient.Commands
}
Location goal = Movement.Move(handler.GetCurrentLocation(), direction);
- if (handler.GetWorld().GetChunkColumn(goal) == null || handler.GetWorld().GetChunkColumn(goal)!.FullyLoaded == false)
+
+ ChunkColumn? chunkColumn = handler.GetWorld().GetChunkColumn(goal);
+ if (chunkColumn == null || chunkColumn.FullyLoaded == false)
return Translations.Get("cmd.move.chunk_not_loaded");
if (Movement.CanMove(handler.GetWorld(), handler.GetCurrentLocation(), direction))
{
- if (handler.MoveTo(Movement.Move(handler.GetCurrentLocation(), direction), allowUnsafe: takeRisk))
+ if (handler.MoveTo(goal, allowUnsafe: takeRisk))
return Translations.Get("cmd.move.moving", args[0]);
else return takeRisk ? Translations.Get("cmd.move.dir_fail") : Translations.Get("cmd.move.suggestforce");
}
@@ -93,12 +95,12 @@ namespace MinecraftClient.Commands
int z = int.Parse(args[2]);
Location goal = new Location(x, y, z);
- if (handler.GetWorld().GetChunkColumn(goal) == null || handler.GetWorld().GetChunkColumn(goal)!.FullyLoaded == false)
+ ChunkColumn? chunkColumn = handler.GetWorld().GetChunkColumn(goal);
+ if (chunkColumn == null || chunkColumn.FullyLoaded == false)
return Translations.Get("cmd.move.chunk_not_loaded");
Location current = handler.GetCurrentLocation();
- Location currentCenter = new Location(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5);
- handler.MoveTo(currentCenter, allowDirectTeleport: true);
+ handler.MoveTo(current.ToCenter(), allowDirectTeleport: true);
if (handler.MoveTo(goal, allowUnsafe: takeRisk))
return Translations.Get("cmd.move.walk", goal, current);
diff --git a/MinecraftClient/Mapping/Location.cs b/MinecraftClient/Mapping/Location.cs
index cf45c493..1e4523ea 100644
--- a/MinecraftClient/Mapping/Location.cs
+++ b/MinecraftClient/Mapping/Location.cs
@@ -61,6 +61,29 @@ namespace MinecraftClient.Mapping
Z = chunkZ * Chunk.SizeZ + blockZ;
}
+ ///
+ /// Round coordinates
+ ///
+ /// itself
+ public Location ToFloor()
+ {
+ this.X = Math.Floor(this.X);
+ this.Y = Math.Floor(this.Y);
+ this.Z = Math.Floor(this.Z);
+ return this;
+ }
+
+ ///
+ /// Get the center coordinates
+ ///
+ /// itself
+ public Location ToCenter()
+ {
+ this.X = Math.Floor(this.X) + 0.5;
+ this.Z = Math.Floor(this.Z) + 0.5;
+ return this;
+ }
+
///
/// The X index of the corresponding chunk in the world
///
diff --git a/MinecraftClient/Mapping/Movement.cs b/MinecraftClient/Mapping/Movement.cs
index 8a2715c4..0853bbb2 100644
--- a/MinecraftClient/Mapping/Movement.cs
+++ b/MinecraftClient/Mapping/Movement.cs
@@ -168,7 +168,8 @@ namespace MinecraftClient.Mapping
throw new ArgumentException("minOffset must be lower or equal to maxOffset", "minOffset");
// Round start coordinates for easier calculation
- start = new Location(Math.Floor(start.X), Math.Floor(start.Y), Math.Floor(start.Z));
+ start.ToFloor();
+ goal.ToFloor();
// We always use distance squared so our limits must also be squared.
minOffset *= minOffset;
diff --git a/MinecraftClient/Protocol/ProfileKey/KeysCache.cs b/MinecraftClient/Protocol/ProfileKey/KeysCache.cs
index 4fc42be1..0e492456 100644
--- a/MinecraftClient/Protocol/ProfileKey/KeysCache.cs
+++ b/MinecraftClient/Protocol/ProfileKey/KeysCache.cs
@@ -121,14 +121,14 @@ namespace MinecraftClient.Protocol.Keys
{
foreach (string line in FileMonitor.ReadAllLinesWithRetries(KeysCacheFilePlaintext))
{
- if (!line.Trim().StartsWith("#"))
+ if (!line.TrimStart().StartsWith("#"))
{
int separatorIdx = line.IndexOf('=');
if (separatorIdx >= 1 && line.Length > separatorIdx + 1)
{
- string login = line.Substring(0, separatorIdx);
- string value = line.Substring(separatorIdx + 1);
+ string login = line[..separatorIdx];
+ string value = line[(separatorIdx + 1)..];
try
{
PlayerKeyPair playerKeyPair = PlayerKeyPair.FromString(value);