mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Bug fix: /move command went to the wrong location
This commit is contained in:
parent
5f520e2cf4
commit
ed8e97fd2d
4 changed files with 35 additions and 9 deletions
|
|
@ -73,12 +73,14 @@ namespace MinecraftClient.Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
Location goal = Movement.Move(handler.GetCurrentLocation(), direction);
|
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");
|
return Translations.Get("cmd.move.chunk_not_loaded");
|
||||||
|
|
||||||
if (Movement.CanMove(handler.GetWorld(), handler.GetCurrentLocation(), direction))
|
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]);
|
return Translations.Get("cmd.move.moving", args[0]);
|
||||||
else return takeRisk ? Translations.Get("cmd.move.dir_fail") : Translations.Get("cmd.move.suggestforce");
|
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]);
|
int z = int.Parse(args[2]);
|
||||||
Location goal = new Location(x, y, z);
|
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");
|
return Translations.Get("cmd.move.chunk_not_loaded");
|
||||||
|
|
||||||
Location current = handler.GetCurrentLocation();
|
Location current = handler.GetCurrentLocation();
|
||||||
Location currentCenter = new Location(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5);
|
handler.MoveTo(current.ToCenter(), allowDirectTeleport: true);
|
||||||
handler.MoveTo(currentCenter, allowDirectTeleport: true);
|
|
||||||
|
|
||||||
if (handler.MoveTo(goal, allowUnsafe: takeRisk))
|
if (handler.MoveTo(goal, allowUnsafe: takeRisk))
|
||||||
return Translations.Get("cmd.move.walk", goal, current);
|
return Translations.Get("cmd.move.walk", goal, current);
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,29 @@ namespace MinecraftClient.Mapping
|
||||||
Z = chunkZ * Chunk.SizeZ + blockZ;
|
Z = chunkZ * Chunk.SizeZ + blockZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Round coordinates
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>itself</returns>
|
||||||
|
public Location ToFloor()
|
||||||
|
{
|
||||||
|
this.X = Math.Floor(this.X);
|
||||||
|
this.Y = Math.Floor(this.Y);
|
||||||
|
this.Z = Math.Floor(this.Z);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the center coordinates
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>itself</returns>
|
||||||
|
public Location ToCenter()
|
||||||
|
{
|
||||||
|
this.X = Math.Floor(this.X) + 0.5;
|
||||||
|
this.Z = Math.Floor(this.Z) + 0.5;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The X index of the corresponding chunk in the world
|
/// The X index of the corresponding chunk in the world
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,8 @@ namespace MinecraftClient.Mapping
|
||||||
throw new ArgumentException("minOffset must be lower or equal to maxOffset", "minOffset");
|
throw new ArgumentException("minOffset must be lower or equal to maxOffset", "minOffset");
|
||||||
|
|
||||||
// Round start coordinates for easier calculation
|
// 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.
|
// We always use distance squared so our limits must also be squared.
|
||||||
minOffset *= minOffset;
|
minOffset *= minOffset;
|
||||||
|
|
|
||||||
|
|
@ -121,14 +121,14 @@ namespace MinecraftClient.Protocol.Keys
|
||||||
{
|
{
|
||||||
foreach (string line in FileMonitor.ReadAllLinesWithRetries(KeysCacheFilePlaintext))
|
foreach (string line in FileMonitor.ReadAllLinesWithRetries(KeysCacheFilePlaintext))
|
||||||
{
|
{
|
||||||
if (!line.Trim().StartsWith("#"))
|
if (!line.TrimStart().StartsWith("#"))
|
||||||
{
|
{
|
||||||
|
|
||||||
int separatorIdx = line.IndexOf('=');
|
int separatorIdx = line.IndexOf('=');
|
||||||
if (separatorIdx >= 1 && line.Length > separatorIdx + 1)
|
if (separatorIdx >= 1 && line.Length > separatorIdx + 1)
|
||||||
{
|
{
|
||||||
string login = line.Substring(0, separatorIdx);
|
string login = line[..separatorIdx];
|
||||||
string value = line.Substring(separatorIdx + 1);
|
string value = line[(separatorIdx + 1)..];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PlayerKeyPair playerKeyPair = PlayerKeyPair.FromString(value);
|
PlayerKeyPair playerKeyPair = PlayerKeyPair.FromString(value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue