Exemplo n.º 1
0
 public boolean storeItemToWorkbench(int index, Id id) {
   if (id.getByteValue() == Id.NONE.getByteValue()) return true;
   if (!currentInventory.getClass().equals(WorkbenchHandler.class)) {
     System.out.println("WB NOT OPEN");
     return false;
   } else {
     System.out.println("WB OPEN");
   }
   int itemIndex = ((WorkbenchHandler) currentInventory).getMyInventoryIndex(id);
   moveItem((short) itemIndex, (short) (index + 1), 1);
   return true;
 }
Exemplo n.º 2
0
 public boolean storeItemToChest(Id id, int count) {
   if (id.getByteValue() == Id.NONE.getByteValue()) return true;
   if (!currentInventory.getClass().equals(ChestHandler.class)) {
     System.out.println("Chest NOT OPEN");
     return false;
   } else {
     System.out.println("Chest OPEN");
   }
   int itemIndex = ((ChestHandler) currentInventory).getMyInventoryIndex(id);
   short chestAvailableIndex = ((ChestHandler) currentInventory).getFirstEmptyIndex(id, count);
   moveItem((short) itemIndex, chestAvailableIndex, count);
   return true;
 }
Exemplo n.º 3
0
 public boolean getItemFromChest(Id id) throws MinecraftException {
   if (id.getByteValue() == Id.NONE.getByteValue()) return true;
   if (!currentInventory.getClass().equals(ChestHandler.class)) {
     System.out.println("CHEST NOT OPEN");
     return false;
   } else {
     System.out.println("CHEST OPEN");
   }
   if (!isItemInChest(id)) throw new MinecraftException(ErrorMessage.M03);
   short itemIndex = currentInventory.getIndex(id);
   short emptyIndex = getFirstEmptyIndex();
   moveItem(itemIndex, emptyIndex, 1);
   return true;
 }
Exemplo n.º 4
0
 public boolean isItemInChest(Id id) throws MinecraftException {
   System.out.println(currentInventory.getClass() + "    " + ChestHandler.class);
   if (!currentInventory.getClass().equals(ChestHandler.class))
     throw new MinecraftException(ErrorMessage.M02);
   return ((ChestHandler) currentInventory).isItemInChest(id);
 }