@Override
public boolean onShiftClick(ItemStack stack, int slot, Inventory from) {
if (getPlayer().getEngine().getPlatform() == Platform.CLIENT) {
throw new IllegalStateException("Shift click handling is handled server side.");
}
final PlayerInventory inventory = getPlayerInventory();
// From main inventory/quickbar to the dispenser
if (from instanceof PlayerMainInventory || from instanceof QuickbarInventory) {
for (InventoryConverter conv : this.getInventoryConverters()) {
Inventory inv = conv.getInventory();
if (inv instanceof DispenserInventory) {
Grid grid = inv.grid(3);
final int height = grid.getHeight();
final int length = grid.getLength();
for (int row = height - 1; row >= 0; row--) {
int startSlot = length * row;
int endSlot = startSlot + length - 1;
inv.add(startSlot, endSlot, stack);
from.set(slot, stack);
if (stack.isEmpty()) {
return true;
}
}
}
}
}
// From chest to inventory/quickbar
if (from instanceof DispenserInventory) {
// To quickbar (reversed)
final QuickbarInventory qbar = inventory.getQuickbar();
qbar.add(qbar.size() - 1, 0, stack);
from.set(slot, stack);
if (stack.isEmpty()) {
return true;
}
// To main inventory (reversed)
final Inventory main = inventory.getMain();
for (int row = 0; row < PlayerMainInventory.HEIGHT; row++) {
int startSlot = PlayerMainInventory.LENGTH * row;
int endSlot = startSlot + PlayerMainInventory.LENGTH - 1;
main.add(endSlot, startSlot, stack);
from.set(slot, stack);