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 moveItem( EntityRef fromInventory, EntityRef instigator, int slotFrom, EntityRef toInventory, int slotTo, int count) { if (!InventoryUtils.moveItemAmount( instigator, fromInventory, slotFrom, toInventory, slotTo, count)) { return false; } MoveItemAmountRequest request = new MoveItemAmountRequest( instigator, fromInventory, slotFrom, toInventory, slotTo, count, changeId++); pendingMoves.put(request.getChangeId(), request); localPlayer.getClientEntity().send(request); return true; }