Modernize data carriers to records and add primary constructors

Convert 14 data carrier classes to records:
- VillagerInfo, MapIcon, EnchantmentData: non-positional records (mutable properties)
- ForgeMod, SkinInfo, VillagerTrade, Node, Response: positional records
- CommandNode: sealed positional record
- CommandArgumentDescriptor: readonly record struct
- ColorRGBA: record struct (multiple constructors preserved)
- RecipeConfig, Recipe, BannerLayer: non-positional records

Add primary constructors to 6 classes:
- DataTypes, Protocol18Terrain, Protocol18Forge, ItemMovingHelper,
  LastSeenMessageList, Acknowledgment, SuggestionTooltip

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 01:31:17 +00:00
parent 81b756292e
commit 654a16907b
18 changed files with 68 additions and 231 deletions

View file

@ -1,6 +1,6 @@
namespace MinecraftClient.Inventory
{
public class EnchantmentData
public record EnchantmentData
{
public Enchantments TopEnchantment { get; set; }
public Enchantments MiddleEnchantment { get; set; }

View file

@ -7,24 +7,10 @@ namespace MinecraftClient.Inventory
/// <summary>
/// Class that contains useful methods to move item around in a container
/// </summary>
public class ItemMovingHelper
public class ItemMovingHelper(Container c, McClient mc)
{
private readonly Container c;
private readonly McClient mc;
/// <summary>
/// Create a helper that contains useful methods to move item around in container
/// </summary>
/// <param name="c">Source container to use. All method will use this container for handling first slot parameter</param>
/// <param name="mc">McClient handler. Needed for sending WindowAction packet to the server</param>
/// <remarks>
/// If you are using ChatBot API and cannot have direct access to McClient handler, use <see cref="ChatBot.WindowAction(int, int, WindowActionType)"/> as second parameter
/// </remarks>
public ItemMovingHelper(Container c, McClient mc)
{
this.c = c;
this.mc = mc;
}
private readonly Container c = c;
private readonly McClient mc = mc;
/// <summary>
/// Move an item fron source to dest. Source should contain an item and dest slot should be empty

View file

@ -3,7 +3,7 @@
/// <summary>
/// Properties of a villager
/// </summary>
public class VillagerInfo
public record VillagerInfo
{
public int Level { get; set; }
public int Experience { get; set; }

View file

@ -3,31 +3,15 @@
/// <summary>
/// Represents a trade of a villager
/// </summary>
public class VillagerTrade
{
public Item InputItem1;
public Item OutputItem;
public Item? InputItem2;
public bool TradeDisabled;
public int NumberOfTradeUses;
public int MaximumNumberOfTradeUses;
public int Xp;
public int SpecialPrice;
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)
{
InputItem1 = inputItem1;
OutputItem = outputItem;
InputItem2 = inputItem2;
TradeDisabled = tradeDisabled;
NumberOfTradeUses = numberOfTradeUses;
MaximumNumberOfTradeUses = maximumNumberOfTradeUses;
Xp = xp;
SpecialPrice = specialPrice;
PriceMultiplier = priceMultiplier;
Demand = demand;
}
}
public record VillagerTrade(
Item InputItem1,
Item OutputItem,
Item? InputItem2,
bool TradeDisabled,
int NumberOfTradeUses,
int MaximumNumberOfTradeUses,
int Xp,
int SpecialPrice,
float PriceMultiplier,
int Demand);
}