mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implemented Enchanting
Implemented Enchanting
This commit is contained in:
commit
12e2c6b4bb
16 changed files with 776 additions and 65 deletions
67
MinecraftClient/Commands/Enchant.cs
Normal file
67
MinecraftClient/Commands/Enchant.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using MinecraftClient.Inventory;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Commands
|
||||||
|
{
|
||||||
|
public class Enchant : Command
|
||||||
|
{
|
||||||
|
public override string CmdName { get { return "enchant"; } }
|
||||||
|
public override string CmdUsage { get { return "enchant <top|middle|bottom>"; } }
|
||||||
|
public override string CmdDesc { get { return "cmd.enchant.desc"; } }
|
||||||
|
|
||||||
|
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||||
|
{
|
||||||
|
if (HasArg(command))
|
||||||
|
{
|
||||||
|
string slot = GetArg(command).ToLower().Trim();
|
||||||
|
|
||||||
|
int slotId = slot switch
|
||||||
|
{
|
||||||
|
"top" => 0,
|
||||||
|
"middle" => 1,
|
||||||
|
"bottom" => 2,
|
||||||
|
_ => -1
|
||||||
|
};
|
||||||
|
|
||||||
|
if (slotId == -1)
|
||||||
|
return Translations.TryGet("cmd.enchant.invalid_slot");
|
||||||
|
|
||||||
|
Container? enchantingTable = null;
|
||||||
|
|
||||||
|
foreach (var (id, container) in handler.GetInventories())
|
||||||
|
{
|
||||||
|
if (container.Type == ContainerType.Enchantment)
|
||||||
|
{
|
||||||
|
enchantingTable = container;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enchantingTable == null)
|
||||||
|
return Translations.TryGet("cmd.enchant.enchanting_table_not_opened");
|
||||||
|
|
||||||
|
int[] emptySlots = enchantingTable.GetEmpytSlots();
|
||||||
|
|
||||||
|
if (emptySlots.Contains(0))
|
||||||
|
return Translations.TryGet("cmd.enchant.enchanting_no_item");
|
||||||
|
|
||||||
|
if (emptySlots.Contains(1))
|
||||||
|
return Translations.TryGet("cmd.enchant.enchanting_no_lapis");
|
||||||
|
|
||||||
|
Item lapisSlot = enchantingTable.Items[1];
|
||||||
|
|
||||||
|
if (lapisSlot.Type != ItemType.LapisLazuli)
|
||||||
|
return Translations.TryGet("cmd.enchant.enchanting_no_lapis");
|
||||||
|
|
||||||
|
if (lapisSlot.Count < 3)
|
||||||
|
return Translations.TryGet("cmd.enchant.enchanting_no_lapis");
|
||||||
|
|
||||||
|
return handler.ClickContainerButton(enchantingTable.ID, slotId) ? Translations.TryGet("cmd.enchant.clicked") : Translations.TryGet("cmd.enchant.not_clicked");
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetCmdDescTranslated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
130
MinecraftClient/DefaultConfigResource.Designer.cs
generated
130
MinecraftClient/DefaultConfigResource.Designer.cs
generated
|
|
@ -8,7 +8,8 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace MinecraftClient {
|
namespace MinecraftClient
|
||||||
|
{
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22,23 +23,28 @@ namespace MinecraftClient {
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class DefaultConfigResource {
|
internal class DefaultConfigResource
|
||||||
|
{
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal DefaultConfigResource() {
|
internal DefaultConfigResource()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager
|
||||||
get {
|
{
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
get
|
||||||
|
{
|
||||||
|
if (object.ReferenceEquals(resourceMan, null))
|
||||||
|
{
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MinecraftClient.DefaultConfigResource", typeof(DefaultConfigResource).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MinecraftClient.DefaultConfigResource", typeof(DefaultConfigResource).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
|
|
@ -51,11 +57,14 @@ namespace MinecraftClient {
|
||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
internal static global::System.Globalization.CultureInfo Culture
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
set {
|
set
|
||||||
|
{
|
||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,8 +84,10 @@ namespace MinecraftClient {
|
||||||
///║║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║12 ║13 ║║
|
///║║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║12 ║13 ║║
|
||||||
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_BrewingStand {
|
internal static string ContainerType_BrewingStand
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_BrewingStand", resourceCulture);
|
return ResourceManager.GetString("ContainerType_BrewingStand", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -96,11 +107,20 @@ namespace MinecraftClient {
|
||||||
///║║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║18 ║║
|
///║║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║18 ║║
|
||||||
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_Crafting {
|
internal static string ContainerType_Crafting
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_Crafting", resourceCulture);
|
return ResourceManager.GetString("ContainerType_Crafting", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal static string ContainerType_EnchantingTable
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ResourceManager.GetString("ContainerType_EnchantingTable", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to ╔═════════════════════════════════════╗
|
/// Looks up a localized string similar to ╔═════════════════════════════════════╗
|
||||||
|
|
@ -117,8 +137,10 @@ namespace MinecraftClient {
|
||||||
///║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║
|
///║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║
|
||||||
///║║ 3 ║ 4 ║ 5 ║ 6 ║ 7 [rest of string was truncated]";.
|
///║║ 3 ║ 4 ║ 5 ║ 6 ║ 7 [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_Furnace {
|
internal static string ContainerType_Furnace
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_Furnace", resourceCulture);
|
return ResourceManager.GetString("ContainerType_Furnace", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -138,8 +160,10 @@ namespace MinecraftClient {
|
||||||
///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║
|
///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║
|
||||||
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_Generic_3x3 {
|
internal static string ContainerType_Generic_3x3
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_Generic_3x3", resourceCulture);
|
return ResourceManager.GetString("ContainerType_Generic_3x3", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,8 +183,10 @@ namespace MinecraftClient {
|
||||||
///║║27 ║28 ║29 ║30 ║31 ║32 ║33 ║34 ║35 ║║
|
///║║27 ║28 ║29 ║30 ║31 ║32 ║33 ║34 ║35 ║║
|
||||||
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_Generic_9x3 {
|
internal static string ContainerType_Generic_9x3
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_Generic_9x3", resourceCulture);
|
return ResourceManager.GetString("ContainerType_Generic_9x3", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,8 +206,10 @@ namespace MinecraftClient {
|
||||||
///║║36 ║37 ║38 ║39 ║40 ║41 ║42 ║43 ║44 ║║
|
///║║36 ║37 ║38 ║39 ║40 ║41 ║42 ║43 ║44 ║║
|
||||||
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_Generic_9x6 {
|
internal static string ContainerType_Generic_9x6
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_Generic_9x6", resourceCulture);
|
return ResourceManager.GetString("ContainerType_Generic_9x6", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -201,8 +229,10 @@ namespace MinecraftClient {
|
||||||
///║ ╚══╝ ╚══╝ ║
|
///║ ╚══╝ ╚══╝ ║
|
||||||
///║ [rest of string was truncated]";.
|
///║ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_Grindstone {
|
internal static string ContainerType_Grindstone
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_Grindstone", resourceCulture);
|
return ResourceManager.GetString("ContainerType_Grindstone", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -222,8 +252,10 @@ namespace MinecraftClient {
|
||||||
///║║23 ║24 ║25 ║26 ║27 ║28 ║29 ║30 ║31 ║║
|
///║║23 ║24 ║25 ║26 ║27 ║28 ║29 ║30 ║31 ║║
|
||||||
///║╚═══╩═══╩═══╩═══╩══ [rest of string was truncated]";.
|
///║╚═══╩═══╩═══╩═══╩══ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_Hopper {
|
internal static string ContainerType_Hopper
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_Hopper", resourceCulture);
|
return ResourceManager.GetString("ContainerType_Hopper", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,8 +275,10 @@ namespace MinecraftClient {
|
||||||
///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║
|
///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║
|
||||||
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
///║╠═══╬═══╬═══╬═══╬══ [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ContainerType_PlayerInventory {
|
internal static string ContainerType_PlayerInventory
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("ContainerType_PlayerInventory", resourceCulture);
|
return ResourceManager.GetString("ContainerType_PlayerInventory", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,8 +299,10 @@ namespace MinecraftClient {
|
||||||
///mcc.session_invalid=§8Gespeicherte Session ungültig oder abgelaufen.
|
///mcc.session_invalid=§8Gespeicherte Session ungültig oder abgelaufen.
|
||||||
///mcc.session_valid=§8Gespeicherte Ses [rest of string was truncated]";.
|
///mcc.session_valid=§8Gespeicherte Ses [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Translation_de {
|
internal static string Translation_de
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("Translation_de", resourceCulture);
|
return ResourceManager.GetString("Translation_de", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -285,8 +321,10 @@ namespace MinecraftClient {
|
||||||
///mcc.password_hidden=Password(invisible): {0}
|
///mcc.password_hidden=Password(invisible): {0}
|
||||||
///mcc.off [rest of string was truncated]";.
|
///mcc.off [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Translation_en {
|
internal static string Translation_en
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("Translation_en", resourceCulture);
|
return ResourceManager.GetString("Translation_en", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -307,8 +345,10 @@ namespace MinecraftClient {
|
||||||
///mcc.session_invalid=§8Le cache de la session est invalide ou a expiré.
|
///mcc.session_invalid=§8Le cache de la session est invalide ou a expiré.
|
||||||
///mcc.session_va [rest of string was truncated]";.
|
///mcc.session_va [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Translation_fr {
|
internal static string Translation_fr
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("Translation_fr", resourceCulture);
|
return ResourceManager.GetString("Translation_fr", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -329,8 +369,10 @@ namespace MinecraftClient {
|
||||||
///mcc.session_invalid=§8Кэшированная сессия недействительна или истекла.
|
///mcc.session_invalid=§8Кэшированная сессия недействительна или истекла.
|
||||||
///mcc.session_valid=§8Кэшированная се [rest of string was truncated]";.
|
///mcc.session_valid=§8Кэшированная се [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Translation_ru {
|
internal static string Translation_ru
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("Translation_ru", resourceCulture);
|
return ResourceManager.GetString("Translation_ru", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -352,8 +394,10 @@ namespace MinecraftClient {
|
||||||
///mcc.session_valid=§8Phiên vẫn còn hợp lệ cho {0}.
|
///mcc.session_valid=§8Phiên vẫn còn hợp lệ cho {0}.
|
||||||
///mcc.profile_ke [rest of string was truncated]";.
|
///mcc.profile_ke [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Translation_vi {
|
internal static string Translation_vi
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("Translation_vi", resourceCulture);
|
return ResourceManager.GetString("Translation_vi", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -376,8 +420,10 @@ namespace MinecraftClient {
|
||||||
///mcc.profile_key_invalid=§8缓存的聊天签名密钥需要刷新。
|
///mcc.profile_key_invalid=§8缓存的聊天签名密钥需要刷新。
|
||||||
///mcc.profile_key_valid=§8{0 [rest of string was truncated]";.
|
///mcc.profile_key_valid=§8{0 [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Translation_zh_Hans {
|
internal static string Translation_zh_Hans
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("Translation_zh_Hans", resourceCulture);
|
return ResourceManager.GetString("Translation_zh_Hans", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -400,8 +446,10 @@ namespace MinecraftClient {
|
||||||
///mcc.profile_key_invalid=§8快取的聊天簽名金鑰需要重新整理。
|
///mcc.profile_key_invalid=§8快取的聊天簽名金鑰需要重新整理。
|
||||||
///mcc.profile_key_valid [rest of string was truncated]";.
|
///mcc.profile_key_valid [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Translation_zh_Hant {
|
internal static string Translation_zh_Hant
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return ResourceManager.GetString("Translation_zh_Hant", resourceCulture);
|
return ResourceManager.GetString("Translation_zh_Hant", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,9 @@
|
||||||
<data name="ContainerType_Crafting" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="ContainerType_Crafting" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>Resources\containers\ContainerType.Crafting.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
<value>Resources\containers\ContainerType.Crafting.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ContainerType_EnchantingTable" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>Resources\containers\ContainerType.EnchantingTable.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||||
|
</data>
|
||||||
<data name="ContainerType_Furnace" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="ContainerType_Furnace" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>Resources\containers\ContainerType.Furnace.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
<value>Resources\containers\ContainerType.Furnace.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,13 @@ namespace MinecraftClient.Inventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<int, Item> Items;
|
public Dictionary<int, Item> Items;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Container Properties
|
||||||
|
/// Used for Frunaces, Enchanting Table, Beacon, Brewing stand, Stone cutter, Loom and Lectern
|
||||||
|
/// More info about: https://wiki.vg/Protocol#Set_Container_Property
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<int, short> Properties;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create an empty container with ID, Type and Title
|
/// Create an empty container with ID, Type and Title
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -44,6 +51,7 @@ namespace MinecraftClient.Inventory
|
||||||
Type = type;
|
Type = type;
|
||||||
Title = title;
|
Title = title;
|
||||||
Items = new Dictionary<int, Item>();
|
Items = new Dictionary<int, Item>();
|
||||||
|
Properties = new Dictionary<int, short>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -59,6 +67,7 @@ namespace MinecraftClient.Inventory
|
||||||
Type = type;
|
Type = type;
|
||||||
Title = title;
|
Title = title;
|
||||||
Items = items;
|
Items = items;
|
||||||
|
Properties = new Dictionary<int, short>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -73,6 +82,7 @@ namespace MinecraftClient.Inventory
|
||||||
Title = title;
|
Title = title;
|
||||||
Type = ConvertType.ToNew(type);
|
Type = ConvertType.ToNew(type);
|
||||||
Items = new Dictionary<int, Item>();
|
Items = new Dictionary<int, Item>();
|
||||||
|
Properties = new Dictionary<int, short>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -87,6 +97,7 @@ namespace MinecraftClient.Inventory
|
||||||
Type = GetContainerType(typeID);
|
Type = GetContainerType(typeID);
|
||||||
Title = title;
|
Title = title;
|
||||||
Items = new Dictionary<int, Item>();
|
Items = new Dictionary<int, Item>();
|
||||||
|
Properties = new Dictionary<int, short>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -99,6 +110,7 @@ namespace MinecraftClient.Inventory
|
||||||
Type = type;
|
Type = type;
|
||||||
Title = null;
|
Title = null;
|
||||||
Items = new Dictionary<int, Item>();
|
Items = new Dictionary<int, Item>();
|
||||||
|
Properties = new Dictionary<int, short>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -112,6 +124,7 @@ namespace MinecraftClient.Inventory
|
||||||
Type = type;
|
Type = type;
|
||||||
Title = null;
|
Title = null;
|
||||||
Items = items;
|
Items = items;
|
||||||
|
Properties = new Dictionary<int, short>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
ContainerType.BlastFurnace => DefaultConfigResource.ContainerType_Furnace,
|
ContainerType.BlastFurnace => DefaultConfigResource.ContainerType_Furnace,
|
||||||
ContainerType.Furnace => DefaultConfigResource.ContainerType_Furnace,
|
ContainerType.Furnace => DefaultConfigResource.ContainerType_Furnace,
|
||||||
ContainerType.Smoker => DefaultConfigResource.ContainerType_Furnace,
|
ContainerType.Smoker => DefaultConfigResource.ContainerType_Furnace,
|
||||||
ContainerType.Enchantment => null,
|
ContainerType.Enchantment => DefaultConfigResource.ContainerType_EnchantingTable,
|
||||||
ContainerType.BrewingStand => DefaultConfigResource.ContainerType_BrewingStand,
|
ContainerType.BrewingStand => DefaultConfigResource.ContainerType_BrewingStand,
|
||||||
ContainerType.Merchant => null,
|
ContainerType.Merchant => null,
|
||||||
ContainerType.Beacon => null,
|
ContainerType.Beacon => null,
|
||||||
|
|
|
||||||
241
MinecraftClient/Inventory/EnchantmentMapping.cs
Normal file
241
MinecraftClient/Inventory/EnchantmentMapping.cs
Normal file
|
|
@ -0,0 +1,241 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using MinecraftClient.Commands;
|
||||||
|
using MinecraftClient.Protocol.Handlers;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Inventory
|
||||||
|
{
|
||||||
|
public class EnchantmentMapping
|
||||||
|
{
|
||||||
|
#pragma warning disable format // @formatter:off
|
||||||
|
// 1.14 - 1.15.2
|
||||||
|
private static Dictionary<short, Enchantment> enchantmentMappings114 = new Dictionary<short, Enchantment>()
|
||||||
|
{
|
||||||
|
//id type
|
||||||
|
{ 0, Enchantment.Protection },
|
||||||
|
{ 1, Enchantment.FireProtection },
|
||||||
|
{ 2, Enchantment.FeatherFalling },
|
||||||
|
{ 3, Enchantment.BlastProtection },
|
||||||
|
{ 4, Enchantment.ProjectileProtection },
|
||||||
|
{ 5, Enchantment.Respiration },
|
||||||
|
{ 6, Enchantment.AquaAffinity },
|
||||||
|
{ 7, Enchantment.Thorns },
|
||||||
|
{ 8, Enchantment.DepthStrieder },
|
||||||
|
{ 9, Enchantment.FrostWalker },
|
||||||
|
{ 10, Enchantment.BindingCurse },
|
||||||
|
{ 11, Enchantment.Sharpness },
|
||||||
|
{ 12, Enchantment.Smite },
|
||||||
|
{ 13, Enchantment.BaneOfArthropods },
|
||||||
|
{ 14, Enchantment.Knockback },
|
||||||
|
{ 15, Enchantment.FireAspect },
|
||||||
|
{ 16, Enchantment.Looting },
|
||||||
|
{ 17, Enchantment.Sweeping },
|
||||||
|
{ 18, Enchantment.Efficency },
|
||||||
|
{ 19, Enchantment.SilkTouch },
|
||||||
|
{ 20, Enchantment.Unbreaking },
|
||||||
|
{ 21, Enchantment.Fortune },
|
||||||
|
{ 22, Enchantment.Power },
|
||||||
|
{ 23, Enchantment.Punch },
|
||||||
|
{ 24, Enchantment.Flame },
|
||||||
|
{ 25, Enchantment.Infinity },
|
||||||
|
{ 26, Enchantment.LuckOfTheSea },
|
||||||
|
{ 27, Enchantment.Lure },
|
||||||
|
{ 28, Enchantment.Loyality },
|
||||||
|
{ 29, Enchantment.Impaling },
|
||||||
|
{ 30, Enchantment.Riptide },
|
||||||
|
{ 31, Enchantment.Channeling },
|
||||||
|
{ 32, Enchantment.Mending },
|
||||||
|
{ 33, Enchantment.VanishingCurse }
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1.16 - 1.18
|
||||||
|
private static Dictionary<short, Enchantment> enchantmentMappings116 = new Dictionary<short, Enchantment>()
|
||||||
|
{
|
||||||
|
//id type
|
||||||
|
{ 0, Enchantment.Protection },
|
||||||
|
{ 1, Enchantment.FireProtection },
|
||||||
|
{ 2, Enchantment.FeatherFalling },
|
||||||
|
{ 3, Enchantment.BlastProtection },
|
||||||
|
{ 4, Enchantment.ProjectileProtection },
|
||||||
|
{ 5, Enchantment.Respiration },
|
||||||
|
{ 6, Enchantment.AquaAffinity },
|
||||||
|
{ 7, Enchantment.Thorns },
|
||||||
|
{ 8, Enchantment.DepthStrieder },
|
||||||
|
{ 9, Enchantment.FrostWalker },
|
||||||
|
{ 10, Enchantment.BindingCurse },
|
||||||
|
{ 11, Enchantment.SoulSpeed },
|
||||||
|
{ 12, Enchantment.Sharpness },
|
||||||
|
{ 13, Enchantment.Smite },
|
||||||
|
{ 14, Enchantment.BaneOfArthropods },
|
||||||
|
{ 15, Enchantment.Knockback },
|
||||||
|
{ 16, Enchantment.FireAspect },
|
||||||
|
{ 17, Enchantment.Looting },
|
||||||
|
{ 18, Enchantment.Sweeping },
|
||||||
|
{ 19, Enchantment.Efficency },
|
||||||
|
{ 20, Enchantment.SilkTouch },
|
||||||
|
{ 21, Enchantment.Unbreaking },
|
||||||
|
{ 22, Enchantment.Fortune },
|
||||||
|
{ 23, Enchantment.Power },
|
||||||
|
{ 24, Enchantment.Punch },
|
||||||
|
{ 25, Enchantment.Flame },
|
||||||
|
{ 26, Enchantment.Infinity },
|
||||||
|
{ 27, Enchantment.LuckOfTheSea },
|
||||||
|
{ 28, Enchantment.Lure },
|
||||||
|
{ 29, Enchantment.Loyality },
|
||||||
|
{ 30, Enchantment.Impaling },
|
||||||
|
{ 31, Enchantment.Riptide },
|
||||||
|
{ 32, Enchantment.Channeling },
|
||||||
|
{ 33, Enchantment.Multishot },
|
||||||
|
{ 34, Enchantment.QuickCharge },
|
||||||
|
{ 35, Enchantment.Piercing },
|
||||||
|
{ 36, Enchantment.Mending },
|
||||||
|
{ 37, Enchantment.VanishingCurse }
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1.19+
|
||||||
|
private static Dictionary<short, Enchantment> enchantmentMappings = new Dictionary<short, Enchantment>()
|
||||||
|
{
|
||||||
|
//id type
|
||||||
|
{ 0, Enchantment.Protection },
|
||||||
|
{ 1, Enchantment.FireProtection },
|
||||||
|
{ 2, Enchantment.FeatherFalling },
|
||||||
|
{ 3, Enchantment.BlastProtection },
|
||||||
|
{ 4, Enchantment.ProjectileProtection },
|
||||||
|
{ 5, Enchantment.Respiration },
|
||||||
|
{ 6, Enchantment.AquaAffinity },
|
||||||
|
{ 7, Enchantment.Thorns },
|
||||||
|
{ 8, Enchantment.DepthStrieder },
|
||||||
|
{ 9, Enchantment.FrostWalker },
|
||||||
|
{ 10, Enchantment.BindingCurse },
|
||||||
|
{ 11, Enchantment.SoulSpeed },
|
||||||
|
{ 12, Enchantment.SwiftSneak },
|
||||||
|
{ 13, Enchantment.Sharpness },
|
||||||
|
{ 14, Enchantment.Smite },
|
||||||
|
{ 15, Enchantment.BaneOfArthropods },
|
||||||
|
{ 16, Enchantment.Knockback },
|
||||||
|
{ 17, Enchantment.FireAspect },
|
||||||
|
{ 18, Enchantment.Looting },
|
||||||
|
{ 19, Enchantment.Sweeping },
|
||||||
|
{ 20, Enchantment.Efficency },
|
||||||
|
{ 21, Enchantment.SilkTouch },
|
||||||
|
{ 22, Enchantment.Unbreaking },
|
||||||
|
{ 23, Enchantment.Fortune },
|
||||||
|
{ 24, Enchantment.Power },
|
||||||
|
{ 25, Enchantment.Punch },
|
||||||
|
{ 26, Enchantment.Flame },
|
||||||
|
{ 27, Enchantment.Infinity },
|
||||||
|
{ 28, Enchantment.LuckOfTheSea },
|
||||||
|
{ 29, Enchantment.Lure },
|
||||||
|
{ 30, Enchantment.Loyality },
|
||||||
|
{ 31, Enchantment.Impaling },
|
||||||
|
{ 32, Enchantment.Riptide },
|
||||||
|
{ 33, Enchantment.Channeling },
|
||||||
|
{ 34, Enchantment.Multishot },
|
||||||
|
{ 35, Enchantment.QuickCharge },
|
||||||
|
{ 36, Enchantment.Piercing },
|
||||||
|
{ 37, Enchantment.Mending },
|
||||||
|
{ 38, Enchantment.VanishingCurse }
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Dictionary<Enchantment, string> enchantmentNames = new Dictionary<Enchantment, string>()
|
||||||
|
{
|
||||||
|
//type
|
||||||
|
{ Enchantment.Protection, "Enchantment.Protection" },
|
||||||
|
{ Enchantment.FireProtection, "Enchantment.FireProtection" },
|
||||||
|
{ Enchantment.FeatherFalling, "Enchantment.FeatherFalling" },
|
||||||
|
{ Enchantment.BlastProtection, "Enchantment.BlastProtection" },
|
||||||
|
{ Enchantment.ProjectileProtection, "Enchantment.ProjectileProtection" },
|
||||||
|
{ Enchantment.Respiration, "Enchantment.Respiration" },
|
||||||
|
{ Enchantment.AquaAffinity, "Enchantment.AquaAffinity" },
|
||||||
|
{ Enchantment.Thorns, "Enchantment.Thorns" },
|
||||||
|
{ Enchantment.DepthStrieder, "Enchantment.DepthStrieder" },
|
||||||
|
{ Enchantment.FrostWalker, "Enchantment.FrostWalker" },
|
||||||
|
{ Enchantment.BindingCurse, "Enchantment.BindingCurse" },
|
||||||
|
{ Enchantment.SoulSpeed, "Enchantment.SoulSpeed" },
|
||||||
|
{ Enchantment.SwiftSneak, "Enchantment.SwiftSneak" },
|
||||||
|
{ Enchantment.Sharpness, "Enchantment.Sharpness" },
|
||||||
|
{ Enchantment.Smite, "Enchantment.Smite" },
|
||||||
|
{ Enchantment.BaneOfArthropods, "Enchantment.BaneOfArthropods" },
|
||||||
|
{ Enchantment.Knockback, "Enchantment.Knockback" },
|
||||||
|
{ Enchantment.FireAspect, "Enchantment.FireAspect" },
|
||||||
|
{ Enchantment.Looting, "Enchantment.Looting" },
|
||||||
|
{ Enchantment.Sweeping, "Enchantment.Sweeping" },
|
||||||
|
{ Enchantment.Efficency, "Enchantment.Efficency" },
|
||||||
|
{ Enchantment.SilkTouch, "Enchantment.SilkTouch" },
|
||||||
|
{ Enchantment.Unbreaking, "Enchantment.Unbreaking" },
|
||||||
|
{ Enchantment.Fortune, "Enchantment.Fortune" },
|
||||||
|
{ Enchantment.Power, "Enchantment.Power" },
|
||||||
|
{ Enchantment.Punch, "Enchantment.Punch" },
|
||||||
|
{ Enchantment.Flame, "Enchantment.Flame" },
|
||||||
|
{ Enchantment.Infinity, "Enchantment.Infinity" },
|
||||||
|
{ Enchantment.LuckOfTheSea, "Enchantment.LuckOfTheSea" },
|
||||||
|
{ Enchantment.Lure, "Enchantment.Lure" },
|
||||||
|
{ Enchantment.Loyality, "Enchantment.Loyality" },
|
||||||
|
{ Enchantment.Impaling, "Enchantment.Impaling" },
|
||||||
|
{ Enchantment.Riptide, "Enchantment.Riptide" },
|
||||||
|
{ Enchantment.Channeling, "Enchantment.Channeling" },
|
||||||
|
{ Enchantment.Multishot, "Enchantment.Multishot" },
|
||||||
|
{ Enchantment.QuickCharge, "Enchantment.QuickCharge" },
|
||||||
|
{ Enchantment.Piercing, "Enchantment.Piercing" },
|
||||||
|
{ Enchantment.Mending, "Enchantment.Mending" },
|
||||||
|
{ Enchantment.VanishingCurse, "Enchantment.VanishingCurse" }
|
||||||
|
};
|
||||||
|
#pragma warning restore format // @formatter:on
|
||||||
|
|
||||||
|
public static Enchantment GetEnchantmentById(int protocolVersion, short id)
|
||||||
|
{
|
||||||
|
if (protocolVersion < Protocol18Handler.MC_1_14_Version)
|
||||||
|
throw new Exception("Enchantments mappings are not implemented bellow 1.14");
|
||||||
|
|
||||||
|
Dictionary<short, Enchantment> map = enchantmentMappings;
|
||||||
|
|
||||||
|
if (protocolVersion >= Protocol18Handler.MC_1_14_Version && protocolVersion < Protocol18Handler.MC_1_16_Version)
|
||||||
|
map = enchantmentMappings114;
|
||||||
|
else if (protocolVersion >= Protocol18Handler.MC_1_16_Version && protocolVersion < Protocol18Handler.MC_1_19_Version)
|
||||||
|
map = enchantmentMappings116;
|
||||||
|
|
||||||
|
if (!map.ContainsKey(id))
|
||||||
|
throw new Exception("Got an Unknown Enchantment ID '" + id + "', please update the Mappings!");
|
||||||
|
|
||||||
|
return map[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetEnchantmentName(Enchantment enchantment)
|
||||||
|
{
|
||||||
|
if (!enchantmentNames.ContainsKey(enchantment))
|
||||||
|
return "Unknown Enchantment with ID: " + ((short)enchantment) + " (Probably not named in the code yet)";
|
||||||
|
|
||||||
|
return Translations.TryGet(enchantmentNames[enchantment]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ConvertLevelToRomanNumbers(int num)
|
||||||
|
{
|
||||||
|
string result = string.Empty;
|
||||||
|
Dictionary<string, int> romanNumbers = new Dictionary<string, int>
|
||||||
|
{
|
||||||
|
{"M", 1000 },
|
||||||
|
{"CM", 900},
|
||||||
|
{"D", 500},
|
||||||
|
{"CD", 400},
|
||||||
|
{"C", 100},
|
||||||
|
{"XC", 90},
|
||||||
|
{"L", 50},
|
||||||
|
{"XL", 40},
|
||||||
|
{"X", 10},
|
||||||
|
{"IX", 9},
|
||||||
|
{"V", 5},
|
||||||
|
{"IV", 4},
|
||||||
|
{"I", 1}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var pair in romanNumbers)
|
||||||
|
{
|
||||||
|
result += string.Join(string.Empty, Enumerable.Repeat(pair.Key, num / pair.Value));
|
||||||
|
num %= pair.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
MinecraftClient/Inventory/EnchantmentPropertyInfo.cs
Normal file
23
MinecraftClient/Inventory/EnchantmentPropertyInfo.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace MinecraftClient.Inventory
|
||||||
|
{
|
||||||
|
public enum EnchantmentPropertyInfo
|
||||||
|
{
|
||||||
|
// Levels that are required to enchant an item
|
||||||
|
TopEnchantmentLevelRequirement = 0,
|
||||||
|
MiddleEnchantmentLevelRequirement,
|
||||||
|
BottomEnchantmentLevelRequirement,
|
||||||
|
|
||||||
|
// Seed
|
||||||
|
EnchantmentSeed,
|
||||||
|
|
||||||
|
// Enchantment ids
|
||||||
|
TopEnchantmentId,
|
||||||
|
MiddleEnchantmentId,
|
||||||
|
BottomEnchantmentId,
|
||||||
|
|
||||||
|
// Shown on mouse hover over the top, middle and bottom slot
|
||||||
|
TopEnchantmentLevel,
|
||||||
|
MiddleEnchantmentLevel,
|
||||||
|
BottomEnchantmentLevel
|
||||||
|
}
|
||||||
|
}
|
||||||
46
MinecraftClient/Inventory/Enchantments.cs
Normal file
46
MinecraftClient/Inventory/Enchantments.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
namespace MinecraftClient.Inventory
|
||||||
|
{
|
||||||
|
// Not implemented for 1.14
|
||||||
|
public enum Enchantment : short
|
||||||
|
{
|
||||||
|
Protection = 0,
|
||||||
|
FireProtection,
|
||||||
|
FeatherFalling,
|
||||||
|
BlastProtection,
|
||||||
|
ProjectileProtection,
|
||||||
|
Respiration,
|
||||||
|
AquaAffinity,
|
||||||
|
Thorns,
|
||||||
|
DepthStrieder,
|
||||||
|
FrostWalker,
|
||||||
|
BindingCurse,
|
||||||
|
SoulSpeed,
|
||||||
|
SwiftSneak,
|
||||||
|
Sharpness,
|
||||||
|
Smite,
|
||||||
|
BaneOfArthropods,
|
||||||
|
Knockback,
|
||||||
|
FireAspect,
|
||||||
|
Looting,
|
||||||
|
Sweeping,
|
||||||
|
Efficency,
|
||||||
|
SilkTouch,
|
||||||
|
Unbreaking,
|
||||||
|
Fortune,
|
||||||
|
Power,
|
||||||
|
Punch,
|
||||||
|
Flame,
|
||||||
|
Infinity,
|
||||||
|
LuckOfTheSea,
|
||||||
|
Lure,
|
||||||
|
Loyality,
|
||||||
|
Impaling,
|
||||||
|
Riptide,
|
||||||
|
Channeling,
|
||||||
|
Multishot,
|
||||||
|
QuickCharge,
|
||||||
|
Piercing,
|
||||||
|
Mending,
|
||||||
|
VanishingCurse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Transactions;
|
||||||
using MinecraftClient.ChatBots;
|
using MinecraftClient.ChatBots;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
using MinecraftClient.Logger;
|
using MinecraftClient.Logger;
|
||||||
|
|
@ -2651,6 +2652,93 @@ namespace MinecraftClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When received window properties from server.
|
||||||
|
/// Used for Frunaces, Enchanting Table, Beacon, Brewing stand, Stone cutter, Loom and Lectern
|
||||||
|
/// More info about: https://wiki.vg/Protocol#Set_Container_Property
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inventoryID">Inventory ID</param>
|
||||||
|
/// <param name="propertyId">Property ID</param>
|
||||||
|
/// <param name="propertyValue">Property Value</param>
|
||||||
|
public void OnWindowProperties(byte inventoryID, short propertyId, short propertyValue)
|
||||||
|
{
|
||||||
|
if (!inventories.ContainsKey(inventoryID))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Container inventory = inventories[inventoryID];
|
||||||
|
|
||||||
|
if (inventory.Properties.ContainsKey(propertyId))
|
||||||
|
inventory.Properties.Remove(propertyId);
|
||||||
|
|
||||||
|
inventory.Properties.Add(propertyId, propertyValue);
|
||||||
|
|
||||||
|
DispatchBotEvent(bot => bot.OnInventoryProperties(inventoryID, propertyId, propertyValue));
|
||||||
|
|
||||||
|
if (inventory.Type == ContainerType.Enchantment)
|
||||||
|
{
|
||||||
|
// We got the last property for enchantment
|
||||||
|
if (propertyId == 9 && propertyValue != -1)
|
||||||
|
{
|
||||||
|
short topEnchantmentLevelRequirement = inventory.Properties[0];
|
||||||
|
short middleEnchantmentLevelRequirement = inventory.Properties[1];
|
||||||
|
short bottomEnchantmentLevelRequirement = inventory.Properties[2];
|
||||||
|
|
||||||
|
Enchantment topEnchantment = EnchantmentMapping.GetEnchantmentById(
|
||||||
|
GetProtocolVersion(),
|
||||||
|
inventory.Properties[4]);
|
||||||
|
|
||||||
|
Enchantment middleEnchantment = EnchantmentMapping.GetEnchantmentById(
|
||||||
|
GetProtocolVersion(),
|
||||||
|
inventory.Properties[5]);
|
||||||
|
|
||||||
|
Enchantment bottomEnchantment = EnchantmentMapping.GetEnchantmentById(
|
||||||
|
GetProtocolVersion(),
|
||||||
|
inventory.Properties[6]);
|
||||||
|
|
||||||
|
short topEnchantmentLevel = inventory.Properties[7];
|
||||||
|
short middleEnchantmentLevel = inventory.Properties[8];
|
||||||
|
short bottomEnchantmentLevel = inventory.Properties[9];
|
||||||
|
|
||||||
|
StringBuilder sb = new();
|
||||||
|
|
||||||
|
sb.AppendLine(Translations.TryGet("Enchantment.enchantments_available") + ":");
|
||||||
|
|
||||||
|
sb.AppendLine(Translations.TryGet("Enchantment.tops_slot") + ":\t"
|
||||||
|
+ EnchantmentMapping.GetEnchantmentName(topEnchantment) + " "
|
||||||
|
+ EnchantmentMapping.ConvertLevelToRomanNumbers(topEnchantmentLevel) + " ("
|
||||||
|
+ topEnchantmentLevelRequirement + " " + Translations.TryGet("Enchantment.levels") + ")");
|
||||||
|
|
||||||
|
sb.AppendLine(Translations.TryGet("Enchantment.middle_slot") + ":\t"
|
||||||
|
+ EnchantmentMapping.GetEnchantmentName(middleEnchantment) + " "
|
||||||
|
+ EnchantmentMapping.ConvertLevelToRomanNumbers(middleEnchantmentLevel) + " ("
|
||||||
|
+ middleEnchantmentLevelRequirement + " " + Translations.TryGet("Enchantment.levels") + ")");
|
||||||
|
|
||||||
|
sb.AppendLine(Translations.TryGet("Enchantment.bottom_slot") + ":\t"
|
||||||
|
+ EnchantmentMapping.GetEnchantmentName(bottomEnchantment) + " "
|
||||||
|
+ EnchantmentMapping.ConvertLevelToRomanNumbers(bottomEnchantmentLevel) + " ("
|
||||||
|
+ bottomEnchantmentLevelRequirement + " " + Translations.TryGet("Enchantment.levels") + ")");
|
||||||
|
|
||||||
|
Log.Info(sb.ToString());
|
||||||
|
|
||||||
|
DispatchBotEvent(bot => bot.OnEnchantments(
|
||||||
|
// Enchantments
|
||||||
|
topEnchantment,
|
||||||
|
middleEnchantment,
|
||||||
|
bottomEnchantment,
|
||||||
|
|
||||||
|
// Enchantment levels
|
||||||
|
topEnchantmentLevel,
|
||||||
|
middleEnchantmentLevel,
|
||||||
|
bottomEnchantmentLevel,
|
||||||
|
|
||||||
|
// Required levels for enchanting
|
||||||
|
topEnchantmentLevelRequirement,
|
||||||
|
middleEnchantmentLevelRequirement,
|
||||||
|
bottomEnchantmentLevelRequirement));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When received window items from server.
|
/// When received window items from server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3305,6 +3393,19 @@ namespace MinecraftClient
|
||||||
DispatchBotEvent(bot => bot.OnBlockChange(location, block));
|
DispatchBotEvent(bot => bot.OnBlockChange(location, block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a click container button packet to the server.
|
||||||
|
/// Used for Enchanting table, Lectern, stone cutter and loom
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windowId">Id of the window being clicked</param>
|
||||||
|
/// <param name="buttonId">Id of the clicked button</param>
|
||||||
|
/// <returns>True if packet was successfully sent</returns>
|
||||||
|
|
||||||
|
public bool ClickContainerButton(int windowId, int buttonId)
|
||||||
|
{
|
||||||
|
return handler.ClickContainerButton(windowId, buttonId);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -770,6 +770,11 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return false; //Currently not implemented
|
return false; //Currently not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ClickContainerButton(int windowId, int buttonId)
|
||||||
|
{
|
||||||
|
return false; //Currently not implemented
|
||||||
|
}
|
||||||
|
|
||||||
public bool SendCloseWindow(int windowId)
|
public bool SendCloseWindow(int windowId)
|
||||||
{
|
{
|
||||||
return false; //Currently not implemented
|
return false; //Currently not implemented
|
||||||
|
|
|
||||||
|
|
@ -1382,6 +1382,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
handler.OnWindowItems(windowId, inventorySlots, stateId);
|
handler.OnWindowItems(windowId, inventorySlots, stateId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PacketTypesIn.WindowProperty:
|
||||||
|
byte containerId = dataTypes.ReadNextByte(packetData);
|
||||||
|
short propertyId = dataTypes.ReadNextShort(packetData);
|
||||||
|
short propertyValue = dataTypes.ReadNextShort(packetData);
|
||||||
|
|
||||||
|
handler.OnWindowProperties(containerId, propertyId, propertyValue);
|
||||||
|
break;
|
||||||
case PacketTypesIn.SetSlot:
|
case PacketTypesIn.SetSlot:
|
||||||
if (handler.GetInventoryEnabled())
|
if (handler.GetInventoryEnabled())
|
||||||
{
|
{
|
||||||
|
|
@ -2835,6 +2842,21 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
catch (ObjectDisposedException) { return false; }
|
catch (ObjectDisposedException) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ClickContainerButton(int windowId, int buttonId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<byte> packet = new();
|
||||||
|
packet.Add((byte)windowId);
|
||||||
|
packet.Add((byte)buttonId);
|
||||||
|
SendPacket(PacketTypesOut.ClickWindowButton, packet);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (SocketException) { return false; }
|
||||||
|
catch (System.IO.IOException) { return false; }
|
||||||
|
catch (ObjectDisposedException) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
public bool SendAnimation(int animation, int playerid)
|
public bool SendAnimation(int animation, int playerid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,16 @@ namespace MinecraftClient.Protocol
|
||||||
/// <returns>TRUE if item given successfully</returns>
|
/// <returns>TRUE if item given successfully</returns>
|
||||||
bool SendCreativeInventoryAction(int slot, ItemType itemType, int count, Dictionary<string, object>? nbt);
|
bool SendCreativeInventoryAction(int slot, ItemType itemType, int count, Dictionary<string, object>? nbt);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a click container button packet to the server.
|
||||||
|
/// Used for Enchanting table, Lectern, stone cutter and loom
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windowId">Id of the window being clicked</param>
|
||||||
|
/// <param name="buttonId">Id of the clicked button</param>
|
||||||
|
/// <returns>True if packet was successfully sent</returns>
|
||||||
|
|
||||||
|
bool ClickContainerButton(int windowId, int buttonId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plays animation
|
/// Plays animation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,15 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="TimeOfDay">Time of Day</param>
|
/// <param name="TimeOfDay">Time of Day</param>
|
||||||
void OnTimeUpdate(long worldAge, long timeOfDay);
|
void OnTimeUpdate(long worldAge, long timeOfDay);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When received window properties from server.
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inventoryID">Inventory ID</param>
|
||||||
|
/// <param name="propertyId">Property ID</param>
|
||||||
|
/// <param name="propertyValue">Property Value</param>
|
||||||
|
public void OnWindowProperties(byte inventoryID, short propertyId, short propertyValue);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when inventory items have been received
|
/// Called when inventory items have been received
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -439,5 +448,15 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="location">The location of the block.</param>
|
/// <param name="location">The location of the block.</param>
|
||||||
/// <param name="block">The block</param>
|
/// <param name="block">The block</param>
|
||||||
public void OnBlockChange(Location location, Block block);
|
public void OnBlockChange(Location location, Block block);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a click container button packet to the server.
|
||||||
|
/// Used for Enchanting table, Lectern, stone cutter and loom
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windowId">Id of the window being clicked</param>
|
||||||
|
/// <param name="buttonId">Id of the clicked button</param>
|
||||||
|
/// <returns>True if packet was successfully sent</returns>
|
||||||
|
|
||||||
|
bool ClickContainerButton(int windowId, int buttonId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
╔═════════════════════════════════════╗
|
||||||
|
║ Enchant ║
|
||||||
|
║ ╔════════════════════╗ ║
|
||||||
|
║ ║ Top ║ ║
|
||||||
|
║ ╔═══╦═══╗ ╠════════════════════╣ ║
|
||||||
|
║ ║ 0 ║ 1 ║ ║ Middle ║ ║
|
||||||
|
║ ╚═══╩═══╝ ╠════════════════════╣ ║
|
||||||
|
║ ║ Bottom ║ ║
|
||||||
|
║ ╚════════════════════╝ ║
|
||||||
|
║ Inventory ║
|
||||||
|
║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║
|
||||||
|
║║ 2 ║ 3 ║ 4 ║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║║
|
||||||
|
║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║
|
||||||
|
║║11 ║12 ║13 ║14 ║15 ║16 ║17 ║18 ║19 ║║
|
||||||
|
║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║
|
||||||
|
║║20 ║21 ║22 ║23 ║24 ║25 ║26 ║27 ║28 ║║
|
||||||
|
║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║
|
||||||
|
║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║
|
||||||
|
║║29 ║30 ║31 ║32 ║33 ║34 ║35 ║36 ║37 ║║
|
||||||
|
║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║
|
||||||
|
║ 1 2 3 4 5 6 7 8 9 ║
|
||||||
|
╚═════════════════════════════════════╝
|
||||||
|
|
@ -152,6 +152,52 @@ extra.inventory_close=Inventory # {0} closed.
|
||||||
extra.entity_disabled=§cEntities are currently not handled for that MC version.
|
extra.entity_disabled=§cEntities are currently not handled for that MC version.
|
||||||
extra.entity_required=Please enable EntityHandling in the config file first.
|
extra.entity_required=Please enable EntityHandling in the config file first.
|
||||||
|
|
||||||
|
# Enchantments
|
||||||
|
Enchantment.enchantments_available=Enchantments available
|
||||||
|
Enchantment.tops_slot=Top slot
|
||||||
|
Enchantment.middle_slot=Middle slot
|
||||||
|
Enchantment.bottom_slot=Bottom slot
|
||||||
|
Enchantment.levels=Levels
|
||||||
|
|
||||||
|
Enchantment.Protection=Protection
|
||||||
|
Enchantment.FireProtection=Fire Protection
|
||||||
|
Enchantment.FeatherFalling=Feather Falling
|
||||||
|
Enchantment.BlastProtection=Blast Protection
|
||||||
|
Enchantment.ProjectileProtection=Projectile Protection
|
||||||
|
Enchantment.Respiration=Respiration
|
||||||
|
Enchantment.AquaAffinity=Aqua Affinity
|
||||||
|
Enchantment.Thorns=Thorns
|
||||||
|
Enchantment.DepthStrieder=Depth Strieder
|
||||||
|
Enchantment.FrostWalker=Frost Walker
|
||||||
|
Enchantment.BindingCurse=Curse of Binding
|
||||||
|
Enchantment.SoulSpeed=Soul Speed
|
||||||
|
Enchantment.SwiftSneak=Swift Sneak
|
||||||
|
Enchantment.Sharpness=Sharpness
|
||||||
|
Enchantment.Smite=Smite
|
||||||
|
Enchantment.BaneOfArthropods=Bane of Arthropods
|
||||||
|
Enchantment.Knockback=Knockback
|
||||||
|
Enchantment.FireAspect=Fire Aspect
|
||||||
|
Enchantment.Looting=Looting
|
||||||
|
Enchantment.Sweeping=Sweeping
|
||||||
|
Enchantment.Efficency=Efficency
|
||||||
|
Enchantment.SilkTouch=Silk Touch
|
||||||
|
Enchantment.Unbreaking=Unbreaking
|
||||||
|
Enchantment.Fortune=Fortune
|
||||||
|
Enchantment.Power=Power
|
||||||
|
Enchantment.Punch=Punch
|
||||||
|
Enchantment.Flame=Flame
|
||||||
|
Enchantment.Infinity=Infinity
|
||||||
|
Enchantment.LuckOfTheSea=Luck of the Sea
|
||||||
|
Enchantment.Lure=Lure
|
||||||
|
Enchantment.Loyality=Loyality
|
||||||
|
Enchantment.Impaling=Impaling
|
||||||
|
Enchantment.Riptide=Riptide
|
||||||
|
Enchantment.Channeling=Channeling
|
||||||
|
Enchantment.Multishot=Multishot
|
||||||
|
Enchantment.QuickCharge=Quick Charge
|
||||||
|
Enchantment.Piercing=Piercing
|
||||||
|
Enchantment.Mending=Mending
|
||||||
|
Enchantment.VanishingCurse=Curse of Vanishing
|
||||||
|
|
||||||
[forge]
|
[forge]
|
||||||
# Messages from Forge handler
|
# Messages from Forge handler
|
||||||
|
|
@ -263,6 +309,15 @@ cmd.dig.no_block=No block at this location (Air)
|
||||||
cmd.dig.dig=Attempting to dig block at {0} {1} {2} ({3})
|
cmd.dig.dig=Attempting to dig block at {0} {1} {2} ({3})
|
||||||
cmd.dig.fail=Failed to start digging block.
|
cmd.dig.fail=Failed to start digging block.
|
||||||
|
|
||||||
|
# Enchantment Command
|
||||||
|
|
||||||
|
cmd.enchant.invalid_slot=Invalid slot provided (Available: top, middle, bottom)!
|
||||||
|
cmd.enchant.enchanting_table_not_opened=You must open a an enchanting table in order to use this option!
|
||||||
|
cmd.enchant.clicked=Sent a click to the server, if you have enough levels and if you have placed the items in the correct slots it should enchant!
|
||||||
|
cmd.enchant.not_clicked=Could not click!
|
||||||
|
cmd.enchant.enchanting_no_item=You must put an item inside the enchanting table in slot 0!
|
||||||
|
cmd.enchant.enchanting_no_lapis=You must put at least 3 lapis lazuli inside the enchanting table in slot 1!
|
||||||
|
|
||||||
# Entitycmd
|
# Entitycmd
|
||||||
cmd.entityCmd.attacked=Entity attacked
|
cmd.entityCmd.attacked=Entity attacked
|
||||||
cmd.entityCmd.used=Entity used
|
cmd.entityCmd.used=Entity used
|
||||||
|
|
|
||||||
|
|
@ -358,6 +358,42 @@ namespace MinecraftClient
|
||||||
/// <param name="inventoryId"></param>
|
/// <param name="inventoryId"></param>
|
||||||
public virtual void OnInventoryClose(int inventoryId) { }
|
public virtual void OnInventoryClose(int inventoryId) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When received inventory/container/window properties from the server.
|
||||||
|
/// Used for Frunaces, Enchanting Table, Beacon, Brewing stand, Stone cutter, Loom and Lectern
|
||||||
|
/// More info about: https://wiki.vg/Protocol#Set_Container_Property
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inventoryID">Inventory ID</param>
|
||||||
|
/// <param name="propertyId">Property ID</param>
|
||||||
|
/// <param name="propertyValue">Property Value</param>
|
||||||
|
public virtual void OnInventoryProperties(byte inventoryID, short propertyId, short propertyValue) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When received enchantments from the server this method is called
|
||||||
|
/// Enchantment levels are the levels of enchantment (eg. I, II, III, IV, V) (eg. Smite IV, Power III, Knockback II ..)
|
||||||
|
/// Enchantment level requirements are the levels that player needs to have in order to enchant the item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="topEnchantment">Enchantment in the top most slot</param>
|
||||||
|
/// <param name="middleEnchantment">Enchantment in the middle slot</param>
|
||||||
|
/// <param name="bottomEnchantment">Enchantment in the bottom slot</param>
|
||||||
|
/// <param name="topEnchantmentLevel">Enchantment level for the enchantment in the top most slot</param>
|
||||||
|
/// <param name="middleEnchantmentLevel">Enchantment level for the enchantment in the middle slot</param>
|
||||||
|
/// <param name="bottomEnchantmentLevel">Enchantment level for the enchantment in the bottom slot</param>
|
||||||
|
/// <param name="topEnchantmentLevelRequirement">Levels required by player for the enchantment in the top most slot</param>
|
||||||
|
/// <param name="middleEnchantmentLevelRequirement">Levels required by player for the enchantment in the middle slot</param>
|
||||||
|
/// <param name="bottomEnchantmentLevelRequirement">Levels required by player for the enchantment in the bottom slot</param>
|
||||||
|
public virtual void OnEnchantments(
|
||||||
|
Enchantment topEnchantment,
|
||||||
|
Enchantment middleEnchantment,
|
||||||
|
Enchantment bottomEnchantment,
|
||||||
|
short topEnchantmentLevel,
|
||||||
|
short middleEnchantmentLevel,
|
||||||
|
short bottomEnchantmentLevel,
|
||||||
|
short topEnchantmentLevelRequirement,
|
||||||
|
short middleEnchantmentLevelRequirement,
|
||||||
|
short bottomEnchantmentLevelRequirement)
|
||||||
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a player joined the game
|
/// Called when a player joined the game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue