mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Fix inventory events not giving the proper inventory/slot
This commit is contained in:
parent
f26e6ef91f
commit
5cf358ac3c
@ -267,7 +267,8 @@ public class Inventory extends AbstractInventory implements Viewable {
|
||||
final boolean isInWindow = isClickInWindow(slot);
|
||||
final int clickSlot = isInWindow ? slot : PlayerInventoryUtils.convertSlot(slot, offset);
|
||||
final ItemStack clicked = isInWindow ? getItemStack(slot) : playerInventory.getItemStack(clickSlot);
|
||||
final InventoryClickResult clickResult = clickProcessor.leftClick(player, this, slot, clicked, cursor);
|
||||
final InventoryClickResult clickResult = clickProcessor.leftClick(player,
|
||||
isInWindow ? this : playerInventory, clickSlot, clicked, cursor);
|
||||
if (clickResult.isCancel()) {
|
||||
updateAll(player);
|
||||
return false;
|
||||
@ -289,7 +290,8 @@ public class Inventory extends AbstractInventory implements Viewable {
|
||||
final boolean isInWindow = isClickInWindow(slot);
|
||||
final int clickSlot = isInWindow ? slot : PlayerInventoryUtils.convertSlot(slot, offset);
|
||||
final ItemStack clicked = isInWindow ? getItemStack(slot) : playerInventory.getItemStack(clickSlot);
|
||||
final InventoryClickResult clickResult = clickProcessor.rightClick(player, this, slot, clicked, cursor);
|
||||
final InventoryClickResult clickResult = clickProcessor.rightClick(player,
|
||||
isInWindow ? this : playerInventory, clickSlot, clicked, cursor);
|
||||
if (clickResult.isCancel()) {
|
||||
updateAll(player);
|
||||
return false;
|
||||
@ -337,7 +339,8 @@ public class Inventory extends AbstractInventory implements Viewable {
|
||||
final int clickSlot = isInWindow ? slot : PlayerInventoryUtils.convertSlot(slot, offset);
|
||||
final ItemStack clicked = isInWindow ? getItemStack(slot) : playerInventory.getItemStack(clickSlot);
|
||||
final ItemStack heldItem = playerInventory.getItemStack(key);
|
||||
final InventoryClickResult clickResult = clickProcessor.changeHeld(player, this, slot, key, clicked, heldItem);
|
||||
final InventoryClickResult clickResult = clickProcessor.changeHeld(player,
|
||||
isInWindow ? this : playerInventory, clickSlot, key, clicked, heldItem);
|
||||
if (clickResult.isCancel()) {
|
||||
updateAll(player);
|
||||
return false;
|
||||
@ -368,8 +371,8 @@ public class Inventory extends AbstractInventory implements Viewable {
|
||||
final ItemStack clicked = outsideDrop ?
|
||||
ItemStack.AIR : (isInWindow ? getItemStack(slot) : playerInventory.getItemStack(clickSlot));
|
||||
final ItemStack cursor = getCursorItem(player);
|
||||
final InventoryClickResult clickResult = clickProcessor.drop(player, this,
|
||||
all, slot, button, clicked, cursor);
|
||||
final InventoryClickResult clickResult = clickProcessor.drop(player,
|
||||
isInWindow ? this : playerInventory, all, clickSlot, button, clicked, cursor);
|
||||
if (clickResult.isCancel()) {
|
||||
updateAll(player);
|
||||
return false;
|
||||
@ -395,8 +398,9 @@ public class Inventory extends AbstractInventory implements Viewable {
|
||||
(isInWindow ? getItemStack(slot) : playerInventory.getItemStack(clickSlot)) :
|
||||
ItemStack.AIR;
|
||||
final ItemStack cursor = getCursorItem(player);
|
||||
final InventoryClickResult clickResult = clickProcessor.dragging(player, this,
|
||||
slot, button,
|
||||
final InventoryClickResult clickResult = clickProcessor.dragging(player,
|
||||
isInWindow ? this : playerInventory,
|
||||
clickSlot, button,
|
||||
clicked, cursor,
|
||||
|
||||
s -> isClickInWindow(s) ? getItemStack(s) :
|
||||
|
@ -6,7 +6,6 @@ import net.minestom.server.listener.manager.PacketListenerManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class ClientPlayPacket implements ClientPacket {
|
||||
|
||||
private static final PacketListenerManager PACKET_LISTENER_MANAGER = MinecraftServer.getPacketListenerManager();
|
||||
|
||||
/**
|
||||
@ -19,5 +18,4 @@ public abstract class ClientPlayPacket implements ClientPacket {
|
||||
public void process(@NotNull Player player) {
|
||||
PACKET_LISTENER_MANAGER.processClientPacket(this, player);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user