Skip to content

Commit

Permalink
Added ShiftRightClick (#2582)
Browse files Browse the repository at this point in the history
* 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 <39955851+ReinforceZwei@users.noreply.github.com>
  • Loading branch information
ozi2285 and ReinforceZwei committed Sep 16, 2023
1 parent 37bcad3 commit 968f864
Show file tree
Hide file tree
Showing 7 changed files with 2,288 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class InventoryActionArgumentType : ArgumentType<WindowActionType>
WindowActionType.RightClick,
WindowActionType.MiddleClick,
WindowActionType.ShiftClick,
WindowActionType.ShiftRightClick,
};

public override WindowActionType Parse(IStringReader reader)
Expand All @@ -33,6 +34,7 @@ public override WindowActionType Parse(IStringReader reader)
"middleclick" => WindowActionType.MiddleClick,
"shift" => WindowActionType.ShiftClick,
"shiftclick" => WindowActionType.ShiftClick,
"shiftrightclick" => WindowActionType.ShiftRightClick,
_ => throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, inputStr)
};
}
Expand Down
3 changes: 2 additions & 1 deletion MinecraftClient/Commands/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private int GetUsage(CmdResult r, string? cmd)
#pragma warning disable format // @formatter:off
"list" => Translations.cmd_inventory_help_list + usageStr + "/inventory <player|container|<id>> list",
"close" => Translations.cmd_inventory_help_close + usageStr + "/inventory <player|container|<id>> close",
"click" => Translations.cmd_inventory_help_click + usageStr + "/inventory <player|container|<id>> click <slot> [left|right|middle|shift]\nDefault is left click",
"click" => Translations.cmd_inventory_help_click + usageStr + "/inventory <player|container|<id>> click <slot> [left|right|middle|shift|shiftright]\nDefault is left click",
"drop" => Translations.cmd_inventory_help_drop + usageStr + "/inventory <player|container|<id>> drop <slot> [all]\nAll means drop full stack",
"creativegive" => Translations.cmd_inventory_help_creativegive + usageStr + "/inventory creativegive <slot> <itemtype> <amount>",
"creativedelete" => Translations.cmd_inventory_help_creativedelete + usageStr + "/inventory creativedelete <slot>",
Expand Down Expand Up @@ -351,6 +351,7 @@ private int DoClickAction(CmdResult r, int? inventoryId, int slot, WindowActionT
WindowActionType.RightClick => Translations.cmd_inventory_right,
WindowActionType.MiddleClick => Translations.cmd_inventory_middle,
WindowActionType.ShiftClick => Translations.cmd_inventory_shiftclick,
WindowActionType.ShiftRightClick => Translations.cmd_inventory_shiftrightclick,
_ => "unknown",
};

Expand Down
5 changes: 5 additions & 0 deletions MinecraftClient/Inventory/WindowActionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public enum WindowActionType
/// </summary>
ShiftClick,

/// <summary>
/// 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
/// </summary>
ShiftRightClick,

/// <summary>
/// Drop a single item on ground
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions MinecraftClient/McClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ public bool DoWindowAction(int windowId, int slotId, WindowActionType action)
changedSlots.Add(new Tuple<short, Item?>((short)slotId, null));
break;
case WindowActionType.ShiftClick:
case WindowActionType.ShiftRightClick:
if (slotId == 0) break;
if (item != null)
{
Expand Down
7 changes: 6 additions & 1 deletion MinecraftClient/Protocol/Handlers/Protocol18.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,11 @@ public bool SendHeldItemChange(short slot)
mode = 1;
item = new Item(ItemType.Null, 0, null);
break;
case WindowActionType.ShiftRightClick: // Right-shift click uses button 1
button = 1;
mode = 1;
item = new Item(ItemType.Null, 0, null);
break;
case WindowActionType.DropItem:
button = 0;
mode = 4;
Expand Down Expand Up @@ -4199,4 +4204,4 @@ private byte[] GenerateSalt()
return salt;
}
}
}
}
Loading

0 comments on commit 968f864

Please sign in to comment.