mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Fix double click clickedItem
always being air
This commit is contained in:
parent
4560f2e630
commit
8cf58fa397
@ -421,10 +421,14 @@ public class Inventory extends AbstractInventory implements Viewable {
|
||||
@Override
|
||||
public boolean doubleClick(@NotNull Player player, int slot) {
|
||||
final PlayerInventory playerInventory = player.getInventory();
|
||||
final ItemStack cursor = getCursorItem(player);
|
||||
final boolean isInWindow = isClickInWindow(slot);
|
||||
final int clickSlot = isInWindow ? slot : PlayerInventoryUtils.convertSlot(slot, offset);
|
||||
final ItemStack clicked = slot != -999 ?
|
||||
(isInWindow ? getItemStack(slot) : playerInventory.getItemStack(clickSlot)) :
|
||||
ItemStack.AIR;
|
||||
final ItemStack cursor = getCursorItem(player);
|
||||
final InventoryClickResult clickResult = clickProcessor.doubleClick(isInWindow ? this : playerInventory,
|
||||
this, player, slot, cursor);
|
||||
this, player, slot, clicked, cursor);
|
||||
if (clickResult.isCancel()) {
|
||||
updateAll(player);
|
||||
return false;
|
||||
|
@ -363,7 +363,8 @@ public class PlayerInventory extends AbstractInventory implements EquipmentHandl
|
||||
@Override
|
||||
public boolean doubleClick(@NotNull Player player, int slot) {
|
||||
final ItemStack cursor = getCursorItem();
|
||||
final InventoryClickResult clickResult = clickProcessor.doubleClick(this, this, player, slot, cursor);
|
||||
final ItemStack clicked = getItemStack(slot, OFFSET);
|
||||
final InventoryClickResult clickResult = clickProcessor.doubleClick(this, this, player, slot, clicked, cursor);
|
||||
if (clickResult.isCancel()) {
|
||||
update();
|
||||
return false;
|
||||
|
@ -265,8 +265,8 @@ public final class InventoryClickProcessor {
|
||||
}
|
||||
|
||||
public @NotNull InventoryClickResult doubleClick(@NotNull AbstractInventory clickedInventory, @NotNull AbstractInventory inventory, @NotNull Player player, int slot,
|
||||
@NotNull final ItemStack cursor) {
|
||||
InventoryClickResult clickResult = startCondition(player, inventory, slot, ClickType.START_DOUBLE_CLICK, ItemStack.AIR, cursor);
|
||||
@NotNull ItemStack clicked, @NotNull ItemStack cursor) {
|
||||
InventoryClickResult clickResult = startCondition(player, inventory, slot, ClickType.START_DOUBLE_CLICK, clicked, cursor);
|
||||
if (clickResult.isCancel()) return clickResult;
|
||||
if (cursor.isAir()) return clickResult.cancelled();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user