コード例 #1
0
 @Override
 public boolean isStackValidForSlot(int slot, ItemStack itemstack) {
   if (itemstack == null) {
     return false;
   }
   for (int i = 0; i < 9; i++) {
     if (i != slot
         && _inventory[i] != null
         && UtilInventory.stacksEqual(_inventory[i], itemstack)) {
       return false;
     }
   }
   return true;
 }
	public boolean doDrop(ItemStack drop)
	{
		drop = UtilInventory.dropStack(this, drop, this.getDropDirections(), this.getDropDirection());
		if (drop != null && drop.stackSize > 0)
		{
			if (failedDrops == null)
			{
				failedDrops = new ArrayList<ItemStack>();
			}
			failedDrops.add(drop);
			onInventoryChanged();
		}
		return true;
	}
コード例 #3
0
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (!worldObj.isRemote) {
      for (int i = 0; i < 9; i++) {
        if (_inventory[i] != null
            && MFRRegistry.getPlantables().containsKey(_inventory[i].itemID)) {
          int targetSlot = findMatchingSlot(_inventory[i]);
          if (targetSlot < 0) {
            continue;
          }

          if (_inventory[targetSlot] == null) {
            _inventory[targetSlot] = _inventory[i];
            _inventory[i] = null;
          } else {
            UtilInventory.mergeStacks(_inventory[targetSlot], _inventory[i]);
            if (_inventory[i].stackSize <= 0) {
              _inventory[i] = null;
            }
          }
        }
      }

      if (Util.isRedstonePowered(this)) {
        return;
      }

      int newBurn = getOutputValue();
      if (_burnTimeMax - _burnTime >= newBurn) {
        _burnTime += newBurn;
        for (int i = 9; i < 18; i++) {
          if (_inventory[i] != null) {
            decrStackSize(i, 1);
          }
        }
      }

      if (_burnTime > 0
          && (_tank.getLiquid() == null
              || _tank.getLiquid().amount <= _tank.getCapacity() - _bioFuelPerTick)) {
        _burnTime -= _burnTimeDecreasePerTick;
        _tank.fill(LiquidDictionary.getLiquid("biofuel", _bioFuelPerTick), true);
      }
    }
  }
	public boolean doDrop(List<ItemStack> drops)
	{
		if (drops == null || drops.size() <= 0)
		{
			return true;
		}
		List<ItemStack> missed = missedDrops;
		missed.clear();
		for (int i = drops.size(); i --> 0; )
		{
			ItemStack dropStack = drops.get(i);
			dropStack = UtilInventory.dropStack(this, dropStack, this.getDropDirections(), this.getDropDirection());
			if (dropStack != null && dropStack.stackSize > 0)
			{
				missed.add(dropStack);
			}
		}
		
		if (missed.size() != 0)
		{
			if (drops != failedDrops)
			{
				if (failedDrops == null)
				{
					failedDrops = new ArrayList<ItemStack>(missed.size());
				}
				failedDrops.addAll(missed);
			}
			else
			{
				failedDrops.clear();
				failedDrops.addAll(missed);
			}
			onInventoryChanged();
			return false;
		}
		
		return true;
	}
	@Override
	public boolean isItemValidForSlot(int i, ItemStack itemstack)
	{
		ItemStack slotContent = this.getStackInSlot(i);
		return slotContent == null || UtilInventory.stacksEqual(itemstack, slotContent);
	}