Fix all warnings & Trim (#2226)

* Fix AutoFishing crash
* Fix all warnings
* Remove DotNetZip.
* Fix the usage of HttpClient.
This commit is contained in:
BruceChen 2022-10-02 18:31:08 +08:00 committed by GitHub
parent 4aa6c1c99f
commit 1d52d1eadd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
227 changed files with 2201 additions and 43564 deletions

View file

@ -2,8 +2,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace MinecraftClient.Mapping
{
@ -23,7 +21,7 @@ namespace MinecraftClient.Mapping
/// </summary>
private static Dimension curDimension = new();
private static Dictionary<string, Dimension> dimensionList = new();
private static readonly Dictionary<string, Dimension> dimensionList = new();
/// <summary>
/// Chunk data parsing progress
@ -62,10 +60,11 @@ namespace MinecraftClient.Mapping
public static void StoreDimensionList(Dictionary<string, object> registryCodec)
{
var dimensionListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:dimension_type"])["value"]);
foreach (Dictionary<string, object> dimensionNbt in dimensionListNbt)
foreach (var (dimensionName, dimensionType) in from Dictionary<string, object> dimensionNbt in dimensionListNbt
let dimensionName = (string)dimensionNbt["name"]
let dimensionType = (Dictionary<string, object>)dimensionNbt["element"]
select (dimensionName, dimensionType))
{
string dimensionName = (string)dimensionNbt["name"];
Dictionary<string, object> dimensionType = (Dictionary<string, object>)dimensionNbt["element"];
StoreOneDimension(dimensionName, dimensionType);
}
}
@ -78,7 +77,7 @@ namespace MinecraftClient.Mapping
public static void StoreOneDimension(string dimensionName, Dictionary<string, object> dimensionType)
{
if (dimensionList.ContainsKey(dimensionName))
dimensionList.Remove(dimensionName);
dimensionList.Remove(dimensionName);
dimensionList.Add(dimensionName, new Dimension(dimensionName, dimensionType));
}
@ -170,16 +169,16 @@ namespace MinecraftClient.Mapping
/// <returns>Block matching the specified block type</returns>
public List<Location> FindBlock(Location from, Material block, int radiusx, int radiusy, int radiusz)
{
Location minPoint = new Location(from.X - radiusx, from.Y - radiusy, from.Z - radiusz);
Location maxPoint = new Location(from.X + radiusx, from.Y + radiusy, from.Z + radiusz);
List<Location> list = new List<Location> { };
Location minPoint = new(from.X - radiusx, from.Y - radiusy, from.Z - radiusz);
Location maxPoint = new(from.X + radiusx, from.Y + radiusy, from.Z + radiusz);
List<Location> list = new() { };
for (double x = minPoint.X; x <= maxPoint.X; x++)
{
for (double y = minPoint.Y; y <= maxPoint.Y; y++)
{
for (double z = minPoint.Z; z <= maxPoint.Z; z++)
{
Location doneloc = new Location(x, y, z);
Location doneloc = new(x, y, z);
Block doneblock = GetBlock(doneloc);
Material blockType = doneblock.Type;
if (blockType == block)
@ -218,5 +217,19 @@ namespace MinecraftClient.Mapping
chunkCnt = 0;
chunkLoadNotCompleted = 0;
}
public static 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;
}
}
}