mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Fix incorrect held click slot
This commit is contained in:
parent
5714d9db79
commit
5607652378
@ -131,19 +131,12 @@ public class InventoryClickProcessor {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public InventoryClickResult changeHeld(@Nullable Inventory inventory, @NotNull Player player, int slot, int key,
|
public InventoryClickResult changeHeld(@Nullable Inventory inventory, @NotNull Player player, int slot, int key,
|
||||||
@NotNull ItemStack clicked, @NotNull ItemStack cursor) {
|
@NotNull ItemStack clicked, @NotNull ItemStack cursor) {
|
||||||
|
// Verify the clicked item
|
||||||
InventoryClickResult clickResult = startCondition(inventory, player, slot, ClickType.CHANGE_HELD, clicked, cursor);
|
InventoryClickResult clickResult = startCondition(inventory, player, slot, ClickType.CHANGE_HELD, clicked, cursor);
|
||||||
|
if (clickResult.isCancel()) return clickResult;
|
||||||
if (clickResult.isCancel()) {
|
// Verify the destination (held bar)
|
||||||
return clickResult;
|
clickResult = startCondition(null, player, key, ClickType.CHANGE_HELD, clicked, cursor);
|
||||||
}
|
if (clickResult.isCancel()) return clickResult;
|
||||||
|
|
||||||
// Converted again during the inventory condition calling to internal slot
|
|
||||||
final int keySlot = PlayerInventoryUtils.convertToPacketSlot(key);
|
|
||||||
clickResult = startCondition(null, player, keySlot, ClickType.CHANGE_HELD, clicked, cursor);
|
|
||||||
|
|
||||||
if (clickResult.isCancel()) {
|
|
||||||
return clickResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor.isAir() && clicked.isAir()) {
|
if (cursor.isAir() && clicked.isAir()) {
|
||||||
clickResult.setCancel(true);
|
clickResult.setCancel(true);
|
||||||
@ -152,7 +145,6 @@ public class InventoryClickProcessor {
|
|||||||
|
|
||||||
ItemStack resultClicked;
|
ItemStack resultClicked;
|
||||||
ItemStack resultHeld;
|
ItemStack resultHeld;
|
||||||
|
|
||||||
if (clicked.isAir()) {
|
if (clicked.isAir()) {
|
||||||
// Set held item [key] to slot
|
// Set held item [key] to slot
|
||||||
resultClicked = cursor;
|
resultClicked = cursor;
|
||||||
@ -162,16 +154,14 @@ public class InventoryClickProcessor {
|
|||||||
// if held item [key] is air then set clicked to held
|
// if held item [key] is air then set clicked to held
|
||||||
resultClicked = ItemStack.AIR;
|
resultClicked = ItemStack.AIR;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise replace held item and held
|
// Otherwise, replace held item and held
|
||||||
resultClicked = cursor;
|
resultClicked = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
resultHeld = clicked;
|
resultHeld = clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
clickResult.setClicked(resultClicked);
|
clickResult.setClicked(resultClicked);
|
||||||
clickResult.setCursor(resultHeld);
|
clickResult.setCursor(resultHeld);
|
||||||
|
|
||||||
return clickResult;
|
return clickResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user