mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 17:37:42 +01:00
Change dragging events
Now fires a start dragging, then a dragging for each slot and then an end dragging.
This commit is contained in:
parent
cd319b047c
commit
ddbd621535
@ -15,6 +15,9 @@ public enum ClickType {
|
||||
LEFT_DRAGGING,
|
||||
RIGHT_DRAGGING,
|
||||
|
||||
END_LEFT_DRAGGING,
|
||||
END_RIGHT_DRAGGING,
|
||||
|
||||
START_DOUBLE_CLICK,
|
||||
DOUBLE_CLICK,
|
||||
|
||||
|
@ -261,9 +261,6 @@ public class InventoryClickProcessor {
|
||||
final int slotSize = (int) ((float) cursorAmount / (float) slotCount);
|
||||
int finalCursorAmount = cursorAmount;
|
||||
|
||||
// Set to a value in case there are no slots
|
||||
clickResult = startCondition(inventory, player, slot, ClickType.START_LEFT_DRAGGING, clicked, cursor);
|
||||
|
||||
for (int s : slots) {
|
||||
ItemStack slotItem = itemGetter.apply(s);
|
||||
|
||||
@ -291,8 +288,14 @@ public class InventoryClickProcessor {
|
||||
|
||||
callClickEvent(player, inventory, s, ClickType.LEFT_DRAGGING, slotItem, cursor);
|
||||
}
|
||||
cursor = stackingRule.apply(cursor, finalCursorAmount);
|
||||
clickResult.setCursor(cursor);
|
||||
|
||||
// If no slots were dragged over, no need to apply any kind of stacking rules
|
||||
if (clickResult != null) {
|
||||
cursor = stackingRule.apply(cursor, finalCursorAmount);
|
||||
clickResult.setCursor(cursor);
|
||||
}
|
||||
|
||||
clickResult = startCondition(inventory, player, slot, ClickType.END_LEFT_DRAGGING, clicked, cursor);
|
||||
|
||||
leftDraggingMap.remove(player);
|
||||
} else if (button == 6) {
|
||||
@ -305,9 +308,6 @@ public class InventoryClickProcessor {
|
||||
if (size > cursorAmount)
|
||||
return null;
|
||||
|
||||
// Set to a value in case there are no slots
|
||||
clickResult = startCondition(inventory, player, slot, ClickType.START_RIGHT_DRAGGING, clicked, cursor);
|
||||
|
||||
for (int s : slots) {
|
||||
ItemStack draggedItem = cursor;
|
||||
ItemStack slotItem = itemGetter.apply(s);
|
||||
@ -332,8 +332,14 @@ public class InventoryClickProcessor {
|
||||
|
||||
callClickEvent(player, inventory, s, ClickType.RIGHT_DRAGGING, draggedItem, cursor);
|
||||
}
|
||||
cursor = stackingRule.apply(cursor, cursorAmount);
|
||||
clickResult.setCursor(cursor);
|
||||
|
||||
// If no slots were dragged over, no need to apply any kind of stacking rules
|
||||
if (clickResult != null) {
|
||||
cursor = stackingRule.apply(cursor, cursorAmount);
|
||||
clickResult.setCursor(cursor);
|
||||
}
|
||||
|
||||
clickResult = startCondition(inventory, player, slot, ClickType.END_RIGHT_DRAGGING, clicked, cursor);
|
||||
|
||||
rightDraggingMap.remove(player);
|
||||
|
||||
@ -346,15 +352,11 @@ public class InventoryClickProcessor {
|
||||
return null;
|
||||
leftDraggingMap.get(player).add(slot);
|
||||
|
||||
clickResult = startCondition(inventory, player, slot, ClickType.START_LEFT_DRAGGING, clicked, cursor);
|
||||
|
||||
} else if (button == 5) {
|
||||
// Add right slot
|
||||
if (!rightDraggingMap.containsKey(player))
|
||||
return null;
|
||||
rightDraggingMap.get(player).add(slot);
|
||||
|
||||
clickResult = startCondition(inventory, player, slot, ClickType.START_RIGHT_DRAGGING, clicked, cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user