Make chunk loading status to be displayed using "/move" command

This commit is contained in:
BruceChen 2022-07-25 14:20:24 +08:00
parent ff014d2912
commit b0b45a74a0
5 changed files with 23 additions and 27 deletions

View file

@ -17,7 +17,14 @@ namespace MinecraftClient.Commands
bool takeRisk = false;
if (args.Count < 1)
return GetCmdDescTranslated();
{
string desc = GetCmdDescTranslated();
if (handler.GetTerrainEnabled())
handler.Log.Info(getChunkLoadingStatus(handler.GetWorld()));
return desc;
}
if (args.Contains("-f"))
{
@ -88,5 +95,19 @@ namespace MinecraftClient.Commands
}
else return Translations.Get("extra.terrainandmovement_required");
}
private string getChunkLoadingStatus(World world)
{
double chunkLoadedRatio;
if (world.chunkCnt == 0)
chunkLoadedRatio = 0;
else
chunkLoadedRatio = (world.chunkCnt - world.chunkLoadNotCompleted) / (double)world.chunkCnt;
string status = Translations.Get("cmd.move.chunk_loading_status",
chunkLoadedRatio, world.chunkCnt - world.chunkLoadNotCompleted, world.chunkCnt);
return status;
}
}
}

View file

@ -31,7 +31,6 @@ namespace MinecraftClient.Mapping
belowFoots = location;
belowFoots.Y = Math.Truncate(location.Y);
}
//Console.WriteLine("IsOnGround = " + IsOnGround(world, location));
if (!IsOnGround(world, location) && !IsSwimming(world, location))
{
while (!IsOnGround(world, belowFoots) &&

View file

@ -59,8 +59,6 @@ namespace MinecraftClient
private float playerYaw;
private float playerPitch;
private double motionY;
private int chunkLoadingStateTicks = 30; // Setting it to zero to disable chunk loading statu log
private double lastChunkLoadedRatio = 0;
private string host;
private int port;
@ -387,26 +385,6 @@ namespace MinecraftClient
taskToRun();
}
}
if (terrainAndMovementsEnabled)
{
if (chunkLoadingStateTicks <= 0)
{
chunkLoadingStateTicks = 50;
if (world.chunkCnt != 0)
{
double chunkLoadedRatio = (world.chunkCnt - world.chunkLoadNotCompleted) / (double)world.chunkCnt;
if (chunkLoadedRatio != lastChunkLoadedRatio)
{
Log.Info(string.Format("Chunk loading: {0:P} {1}/{2}",
chunkLoadedRatio, world.chunkCnt - world.chunkLoadNotCompleted, world.chunkCnt));
lastChunkLoadedRatio = chunkLoadedRatio;
}
}
}
else
chunkLoadingStateTicks--;
}
}
#region Connection Lost and Disconnect from Server

View file

@ -332,10 +332,7 @@ namespace MinecraftClient.Protocol.Handlers
currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
if (protocolversion >= MC1162Version)
new Task(() =>
{
handler.GetWorld().SetDimension(currentDimensionName, currentDimensionType);
}).Start();
if (protocolversion >= MC115Version)
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above

View file

@ -319,6 +319,7 @@ 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.
cmd.move.chunk_loading_status=Chunk loading status: {0:P} - {1} out of {2} load completed.
cmd.move.chunk_not_loaded=The chunk where the target location resides has not yet been loaded.
# Reco