Update BaseGUI.java

Fixed a bug that didn't let players put items inside a VirtualInventory if the whole stack didn't fit.
This commit is contained in:
NichtStudioCode 2021-07-18 14:17:59 +02:00
parent ac7302d606
commit b465bbc7de

@ -152,21 +152,14 @@ public abstract class BaseGUI implements GUI {
// if the cursor is empty, pick the stack up
if (inventory.setItemStack(updateReason, slot, null))
event.setCursor(clicked);
} else if (clicked == null) {
// if the clicked slot is empty, place the item on the cursor there
if (inventory.setItemStack(updateReason, slot, cursor))
} else if (clicked == null || cursor.isSimilar(clicked)) {
// if there are no items or they're similar to the cursor, add the cursor items to the stack
int remains = inventory.putItemStack(updateReason, slot, cursor);
if (remains == 0) {
event.setCursor(null);
} else if (cursor.isSimilar(clicked)) {
// if the items on the cursor are similar to the clicked ones, add them to the stack
int cursorAmount = cursor.getAmount();
int added = inventory.addItemAmount(updateReason, slot, cursorAmount);
if (added != 0) {
if (added == cursorAmount) {
event.setCursor(null);
} else {
cursor.setAmount(cursorAmount - added);
event.setCursor(cursor);
}
} else {
cursor.setAmount(remains);
event.setCursor(cursor);
}
} else if (!cursor.isSimilar(clicked)) {
// if the stacks are not similar, swap them