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;
}
}
}