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,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);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
// For MC 1.14 after ONLY
|
||||
public enum ContainerType
|
||||
|
|
@ -57,22 +52,24 @@ namespace MinecraftClient.Inventory
|
|||
{
|
||||
public static ContainerType ToNew(ContainerTypeOld type)
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case ContainerTypeOld.CONTAINER: return ContainerType.Unknown;
|
||||
case ContainerTypeOld.CHEST: return ContainerType.Generic_9x3;
|
||||
case ContainerTypeOld.CRAFTING_TABLE: return ContainerType.Crafting;
|
||||
case ContainerTypeOld.FURNACE: return ContainerType.Furnace;
|
||||
case ContainerTypeOld.DISPENSER: return ContainerType.Generic_3x3;
|
||||
case ContainerTypeOld.ENCHANTING_TABLE: return ContainerType.Enchantment;
|
||||
case ContainerTypeOld.BREWING_STAND: return ContainerType.BrewingStand;
|
||||
case ContainerTypeOld.VILLAGER: return ContainerType.Merchant;
|
||||
case ContainerTypeOld.HOPPER: return ContainerType.Hopper;
|
||||
case ContainerTypeOld.DROPPER: return ContainerType.Generic_3x3;
|
||||
case ContainerTypeOld.SHULKER_BOX: return ContainerType.ShulkerBox;
|
||||
case ContainerTypeOld.ENTITYHORSE: return ContainerType.Unknown;
|
||||
default: return ContainerType.Unknown;
|
||||
}
|
||||
#pragma warning disable format // @formatter:off
|
||||
ContainerTypeOld.CONTAINER => ContainerType.Unknown,
|
||||
ContainerTypeOld.CHEST => ContainerType.Generic_9x3,
|
||||
ContainerTypeOld.CRAFTING_TABLE => ContainerType.Crafting,
|
||||
ContainerTypeOld.FURNACE => ContainerType.Furnace,
|
||||
ContainerTypeOld.DISPENSER => ContainerType.Generic_3x3,
|
||||
ContainerTypeOld.ENCHANTING_TABLE => ContainerType.Enchantment,
|
||||
ContainerTypeOld.BREWING_STAND => ContainerType.BrewingStand,
|
||||
ContainerTypeOld.VILLAGER => ContainerType.Merchant,
|
||||
ContainerTypeOld.HOPPER => ContainerType.Hopper,
|
||||
ContainerTypeOld.DROPPER => ContainerType.Generic_3x3,
|
||||
ContainerTypeOld.SHULKER_BOX => ContainerType.ShulkerBox,
|
||||
ContainerTypeOld.ENTITYHORSE => ContainerType.Unknown,
|
||||
_ => ContainerType.Unknown,
|
||||
#pragma warning restore format // @formatter:on
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
public static class ContainerTypeExtensions
|
||||
{
|
||||
|
|
@ -14,31 +9,33 @@ namespace MinecraftClient.Inventory
|
|||
/// <returns>Slot count of the container</returns>
|
||||
public static int SlotCount(this ContainerType c)
|
||||
{
|
||||
switch (c)
|
||||
return c switch
|
||||
{
|
||||
case ContainerType.PlayerInventory: return 46;
|
||||
case ContainerType.Generic_9x3: return 63;
|
||||
case ContainerType.Generic_9x6: return 90;
|
||||
case ContainerType.Generic_3x3: return 45;
|
||||
case ContainerType.Crafting: return 46;
|
||||
case ContainerType.BlastFurnace: return 39;
|
||||
case ContainerType.Furnace: return 39;
|
||||
case ContainerType.Smoker: return 39;
|
||||
case ContainerType.Enchantment: return 38;
|
||||
case ContainerType.BrewingStand: return 41;
|
||||
case ContainerType.Merchant: return 39;
|
||||
case ContainerType.Beacon: return 37;
|
||||
case ContainerType.Anvil: return 39;
|
||||
case ContainerType.Hopper: return 41;
|
||||
case ContainerType.ShulkerBox: return 63;
|
||||
case ContainerType.Loom: return 40;
|
||||
case ContainerType.Stonecutter: return 38;
|
||||
case ContainerType.Lectern: return 37;
|
||||
case ContainerType.Cartography: return 39;
|
||||
case ContainerType.Grindstone: return 39;
|
||||
case ContainerType.Unknown: return 0;
|
||||
default: return 0;
|
||||
}
|
||||
#pragma warning disable format // @formatter:off
|
||||
ContainerType.PlayerInventory => 46,
|
||||
ContainerType.Generic_9x3 => 63,
|
||||
ContainerType.Generic_9x6 => 90,
|
||||
ContainerType.Generic_3x3 => 45,
|
||||
ContainerType.Crafting => 46,
|
||||
ContainerType.BlastFurnace => 39,
|
||||
ContainerType.Furnace => 39,
|
||||
ContainerType.Smoker => 39,
|
||||
ContainerType.Enchantment => 38,
|
||||
ContainerType.BrewingStand => 41,
|
||||
ContainerType.Merchant => 39,
|
||||
ContainerType.Beacon => 37,
|
||||
ContainerType.Anvil => 39,
|
||||
ContainerType.Hopper => 41,
|
||||
ContainerType.ShulkerBox => 63,
|
||||
ContainerType.Loom => 40,
|
||||
ContainerType.Stonecutter => 38,
|
||||
ContainerType.Lectern => 37,
|
||||
ContainerType.Cartography => 39,
|
||||
ContainerType.Grindstone => 39,
|
||||
ContainerType.Unknown => 0,
|
||||
_ => 0,
|
||||
#pragma warning restore format // @formatter:on
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -46,33 +43,40 @@ namespace MinecraftClient.Inventory
|
|||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns>ASCII art representation or NULL if not implemented for this container type</returns>
|
||||
public static string GetAsciiArt(this ContainerType c)
|
||||
public static string? GetAsciiArt(this ContainerType c)
|
||||
{
|
||||
switch (c)
|
||||
return c switch
|
||||
{
|
||||
case ContainerType.PlayerInventory: return DefaultConfigResource.ContainerType_PlayerInventory;
|
||||
case ContainerType.Generic_9x3: return DefaultConfigResource.ContainerType_Generic_9x3;
|
||||
case ContainerType.Generic_9x6: return DefaultConfigResource.ContainerType_Generic_9x6;
|
||||
case ContainerType.Generic_3x3: return DefaultConfigResource.ContainerType_Generic_3x3;
|
||||
case ContainerType.Crafting: return DefaultConfigResource.ContainerType_Crafting;
|
||||
case ContainerType.BlastFurnace: return DefaultConfigResource.ContainerType_Furnace;
|
||||
case ContainerType.Furnace: return DefaultConfigResource.ContainerType_Furnace;
|
||||
case ContainerType.Smoker: return DefaultConfigResource.ContainerType_Furnace;
|
||||
case ContainerType.Enchantment: return null;
|
||||
case ContainerType.BrewingStand: return DefaultConfigResource.ContainerType_BrewingStand;
|
||||
case ContainerType.Merchant: return null;
|
||||
case ContainerType.Beacon: return null;
|
||||
case ContainerType.Anvil: return null;
|
||||
case ContainerType.Hopper: return DefaultConfigResource.ContainerType_Hopper;
|
||||
case ContainerType.ShulkerBox: return DefaultConfigResource.ContainerType_Generic_9x3;
|
||||
case ContainerType.Loom: return null;
|
||||
case ContainerType.Stonecutter: return null;
|
||||
case ContainerType.Lectern: return null;
|
||||
case ContainerType.Cartography: return null;
|
||||
case ContainerType.Grindstone: return DefaultConfigResource.ContainerType_Grindstone;
|
||||
case ContainerType.Unknown: return null;
|
||||
default: return null;
|
||||
}
|
||||
#pragma warning disable format // @formatter:off
|
||||
ContainerType.PlayerInventory => DefaultConfigResource.ContainerType_PlayerInventory,
|
||||
ContainerType.Generic_9x3 => DefaultConfigResource.ContainerType_Generic_9x3,
|
||||
ContainerType.Generic_9x6 => DefaultConfigResource.ContainerType_Generic_9x6,
|
||||
ContainerType.Generic_3x3 => DefaultConfigResource.ContainerType_Generic_3x3,
|
||||
ContainerType.Crafting => DefaultConfigResource.ContainerType_Crafting,
|
||||
ContainerType.BlastFurnace => DefaultConfigResource.ContainerType_Furnace,
|
||||
ContainerType.Furnace => DefaultConfigResource.ContainerType_Furnace,
|
||||
ContainerType.Smoker => DefaultConfigResource.ContainerType_Furnace,
|
||||
ContainerType.Enchantment => null,
|
||||
ContainerType.BrewingStand => DefaultConfigResource.ContainerType_BrewingStand,
|
||||
ContainerType.Merchant => null,
|
||||
ContainerType.Beacon => null,
|
||||
ContainerType.Anvil => null,
|
||||
ContainerType.Hopper => DefaultConfigResource.ContainerType_Hopper,
|
||||
ContainerType.ShulkerBox => DefaultConfigResource.ContainerType_Generic_9x3,
|
||||
ContainerType.Loom => null,
|
||||
ContainerType.Stonecutter => null,
|
||||
ContainerType.Lectern => null,
|
||||
ContainerType.Cartography => null,
|
||||
ContainerType.Grindstone => DefaultConfigResource.ContainerType_Grindstone,
|
||||
ContainerType.Unknown => null,
|
||||
ContainerType.Generic_9x1 => null,
|
||||
ContainerType.Generic_9x2 => null,
|
||||
ContainerType.Generic_9x4 => null,
|
||||
ContainerType.Generic_9x5 => null,
|
||||
ContainerType.SmightingTable => null,
|
||||
_ => null,
|
||||
#pragma warning restore format // @formatter:on
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
|
|
@ -33,9 +33,9 @@ namespace MinecraftClient.Inventory
|
|||
/// <param name="nbt">Item Metadata</param>
|
||||
public Item(ItemType itemType, int count, Dictionary<string, object>? nbt)
|
||||
{
|
||||
this.Type = itemType;
|
||||
this.Count = count;
|
||||
this.NBT = nbt;
|
||||
Type = itemType;
|
||||
Count = count;
|
||||
NBT = nbt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -53,50 +53,46 @@ namespace MinecraftClient.Inventory
|
|||
/// <summary>
|
||||
/// Retrieve item display name from NBT properties. NULL if no display name is defined.
|
||||
/// </summary>
|
||||
public string DisplayName
|
||||
public string? DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (NBT != null && NBT.ContainsKey("display"))
|
||||
{
|
||||
var displayProperties = NBT["display"] as Dictionary<string, object>;
|
||||
if (displayProperties != null && displayProperties.ContainsKey("Name"))
|
||||
if (NBT["display"] is Dictionary<string, object> displayProperties && displayProperties.ContainsKey("Name"))
|
||||
{
|
||||
string displayName = displayProperties["Name"] as string;
|
||||
string? displayName = displayProperties["Name"] as string;
|
||||
if (!String.IsNullOrEmpty(displayName))
|
||||
return MinecraftClient.Protocol.ChatParser.ParseText(displayProperties["Name"].ToString());
|
||||
return MinecraftClient.Protocol.ChatParser.ParseText(displayProperties["Name"].ToString() ?? string.Empty);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve item lores from NBT properties. Returns null if no lores is defined.
|
||||
/// </summary>
|
||||
public string[] Lores
|
||||
public string[]? Lores
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> lores = new List<string>();
|
||||
List<string> lores = new();
|
||||
if (NBT != null && NBT.ContainsKey("display"))
|
||||
{
|
||||
var displayProperties = NBT["display"] as Dictionary<string, object>;
|
||||
if (displayProperties != null && displayProperties.ContainsKey("Lore"))
|
||||
if (NBT["display"] is Dictionary<string, object> displayProperties && displayProperties.ContainsKey("Lore"))
|
||||
{
|
||||
object[] displayName = displayProperties["Lore"] as object[];
|
||||
foreach (string st in displayName)
|
||||
{
|
||||
string str = MinecraftClient.Protocol.ChatParser.ParseText(st.ToString());
|
||||
lores.Add(str);
|
||||
}
|
||||
object[] displayName = (object[])displayProperties["Lore"];
|
||||
lores.AddRange(from string st in displayName
|
||||
let str = MinecraftClient.Protocol.ChatParser.ParseText(st.ToString())
|
||||
select str);
|
||||
return lores.ToArray();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve item damage from NBT properties. Returns 0 if no damage is defined.
|
||||
/// </summary>
|
||||
|
|
@ -109,7 +105,7 @@ namespace MinecraftClient.Inventory
|
|||
object damage = NBT["Damage"];
|
||||
if (damage != null)
|
||||
{
|
||||
return int.Parse(damage.ToString());
|
||||
return int.Parse(damage.ToString() ?? string.Empty);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -118,18 +114,18 @@ namespace MinecraftClient.Inventory
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.AppendFormat("x{0,-2} {1}", Count, Type.ToString());
|
||||
string displayName = DisplayName;
|
||||
|
||||
string? displayName = DisplayName;
|
||||
if (!String.IsNullOrEmpty(displayName))
|
||||
{
|
||||
sb.AppendFormat(" - {0}§8", displayName);
|
||||
}
|
||||
|
||||
int damage = Damage;
|
||||
if (damage != 0)
|
||||
{
|
||||
sb.AppendFormat(" | {0}: {1}", Translations.Get("cmd.inventory.damage"), damage);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
public abstract class ItemPalette
|
||||
{
|
||||
protected abstract Dictionary<int, ItemType> GetDict();
|
||||
private readonly Dictionary<ItemType, int> DictReverse = new Dictionary<ItemType, int>();
|
||||
private readonly Dictionary<ItemType, int> DictReverse = new();
|
||||
|
||||
public ItemPalette()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
|
|
@ -9,7 +8,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
|
|||
/// </summary>
|
||||
public class ItemPalette115 : ItemPalette
|
||||
{
|
||||
private static Dictionary<int, ItemType> mappings = new Dictionary<int, ItemType>();
|
||||
private static readonly Dictionary<int, ItemType> mappings = new();
|
||||
|
||||
static ItemPalette115()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
|
|
@ -9,7 +8,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
|
|||
/// </summary>
|
||||
public class ItemPalette1161 : ItemPalette
|
||||
{
|
||||
private static Dictionary<int, ItemType> mappings = new Dictionary<int, ItemType>();
|
||||
private static readonly Dictionary<int, ItemType> mappings = new();
|
||||
|
||||
static ItemPalette1161()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
|
|
@ -9,7 +8,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
|
|||
/// </summary>
|
||||
public class ItemPalette1162 : ItemPalette
|
||||
{
|
||||
private static Dictionary<int, ItemType> mappings = new Dictionary<int, ItemType>();
|
||||
private static readonly Dictionary<int, ItemType> mappings = new();
|
||||
|
||||
static ItemPalette1162()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
public class ItemPalette117 : ItemPalette
|
||||
{
|
||||
private static Dictionary<int, ItemType> mappings = new Dictionary<int, ItemType>();
|
||||
private static readonly Dictionary<int, ItemType> mappings = new();
|
||||
|
||||
static ItemPalette117()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
public class ItemPalette118 : ItemPalette
|
||||
{
|
||||
private static Dictionary<int, ItemType> mappings = new Dictionary<int, ItemType>();
|
||||
private static readonly Dictionary<int, ItemType> mappings = new();
|
||||
|
||||
static ItemPalette118()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
public class ItemPalette119 : ItemPalette
|
||||
{
|
||||
private static Dictionary<int, ItemType> mappings = new Dictionary<int, ItemType>();
|
||||
private static readonly Dictionary<int, ItemType> mappings = new();
|
||||
|
||||
static ItemPalette119()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
using MinecraftClient.Protocol;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
|
|
@ -18,8 +14,8 @@ namespace MinecraftClient.Inventory.ItemPalettes
|
|||
{
|
||||
DataTypeGenerator.GenerateEnumWithPalette(
|
||||
registriesJsonFile,
|
||||
"minecraft:item",
|
||||
"ItemType",
|
||||
"minecraft:item",
|
||||
"ItemType",
|
||||
"MinecraftClient.Inventory",
|
||||
"ItemPalette",
|
||||
"MinecraftClient.Inventory.ItemPalettes");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
{
|
||||
public Item InputItem1;
|
||||
public Item OutputItem;
|
||||
public Item InputItem2;
|
||||
public Item? InputItem2;
|
||||
public bool TradeDisabled;
|
||||
public int NumberOfTradeUses;
|
||||
public int MaximumNumberOfTradeUses;
|
||||
|
|
@ -16,18 +16,18 @@
|
|||
public float PriceMultiplier;
|
||||
public int Demand;
|
||||
|
||||
public VillagerTrade(Item inputItem1, Item outputItem, Item inputItem2, bool tradeDisabled, int numberOfTradeUses, int maximumNumberOfTradeUses, int xp, int specialPrice, float priceMultiplier, int demand)
|
||||
public VillagerTrade(Item inputItem1, Item outputItem, Item? inputItem2, bool tradeDisabled, int numberOfTradeUses, int maximumNumberOfTradeUses, int xp, int specialPrice, float priceMultiplier, int demand)
|
||||
{
|
||||
this.InputItem1 = inputItem1;
|
||||
this.OutputItem = outputItem;
|
||||
this.InputItem2 = inputItem2;
|
||||
this.TradeDisabled = tradeDisabled;
|
||||
this.NumberOfTradeUses = numberOfTradeUses;
|
||||
this.MaximumNumberOfTradeUses = maximumNumberOfTradeUses;
|
||||
this.Xp = xp;
|
||||
this.SpecialPrice = specialPrice;
|
||||
this.PriceMultiplier = priceMultiplier;
|
||||
this.Demand = demand;
|
||||
InputItem1 = inputItem1;
|
||||
OutputItem = outputItem;
|
||||
InputItem2 = inputItem2;
|
||||
TradeDisabled = tradeDisabled;
|
||||
NumberOfTradeUses = numberOfTradeUses;
|
||||
MaximumNumberOfTradeUses = maximumNumberOfTradeUses;
|
||||
Xp = xp;
|
||||
SpecialPrice = specialPrice;
|
||||
PriceMultiplier = priceMultiplier;
|
||||
Demand = demand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents mouse interactions with an inventory window
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue