Skip to content

Commit 968f864

Browse files
Added ShiftRightClick (#2582)
* Added ShiftRightClick * Added ShiftRightClick * Added ShiftRightClick * Added ShiftRightClick * Added ShiftRightClick * Added ShiftRightClick * Added ShiftRightClick * Added ShiftRightClick * Updated Protocol18.cs ShiftRightClick Description for ReinforceZwei's Suggestion * Just Deleted Added ShiftRightClick's Description Line * Just Deleted Added ShiftRightClick's Description Lines * Made Change With Informaiton ReinforceZwei Given to Me About Switch-Case and Shorten the Code. * Re Added Lines That Got Deleted By Mistake * Add translation key for shift right-click --------- Co-authored-by: ReinforceZwei <[email protected]>
1 parent 37bcad3 commit 968f864

File tree

7 files changed

+2288
-246
lines changed

7 files changed

+2288
-246
lines changed

MinecraftClient/CommandHandler/ArgumentType/InventoryActionArgumentType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class InventoryActionArgumentType : ArgumentType<WindowActionType>
1616
WindowActionType.RightClick,
1717
WindowActionType.MiddleClick,
1818
WindowActionType.ShiftClick,
19+
WindowActionType.ShiftRightClick,
1920
};
2021

2122
public override WindowActionType Parse(IStringReader reader)
@@ -33,6 +34,7 @@ public override WindowActionType Parse(IStringReader reader)
3334
"middleclick" => WindowActionType.MiddleClick,
3435
"shift" => WindowActionType.ShiftClick,
3536
"shiftclick" => WindowActionType.ShiftClick,
37+
"shiftrightclick" => WindowActionType.ShiftRightClick,
3638
_ => throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, inputStr)
3739
};
3840
}

MinecraftClient/Commands/Inventory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private int GetUsage(CmdResult r, string? cmd)
115115
#pragma warning disable format // @formatter:off
116116
"list" => Translations.cmd_inventory_help_list + usageStr + "/inventory <player|container|<id>> list",
117117
"close" => Translations.cmd_inventory_help_close + usageStr + "/inventory <player|container|<id>> close",
118-
"click" => Translations.cmd_inventory_help_click + usageStr + "/inventory <player|container|<id>> click <slot> [left|right|middle|shift]\nDefault is left click",
118+
"click" => Translations.cmd_inventory_help_click + usageStr + "/inventory <player|container|<id>> click <slot> [left|right|middle|shift|shiftright]\nDefault is left click",
119119
"drop" => Translations.cmd_inventory_help_drop + usageStr + "/inventory <player|container|<id>> drop <slot> [all]\nAll means drop full stack",
120120
"creativegive" => Translations.cmd_inventory_help_creativegive + usageStr + "/inventory creativegive <slot> <itemtype> <amount>",
121121
"creativedelete" => Translations.cmd_inventory_help_creativedelete + usageStr + "/inventory creativedelete <slot>",
@@ -351,6 +351,7 @@ private int DoClickAction(CmdResult r, int? inventoryId, int slot, WindowActionT
351351
WindowActionType.RightClick => Translations.cmd_inventory_right,
352352
WindowActionType.MiddleClick => Translations.cmd_inventory_middle,
353353
WindowActionType.ShiftClick => Translations.cmd_inventory_shiftclick,
354+
WindowActionType.ShiftRightClick => Translations.cmd_inventory_shiftrightclick,
354355
_ => "unknown",
355356
};
356357

MinecraftClient/Inventory/WindowActionType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public enum WindowActionType
2525
/// </summary>
2626
ShiftClick,
2727

28+
/// <summary>
29+
/// Shift+Right click with mouse on a slot: send a whole item stack to the hotbar or other inventory. Differece from ShiftClick is how it reported to server
30+
/// </summary>
31+
ShiftRightClick,
32+
2833
/// <summary>
2934
/// Drop a single item on ground
3035
/// </summary>

MinecraftClient/McClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,7 @@ public bool DoWindowAction(int windowId, int slotId, WindowActionType action)
15821582
changedSlots.Add(new Tuple<short, Item?>((short)slotId, null));
15831583
break;
15841584
case WindowActionType.ShiftClick:
1585+
case WindowActionType.ShiftRightClick:
15851586
if (slotId == 0) break;
15861587
if (item != null)
15871588
{

MinecraftClient/Protocol/Handlers/Protocol18.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3723,6 +3723,11 @@ public bool SendWindowAction(int windowId, int slotId, WindowActionType action,
37233723
mode = 1;
37243724
item = new Item(ItemType.Null, 0, null);
37253725
break;
3726+
case WindowActionType.ShiftRightClick: // Right-shift click uses button 1
3727+
button = 1;
3728+
mode = 1;
3729+
item = new Item(ItemType.Null, 0, null);
3730+
break;
37263731
case WindowActionType.DropItem:
37273732
button = 0;
37283733
mode = 4;
@@ -4199,4 +4204,4 @@ private byte[] GenerateSalt()
41994204
return salt;
42004205
}
42014206
}
4202-
}
4207+
}

0 commit comments

Comments
 (0)