Beispiel #1
0
 @Override
 public void writeToNBT(NBTTagCompound tag) {
   inventory.writeToNBT(tag, "");
   for (int i = 0; i < 6; i++) {
     tag.setBoolean("InsertSide" + String.valueOf(i), insertSides[i]);
     tag.setBoolean("ExtractSide" + String.valueOf(i), extractSides[i]);
   }
 }
Beispiel #2
0
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   inventory.readFromNBT(tag, 6, "");
   insertSides = new boolean[6];
   extractSides = new boolean[6];
   for (int i = 0; i < 6; i++) {
     insertSides[i] = tag.getBoolean("InsertSide" + String.valueOf(i));
     extractSides[i] = tag.getBoolean("ExtractSide" + String.valueOf(i));
   }
 }
Beispiel #3
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;
 }
Beispiel #4
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;
 }
Beispiel #5
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);
   }
 }