Esempio n. 1
0
  public ItemStack checkInvent(ItemStack itemstack) {
    ItemStack result = null;
    if (worldObj.isRemote) return itemstack;
    this.update += 1;
    if (this.update % 8 == 0 && itemstack != null) {
      ItemStack emptyItem = itemstack.getItem().getContainerItemStack(itemstack);
      if (cargoItems[1] == null) {
        result = LiquidManager.getInstance().processContainer(this, 0, theTank, itemstack, 0);
      } else if (emptyItem != null) {
        if (cargoItems[1] != null && emptyItem.getItem().itemID == cargoItems[1].itemID) {
          if (cargoItems[1].stackSize + 1 < cargoItems[1].getMaxStackSize()) {
            result = LiquidManager.getInstance().processContainer(this, 0, theTank, itemstack, 0);
          }
        }
      } else {
        if (cargoItems[1] != null && itemstack.getItem().itemID == cargoItems[1].itemID) {
          if (cargoItems[1].stackSize + 1 <= cargoItems[1].getMaxStackSize()) {
            result = LiquidManager.getInstance().processContainer(this, 0, theTank, itemstack, 0);
          }
        }
      }

      if (result != null) {
        if (cargoItems[1] == null) {
          cargoItems[1] = result;
        } else if (cargoItems[1].getItem().itemID == result.itemID) {
          cargoItems[1].stackSize += 1;
        }
      }
    }
    return itemstack;
  }
Esempio n. 2
0
 private LiquidTank(
     FluidStack liquid, int capacity, World world, FluidStack filter, boolean reverseSort) {
   super(world);
   this.liquid = liquid;
   this.capacity = capacity;
   if (filter == null) this.theTank = LiquidManager.getInstance().new StandardTank(capacity);
   if (filter != null)
     this.theTank = LiquidManager.getInstance().new FilteredTank(capacity, filter);
   if (filter != null && reverseSort)
     this.theTank = LiquidManager.getInstance().new ReverseFilteredTank(capacity, filter);
   tankArray[0] = theTank;
   dataWatcher.addObject(4, new Integer(0));
   dataWatcher.addObject(22, new String(""));
 }
Esempio n. 3
0
 /**
  * Offers an ItemStack for addition to the inventory.
  *
  * @param stack ItemStack offered for addition. Do not manipulate this!
  * @param doAdd If false no actual addition should take place.
  * @param from Orientation the ItemStack is offered from.
  * @return Amount of items used from the passed stack.
  */
 @Override
 public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
   if (stack == null) {
     return 0;
   }
   if (LiquidManager.getInstance().isContainer(stack))
     return placeInSpecialInvent(stack, 0, doAdd);
   return 0;
 }