Added a command to (re)name items in the Anvil

This commit is contained in:
Anon 2023-06-03 16:12:17 +02:00
parent 9855e2e0f1
commit fce12db33f
8 changed files with 174 additions and 0 deletions

View file

@ -909,6 +909,11 @@ namespace MinecraftClient.Protocol.Handlers
{
return false; //Currently not implemented
}
public bool SendRenameItem(string itemName)
{
return false;
}
public bool SendPlayerSession(PlayerKeyPair? playerKeyPair)
{

View file

@ -4150,6 +4150,29 @@ namespace MinecraftClient.Protocol.Handlers
}
}
public bool SendRenameItem(string itemName)
{
try
{
List<byte> packet = new();
packet.AddRange(dataTypes.GetString(itemName.Length > 50 ? itemName[..50] : itemName));
SendPacket(PacketTypesOut.NameItem, packet);
return true;
}
catch (SocketException)
{
return false;
}
catch (System.IO.IOException)
{
return false;
}
catch (ObjectDisposedException)
{
return false;
}
}
private byte[] GenerateSalt()
{
byte[] salt = new byte[8];

View file

@ -260,6 +260,12 @@ namespace MinecraftClient.Protocol
/// </summary>
/// <returns></returns>
bool SendPlayerSession(PlayerKeyPair? playerKeyPair);
/// <summary>
/// Send the server a command to type in the item name in the Anvil inventory when it's open.
/// </summary>
/// <param name="itemName">The new item name</param>
bool SendRenameItem(string itemName);
/// <summary>
/// Get net read thread (main thread) ID

View file

@ -477,5 +477,13 @@ namespace MinecraftClient.Protocol
/// <returns>True if packet was successfully sent</returns>
bool ClickContainerButton(int windowId, int buttonId);
/// <summary>
/// Send a rename item packet when the anvil inventory is open and there is an item in the first slot
/// </summary>
/// <param name="itemName">New name (max 50 characters)</param>
/// <returns>True if packet was successfully sent</returns>
bool SendRenameItem(string itemName);
}
}