예제 #1
0
  @Override
  public boolean switchItem(
      EntityRef fromInventory,
      EntityRef instigator,
      int slotFrom,
      EntityRef toInventory,
      int slotTo) {
    if (!InventoryUtils.moveItem(instigator, fromInventory, slotFrom, toInventory, slotTo)) {
      return false;
    }

    MoveItemRequest request =
        new MoveItemRequest(instigator, fromInventory, slotFrom, toInventory, slotTo, changeId++);
    pendingMoves.put(request.getChangeId(), request);
    localPlayer.getClientEntity().send(request);

    return true;
  }
예제 #2
0
 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());
     }
   }
 }