mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implement inventory mouse item dragging (#1208)
* Implement inventory mouse item dragging * SendWindowAction: Format switch/align statements * Document window action types Co-authored-by: ORelio <ORelio@users.noreply.github.com>
This commit is contained in:
parent
4a3a23eb1d
commit
526dabd1e7
2 changed files with 89 additions and 15 deletions
|
|
@ -5,13 +5,84 @@ using System.Text;
|
||||||
|
|
||||||
namespace MinecraftClient.Inventory
|
namespace MinecraftClient.Inventory
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents mouse interactions with an inventory window
|
||||||
|
/// </summary>
|
||||||
public enum WindowActionType
|
public enum WindowActionType
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Left click with mouse on a slot: grab or drop a whole item stack
|
||||||
|
/// </summary>
|
||||||
LeftClick,
|
LeftClick,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Right click with mouse on a slot: grab half a stack or drop a single item
|
||||||
|
/// </summary>
|
||||||
RightClick,
|
RightClick,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Middle click with mouse on a slot: grab a full stack from creative inventory
|
||||||
|
/// </summary>
|
||||||
MiddleClick,
|
MiddleClick,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shift+Left click with mouse on a slot: send a whole item stack to the hotbar or other inventory
|
||||||
|
/// </summary>
|
||||||
ShiftClick,
|
ShiftClick,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drop a single item on ground after grabbing an item stack
|
||||||
|
/// </summary>
|
||||||
DropItem,
|
DropItem,
|
||||||
DropItemStack
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drop a whole item stack on ground after grabbing it
|
||||||
|
/// </summary>
|
||||||
|
DropItemStack,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start hovering slots with left button pressed: Distribute evenly the stack on hovered slots
|
||||||
|
/// </summary>
|
||||||
|
StartDragLeft,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start hovering slots with right button pressed: Drop one item on each hovered slot
|
||||||
|
/// </summary>
|
||||||
|
StartDragRight,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start hovering slots with middle button pressed: Create one item stack on each hovered slot in creative mode
|
||||||
|
/// </summary>
|
||||||
|
StartDragMiddle,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hover a slot to distribute evenly an item stack
|
||||||
|
/// </summary>
|
||||||
|
AddDragLeft,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hover a slot to drop one item from an item stack
|
||||||
|
/// </summary>
|
||||||
|
AddDragRight,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hover a slot to create one item stack in creative mode
|
||||||
|
/// </summary>
|
||||||
|
AddDragMiddle,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop hovering slots with left button pressed
|
||||||
|
/// </summary>
|
||||||
|
EndDragLeft,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop hovering slots with right button pressed
|
||||||
|
/// </summary>
|
||||||
|
EndDragRight,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop hovering slots with middble button pressed
|
||||||
|
/// </summary>
|
||||||
|
EndDragMiddle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1609,6 +1609,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
catch (System.IO.IOException) { return false; }
|
catch (System.IO.IOException) { return false; }
|
||||||
catch (ObjectDisposedException) { return false; }
|
catch (ObjectDisposedException) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item)
|
public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -1624,22 +1625,24 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
byte button = 0;
|
byte button = 0;
|
||||||
byte mode = 0;
|
byte mode = 0;
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case WindowActionType.LeftClick: button = 0; break;
|
case WindowActionType.LeftClick: button = 0; break;
|
||||||
case WindowActionType.RightClick: button = 1; break;
|
case WindowActionType.RightClick: button = 1; break;
|
||||||
case WindowActionType.MiddleClick: button = 2; mode = 3; break;
|
case WindowActionType.MiddleClick: button = 2; mode = 3; break;
|
||||||
case WindowActionType.ShiftClick: button = 0; mode = 1; item = new Item(-1, 0, null); break;
|
case WindowActionType.ShiftClick: button = 0; mode = 1; item = new Item(-1, 0, null); break;
|
||||||
case WindowActionType.DropItem:
|
case WindowActionType.DropItem: button = 0; mode = 4; item = new Item(-1, 0, null); break;
|
||||||
button = 0;
|
case WindowActionType.DropItemStack: button = 1; mode = 4; item = new Item(-1, 0, null); break;
|
||||||
mode = 4;
|
case WindowActionType.StartDragLeft: button = 0; mode = 5; item = new Item(-1, 0, null); slotId = -999; break;
|
||||||
item = new Item(-1, 0, null);
|
case WindowActionType.StartDragRight: button = 4; mode = 5; item = new Item(-1, 0, null); slotId = -999; break;
|
||||||
break;
|
case WindowActionType.StartDragMiddle: button = 8; mode = 5; item = new Item(-1, 0, null); slotId = -999; break;
|
||||||
case WindowActionType.DropItemStack:
|
case WindowActionType.EndDragLeft: button = 2; mode = 5; item = new Item(-1, 0, null); slotId = -999; break;
|
||||||
button = 1;
|
case WindowActionType.EndDragRight: button = 6; mode = 5; item = new Item(-1, 0, null); slotId = -999; break;
|
||||||
mode = 4;
|
case WindowActionType.EndDragMiddle: button = 10; mode = 5; item = new Item(-1, 0, null); slotId = -999; break;
|
||||||
item = new Item(-1, 0, null);
|
case WindowActionType.AddDragLeft: button = 1; mode = 5; item = new Item(-1, 0, null); break;
|
||||||
break;
|
case WindowActionType.AddDragRight: button = 5; mode = 5; item = new Item(-1, 0, null); break;
|
||||||
|
case WindowActionType.AddDragMiddle: button = 9; mode = 5; item = new Item(-1, 0, null); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<byte> packet = new List<byte>();
|
List<byte> packet = new List<byte>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue