Esempio n. 1
0
  @Override
  protected void mergeCaches(
      List<ItemStack> rejectedItems,
      MultiblockCache<SynchronizedMatrixData> cache,
      MultiblockCache<SynchronizedMatrixData> merge) {
    List<ItemStack> rejects =
        StackUtils.getMergeRejects(
            ((MatrixCache) cache).inventory, ((MatrixCache) merge).inventory);

    if (!rejects.isEmpty()) {
      rejectedItems.addAll(rejects);
    }

    StackUtils.merge(((MatrixCache) cache).inventory, ((MatrixCache) merge).inventory);
  }
Esempio n. 2
0
  /**
   * Whether or not this PressurizedReactants's ItemStack entry's item type is equal to the item
   * type of the given item.
   *
   * @param stack - stack to check
   * @return if the stack's item type is contained in this PressurizedReactants
   */
  public boolean containsType(ItemStack stack) {
    if (stack == null || stack.stackSize == 0) {
      return false;
    }

    return StackUtils.equalsWildcard(stack, theSolid);
  }
Esempio n. 3
0
  public void setItemType(ItemStack stack) {
    if (stack == null) {
      ItemDataUtils.removeData(bin, "storedItem");
      return;
    }

    ItemDataUtils.setCompound(
        bin, "storedItem", StackUtils.size(stack, 1).writeToNBT(new NBTTagCompound()));
  }
Esempio n. 4
0
 public boolean use(
     ItemStack[] inventory, int index, FluidTank fluidTank, GasTank gasTank, boolean deplete) {
   if (meets(new PressurizedInput(inventory[index], fluidTank.getFluid(), gasTank.getGas()))) {
     if (deplete) {
       inventory[index] = StackUtils.subtract(inventory[index], theSolid);
       fluidTank.drain(theFluid.amount, true);
       gasTank.draw(theGas.amount, true);
     }
     return true;
   }
   return false;
 }
Esempio n. 5
0
  private boolean smeltItem(EntityItem item) {
    ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(item.getEntityItem());

    if (result != null) {
      item.setEntityItemStack(StackUtils.size(result, item.getEntityItem().stackSize));
      item.ticksExisted = 0;

      spawnParticlesAt(new Pos3D(item));
      worldObj.playSoundAtEntity(item, "random.fizz", 1.0F, 1.0F);

      return true;
    }

    return false;
  }
Esempio n. 6
0
  /**
   * Actual implementation of meetsInput(), performs the checks.
   *
   * @param input - input to check
   * @return if the input meets this input's requirements
   */
  public boolean meets(PressurizedInput input) {
    if (input == null || !input.isValid()) {
      return false;
    }

    if (!(StackUtils.equalsWildcard(input.theSolid, theSolid)
        && input.theFluid.isFluidEqual(theFluid)
        && input.theGas.isGasEqual(theGas))) {
      return false;
    }

    return input.theSolid.stackSize >= theSolid.stackSize
        && input.theFluid.amount >= theFluid.amount
        && input.theGas.amount >= theGas.amount;
  }
Esempio n. 7
0
 @Override
 public int hashIngredients() {
   return StackUtils.hashItemStack(theSolid) << 16
       | (theFluid.getFluid() != null ? theFluid.getFluid().hashCode() : 0) << 8
       | theGas.hashCode();
 }