mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
Fix double click result handling
This commit is contained in:
parent
4d2dd7d256
commit
1f60330abe
@ -405,7 +405,8 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
|
||||
}
|
||||
|
||||
if (isInWindow) {
|
||||
setItemStack(slot, clickResult.getClicked());
|
||||
// if (clickResult.isCancel())
|
||||
setItemStack(slot, clickResult.getClicked());
|
||||
} else {
|
||||
playerInventory.setItemStack(slot, offset, clickResult.getClicked());
|
||||
}
|
||||
@ -564,7 +565,7 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
|
||||
public boolean dragging(@NotNull Player player, int slot, int button) {
|
||||
final PlayerInventory playerInventory = player.getInventory();
|
||||
final boolean isInWindow = isClickInWindow(slot);
|
||||
final ItemStack clicked = slot != 999 ?
|
||||
final ItemStack clicked = slot != -999 ?
|
||||
(isInWindow ? getItemStack(slot) : playerInventory.getItemStack(slot, offset)) :
|
||||
ItemStack.getAirItem();
|
||||
final ItemStack cursor = getCursorItem(player);
|
||||
@ -611,13 +612,8 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
|
||||
// Looping through player inventory
|
||||
new InventoryClickLoopHandler(0, PlayerInventory.INVENTORY_SIZE - 9, 1,
|
||||
PlayerInventoryUtils::convertToPacketSlot,
|
||||
index -> playerInventory.getItemStack(index, offset),
|
||||
(index, itemStack) -> playerInventory.setItemStack(index, offset, itemStack)),
|
||||
// Player hot bar
|
||||
new InventoryClickLoopHandler(0, 9, 1,
|
||||
PlayerInventoryUtils::convertToPacketSlot,
|
||||
index -> playerInventory.getItemStack(index, offset),
|
||||
(index, itemStack) -> playerInventory.setItemStack(index, offset, itemStack)));
|
||||
index -> playerInventory.getItemStack(index, 9),
|
||||
(index, itemStack) -> playerInventory.setItemStack(index, 9, itemStack)));
|
||||
|
||||
if (clickResult == null)
|
||||
return false;
|
||||
|
@ -49,7 +49,7 @@ public final class PlayerInventoryUtils {
|
||||
case 8:
|
||||
return BOOTS_SLOT;
|
||||
}
|
||||
//System.out.println("ENTRY: " + slot + " | " + offset);
|
||||
System.out.println("ENTRY: " + slot + " | " + offset);
|
||||
final int rowSize = 9;
|
||||
slot -= offset;
|
||||
if (slot >= rowSize * 3 && slot < rowSize * 4) {
|
||||
@ -57,7 +57,7 @@ public final class PlayerInventoryUtils {
|
||||
} else {
|
||||
slot = slot + rowSize;
|
||||
}
|
||||
//System.out.println("CONVERT: " + slot);
|
||||
System.out.println("CONVERT: " + slot);
|
||||
return slot;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public final class PlayerInventoryUtils {
|
||||
* @return a slot id which can be used for packets
|
||||
*/
|
||||
public static int convertToPacketSlot(int slot) {
|
||||
if (slot > -1 && slot < 9) { // Held bar 0-9
|
||||
if (slot > -1 && slot < 9) { // Held bar 0-8
|
||||
slot = slot + 36;
|
||||
} else if (slot > 8 && slot < 36) { // Inventory 9-35
|
||||
slot = slot;
|
||||
|
Loading…
Reference in New Issue
Block a user