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

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace MinecraftClient.Inventory
{
@ -23,7 +20,7 @@ namespace MinecraftClient.Inventory
/// <summary>
/// title of container
/// </summary>
public string Title;
public string? Title;
/// <summary>
/// state of container
@ -35,11 +32,6 @@ namespace MinecraftClient.Inventory
/// </summary>
public Dictionary<int, Item> Items;
/// <summary>
/// Create an empty container
/// </summary>
public Container() { }
/// <summary>
/// Create an empty container with ID, Type and Title
/// </summary>
@ -61,7 +53,7 @@ namespace MinecraftClient.Inventory
/// <param name="type">Container Type</param>
/// <param name="title">Container Title</param>
/// <param name="items">Container Items (key: slot ID, value: item info)</param>
public Container(int id, ContainerType type, string title, Dictionary<int, Item> items)
public Container(int id, ContainerType type, string? title, Dictionary<int, Item> items)
{
ID = id;
Type = type;
@ -130,33 +122,33 @@ namespace MinecraftClient.Inventory
public static ContainerType GetContainerType(int typeID)
{
// https://wiki.vg/Inventory didn't state the inventory ID, assume that list start with 0
switch (typeID)
return typeID switch
{
case 0: return ContainerType.Generic_9x1;
case 1: return ContainerType.Generic_9x2;
case 2: return ContainerType.Generic_9x3;
case 3: return ContainerType.Generic_9x4;
case 4: return ContainerType.Generic_9x5;
case 5: return ContainerType.Generic_9x6;
case 6: return ContainerType.Generic_3x3;
case 7: return ContainerType.Anvil;
case 8: return ContainerType.Beacon;
case 9: return ContainerType.BlastFurnace;
case 10: return ContainerType.BrewingStand;
case 11: return ContainerType.Crafting;
case 12: return ContainerType.Enchantment;
case 13: return ContainerType.Furnace;
case 14: return ContainerType.Grindstone;
case 15: return ContainerType.Hopper;
case 16: return ContainerType.Lectern;
case 17: return ContainerType.Loom;
case 18: return ContainerType.Merchant;
case 19: return ContainerType.ShulkerBox;
case 20: return ContainerType.Smoker;
case 21: return ContainerType.Cartography;
case 22: return ContainerType.Stonecutter;
default: return ContainerType.Unknown;
}
0 => ContainerType.Generic_9x1,
1 => ContainerType.Generic_9x2,
2 => ContainerType.Generic_9x3,
3 => ContainerType.Generic_9x4,
4 => ContainerType.Generic_9x5,
5 => ContainerType.Generic_9x6,
6 => ContainerType.Generic_3x3,
7 => ContainerType.Anvil,
8 => ContainerType.Beacon,
9 => ContainerType.BlastFurnace,
10 => ContainerType.BrewingStand,
11 => ContainerType.Crafting,
12 => ContainerType.Enchantment,
13 => ContainerType.Furnace,
14 => ContainerType.Grindstone,
15 => ContainerType.Hopper,
16 => ContainerType.Lectern,
17 => ContainerType.Loom,
18 => ContainerType.Merchant,
19 => ContainerType.ShulkerBox,
20 => ContainerType.Smoker,
21 => ContainerType.Cartography,
22 => ContainerType.Stonecutter,
_ => ContainerType.Unknown,
};
}
/// <summary>
@ -166,7 +158,7 @@ namespace MinecraftClient.Inventory
/// <returns>An array of slot ID</returns>
public int[] SearchItem(ItemType itemType)
{
List<int> result = new List<int>();
List<int> result = new();
if (Items != null)
{
foreach (var item in Items)
@ -185,7 +177,7 @@ namespace MinecraftClient.Inventory
/// <remarks>Also depending on the container type, some empty slots cannot be used e.g. armor slots. This might cause issues.</remarks>
public int[] GetEmpytSlots()
{
List<int> result = new List<int>();
List<int> result = new();
for (int i = 0; i < Type.SlotCount(); i++)
{
result.Add(i);