mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix all warnings & Trim (#2226)
* Fix AutoFishing crash * Fix all warnings * Remove DotNetZip. * Fix the usage of HttpClient.
This commit is contained in:
parent
4aa6c1c99f
commit
1d52d1eadd
227 changed files with 2201 additions and 43564 deletions
|
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
|
|
@ -11,8 +8,8 @@ namespace MinecraftClient.Inventory
|
|||
/// </summary>
|
||||
public class ItemMovingHelper
|
||||
{
|
||||
private Container c;
|
||||
private McClient mc;
|
||||
private readonly Container c;
|
||||
private readonly McClient mc;
|
||||
|
||||
/// <summary>
|
||||
/// Create a helper that contains useful methods to move item around in container
|
||||
|
|
@ -35,7 +32,7 @@ namespace MinecraftClient.Inventory
|
|||
/// <param name="dest">Dest slot</param>
|
||||
/// <param name="destContainer">Dest slot's container (only if dest slot is in other container)</param>
|
||||
/// <returns>True if success or false if Failed</returns>
|
||||
public bool MoveTo(int source, int dest, Container destContainer = null)
|
||||
public bool MoveTo(int source, int dest, Container? destContainer = null)
|
||||
{
|
||||
// Condition: source has item and dest has no item
|
||||
if (ValidateSlots(source, dest, destContainer) &&
|
||||
|
|
@ -53,7 +50,7 @@ namespace MinecraftClient.Inventory
|
|||
/// <param name="slot2">Slot 2</param>
|
||||
/// <param name="destContainer">Slot2 container (only if slot2 is in other container)</param>
|
||||
/// <returns>True if success or False if Failed</returns>
|
||||
public bool Swap(int slot1, int slot2, Container destContainer = null)
|
||||
public bool Swap(int slot1, int slot2, Container? destContainer = null)
|
||||
{
|
||||
// Condition: Both slot1 and slot2 has item
|
||||
if (ValidateSlots(slot1, slot2, destContainer) &&
|
||||
|
|
@ -79,7 +76,7 @@ namespace MinecraftClient.Inventory
|
|||
{
|
||||
if (!HasItem(source))
|
||||
return false;
|
||||
List<int> availableSlots = new List<int>(slots.Count());
|
||||
List<int> availableSlots = new(slots.Count());
|
||||
// filter out different item type or non-empty slots (they will be ignored silently)
|
||||
foreach (var slot in slots)
|
||||
if (ItemTypeEqual(source, slot) || !HasItem(slot))
|
||||
|
|
@ -126,7 +123,7 @@ namespace MinecraftClient.Inventory
|
|||
/// <param name="s2">Slot 2</param>
|
||||
/// <param name="s2Container">Second container (only if slot2 is in other container)</param>
|
||||
/// <returns>The compare result</returns>
|
||||
private bool ValidateSlots(int s1, int s2, Container s2Container = null)
|
||||
private bool ValidateSlots(int s1, int s2, Container? s2Container = null)
|
||||
{
|
||||
if (s2Container == null)
|
||||
return (s1 != s2 && s1 < c.Type.SlotCount() && s2 < c.Type.SlotCount());
|
||||
|
|
@ -140,10 +137,9 @@ namespace MinecraftClient.Inventory
|
|||
/// <param name="slot">Slot ID</param>
|
||||
/// <param name="c">Specify another contianer (only if the slot is in other container)</param>
|
||||
/// <returns>True if has item</returns>
|
||||
private bool HasItem(int slot, Container c = null)
|
||||
private bool HasItem(int slot, Container? c = null)
|
||||
{
|
||||
if (c == null)
|
||||
c = this.c;
|
||||
c ??= this.c;
|
||||
return c.Items.ContainsKey(slot);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +150,7 @@ namespace MinecraftClient.Inventory
|
|||
/// <param name="slot2"></param>
|
||||
/// <param name="s2Container">Second container (only if slot2 is in other container)</param>
|
||||
/// <returns>True if they are equal</returns>
|
||||
private bool ItemTypeEqual(int slot1, int slot2, Container s2Container = null)
|
||||
private bool ItemTypeEqual(int slot1, int slot2, Container? s2Container = null)
|
||||
{
|
||||
if (s2Container == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue