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

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
//using System.Linq;
//using System.Text;
using MinecraftClient.Mapping;
@ -16,9 +14,9 @@ namespace MinecraftClient.Protocol.Handlers
/// </summary>
class Protocol18Terrain
{
private int protocolversion;
private DataTypes dataTypes;
private IMinecraftComHandler handler;
private readonly int protocolversion;
private readonly DataTypes dataTypes;
private readonly IMinecraftComHandler handler;
/// <summary>
/// Initialize a new Terrain Decoder
@ -27,7 +25,7 @@ namespace MinecraftClient.Protocol.Handlers
/// <param name="dataTypes">Minecraft Protocol Data Types</param>
public Protocol18Terrain(int protocolVersion, DataTypes dataTypes, IMinecraftComHandler handler)
{
this.protocolversion = protocolVersion;
protocolversion = protocolVersion;
this.dataTypes = dataTypes;
this.handler = handler;
}
@ -179,7 +177,7 @@ namespace MinecraftClient.Protocol.Handlers
// 1.18 and above always contains all chunk section in data
// 1.17 and 1.17.1 need vertical strip bitmask to know if the chunk section is included
if ((protocolversion >= Protocol18Handler.MC_1_18_1_Version) ||
if ((protocolversion >= Protocol18Handler.MC_1_18_1_Version) ||
((verticalStripBitmask![chunkY / 64] & (1UL << (chunkY % 64))) != 0))
{
// Non-air block count inside chunk section, for lighting purposes
@ -277,7 +275,7 @@ namespace MinecraftClient.Protocol.Handlers
// Block IDs are packed in the array of 64-bits integers
ulong[] dataArray = dataTypes.ReadNextULongArray(cache);
Chunk chunk = new Chunk();
Chunk chunk = new();
if (dataArray.Length > 0)
{
@ -399,10 +397,10 @@ namespace MinecraftClient.Protocol.Handlers
{
if ((chunkMask & (1 << chunkY)) != 0)
{
Chunk chunk = new Chunk();
Chunk chunk = new();
//Read chunk data, all at once for performance reasons, and build the chunk object
Queue<ushort> queue = new Queue<ushort>(dataTypes.ReadNextUShortsLittleEndian(Chunk.SizeX * Chunk.SizeY * Chunk.SizeZ, cache));
Queue<ushort> queue = new(dataTypes.ReadNextUShortsLittleEndian(Chunk.SizeX * Chunk.SizeY * Chunk.SizeZ, cache));
for (int blockY = 0; blockY < Chunk.SizeY; blockY++)
for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++)
for (int blockX = 0; blockX < Chunk.SizeX; blockX++)
@ -457,8 +455,8 @@ namespace MinecraftClient.Protocol.Handlers
}
//Read chunk data, unpacking 4-bit values into 8-bit values for block metadata
Queue<byte> blockTypes = new Queue<byte>(dataTypes.ReadData(Chunk.SizeX * Chunk.SizeY * Chunk.SizeZ * sectionCount, cache));
Queue<byte> blockMeta = new Queue<byte>();
Queue<byte> blockTypes = new(dataTypes.ReadData(Chunk.SizeX * Chunk.SizeY * Chunk.SizeZ * sectionCount, cache));
Queue<byte> blockMeta = new();
foreach (byte packed in dataTypes.ReadData((Chunk.SizeX * Chunk.SizeY * Chunk.SizeZ * sectionCount) / 2, cache))
{
byte hig = (byte)(packed >> 4);
@ -481,7 +479,7 @@ namespace MinecraftClient.Protocol.Handlers
{
if ((chunkMask & (1 << chunkY)) != 0)
{
Chunk chunk = new Chunk();
Chunk chunk = new();
for (int blockY = 0; blockY < Chunk.SizeY; blockY++)
for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++)