mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +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
|
@Override
|
||||||
public boolean doubleClick(@NotNull Player player, int slot) {
|
public boolean doubleClick(@NotNull Player player, int slot) {
|
||||||
final PlayerInventory playerInventory = player.getInventory();
|
final PlayerInventory playerInventory = player.getInventory();
|
||||||
final ItemStack cursor = getCursorItem(player);
|
|
||||||
final boolean isInWindow = isClickInWindow(slot);
|
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,
|
final InventoryClickResult clickResult = clickProcessor.doubleClick(isInWindow ? this : playerInventory,
|
||||||
this, player, slot, cursor);
|
this, player, slot, clicked, cursor);
|
||||||
if (clickResult.isCancel()) {
|
if (clickResult.isCancel()) {
|
||||||
updateAll(player);
|
updateAll(player);
|
||||||
return false;
|
return false;
|
||||||
|
@ -363,7 +363,8 @@ public class PlayerInventory extends AbstractInventory implements EquipmentHandl
|
|||||||
@Override
|
@Override
|
||||||
public boolean doubleClick(@NotNull Player player, int slot) {
|
public boolean doubleClick(@NotNull Player player, int slot) {
|
||||||
final ItemStack cursor = getCursorItem();
|
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()) {
|
if (clickResult.isCancel()) {
|
||||||
update();
|
update();
|
||||||
return false;
|
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,
|
public @NotNull InventoryClickResult doubleClick(@NotNull AbstractInventory clickedInventory, @NotNull AbstractInventory inventory, @NotNull Player player, int slot,
|
||||||
@NotNull final ItemStack cursor) {
|
@NotNull ItemStack clicked, @NotNull ItemStack cursor) {
|
||||||
InventoryClickResult clickResult = startCondition(player, inventory, slot, ClickType.START_DOUBLE_CLICK, ItemStack.AIR, cursor);
|
InventoryClickResult clickResult = startCondition(player, inventory, slot, ClickType.START_DOUBLE_CLICK, clicked, cursor);
|
||||||
if (clickResult.isCancel()) return clickResult;
|
if (clickResult.isCancel()) return clickResult;
|
||||||
if (cursor.isAir()) return clickResult.cancelled();
|
if (cursor.isAir()) return clickResult.cancelled();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user