Skip to content

Commit

Permalink
Implement quick move behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ustc-zzzz committed Aug 17, 2024
1 parent c626e58 commit fd188a6
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,28 @@ public static MenuType<?> create() {

@Override
public ItemStack quickMoveStack(Player player, int index) {
return ItemStack.EMPTY;
var projectHalfCapacity = ProjectorBlock.SLIDE_ITEM_HANDLER_CAPACITY;
var resultStack = ItemStack.EMPTY;
var slot = this.slots.get(index);
// noinspection ConstantValue
if (slot != null && slot.hasItem()) {
var slotStack = slot.getItem();
resultStack = slotStack.copy();
if (index < projectHalfCapacity * 2) {
if (!this.moveItemStackTo(slotStack, projectHalfCapacity * 2, this.slots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (!this.moveItemStackTo(slotStack, 0, projectHalfCapacity, false) &&
!this.moveItemStackTo(slotStack, projectHalfCapacity, projectHalfCapacity * 2, true)) {
return ItemStack.EMPTY;
}
if (slotStack.isEmpty()) {
slot.setByPlayer(ItemStack.EMPTY);
} else {
slot.setChanged();
}
}
return resultStack;
}

@Override
Expand Down

0 comments on commit fd188a6

Please sign in to comment.