Esempio n. 1
0
 @Override
 public ItemStack removeResource(int maxAmount, EnumFacing outputFace, boolean simulate) {
   for (int i = 0; i < inventory.getSizeInventory(); i++) {
     if (inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).stackSize > 0) {
       justReceived[outputFace.ordinal()] = false;
       ItemStack resource = inventory.getStackInSlot(i).copy();
       if (resource.stackSize > maxAmount) {
         resource.stackSize = maxAmount;
         if (!simulate) {
           inventory.getStackInSlot(i).stackSize -= maxAmount;
         }
         return resource;
       }
       if (!simulate) inventory.setStackInSlot(null, i);
       return resource;
     }
   }
   return null;
 }
Esempio n. 2
0
 @Override
 public ItemStack acceptResource(
     int maxAmount, EnumFacing inputFace, ItemStack resource, boolean simulate) {
   if (resource != null && resource.stackSize > 0) {
     for (int i = 0; i < inventory.getSizeInventory(); i++) {
       if (inventory.getStackInSlot(i) == null) {
         ItemStack mover = resource.copy();
         if (mover.stackSize >= maxAmount) {
           mover.stackSize = maxAmount;
           if (!simulate) resource.stackSize -= mover.stackSize;
         } else if (mover.stackSize < maxAmount && !simulate) {
           resource.stackSize -= resource.stackSize;
         }
         if (!simulate) inventory.setStackInSlot(mover, i);
         return resource;
       }
     }
   }
   return null;
 }
Esempio n. 3
0
 public void removeDeadStacks() {
   for (int i = 0; i < inventory.getSizeInventory(); i++) {
     if (inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).stackSize <= 0)
       inventory.setStackInSlot(null, i);
   }
 }