private void recalculatePredictedState() { for (AbstractMoveItemRequest request : pendingMoves.values()) { if (request instanceof MoveItemRequest) { MoveItemRequest r = (MoveItemRequest) request; InventoryUtils.moveItem( r.getInstigator(), r.getFromInventory(), r.getFromSlot(), r.getToInventory(), r.getToSlot()); } else if (request instanceof MoveItemAmountRequest) { MoveItemAmountRequest r = (MoveItemAmountRequest) request; InventoryUtils.moveItemAmount( r.getInstigator(), r.getFromInventory(), r.getFromSlot(), r.getToInventory(), r.getToSlot(), r.getAmount()); } else if (request instanceof MoveItemToSlotsRequest) { MoveItemToSlotsRequest r = (MoveItemToSlotsRequest) request; InventoryUtils.moveItemToSlots( r.getInstigator(), r.getFromInventory(), r.getFromSlot(), r.getToInventory(), r.getToSlots()); } } }
@Override public boolean moveItemToSlots( EntityRef instigator, EntityRef fromInventory, int slotFrom, EntityRef toInventory, List<Integer> toSlots) { if (!InventoryUtils.moveItemToSlots( instigator, fromInventory, slotFrom, toInventory, toSlots)) { return false; } MoveItemToSlotsRequest request = new MoveItemToSlotsRequest( instigator, fromInventory, slotFrom, toInventory, toSlots, changeId++); pendingMoves.put(request.getChangeId(), request); localPlayer.getClientEntity().send(request); return true; }