Fix shift click ghost item when click is cancelled

This commit is contained in:
TheMode 2021-04-26 01:35:44 +02:00
parent 47e7d35949
commit ec9658e7d3
2 changed files with 14 additions and 2 deletions

View File

@ -352,6 +352,10 @@ public class Inventory extends AbstractInventory implements Viewable {
playerInventory.setItemStack(clickSlot, clickResult.getClicked());
}
if(clickResult.doRefresh()){
update(player);
}
refreshPlayerCursorItem(player, clickResult.getCursor());
return !clickResult.isCancel();

View File

@ -187,7 +187,11 @@ public class InventoryClickProcessor {
var pair = TransactionType.ADD.process(targetInventory, clicked, (index, itemStack) -> {
InventoryClickResult result = startCondition(targetInventory, player, index, ClickType.SHIFT_CLICK, itemStack, cursor);
return !result.isCancel();
if(result.isCancel()){
clickResult.setRefresh(true);
return false;
}
return true;
});
ItemStack itemResult = TransactionOption.ALL.fill(targetInventory, pair.left(), pair.right());
@ -210,7 +214,11 @@ public class InventoryClickProcessor {
if (index == slot) // Prevent item lose/duplication
return false;
InventoryClickResult result = startCondition(targetInventory, player, index, ClickType.SHIFT_CLICK, itemStack, cursor);
return !result.isCancel();
if(result.isCancel()){
clickResult.setRefresh(true);
return false;
}
return true;
}, start, end, step);
ItemStack itemResult = TransactionOption.ALL.fill(targetInventory, pair.left(), pair.right());