Package pneumaticCraft.common.thirdparty.ic2

Examples of pneumaticCraft.common.thirdparty.ic2.IC2


  public boolean isItemValid(int slot, ItemStack stack)
  {
    // Decide if the item is a valid IC2 electrical item
    if (stack != null && stack.getItem() instanceof IElectricItem)
    {
      IElectricItem item = (IElectricItem)(stack.getItem());
      // Is the item appropriate for this slot?
      if (slot == Info.CB_SLOT_POWER_SOURCE && item.canProvideEnergy(stack) && item.getTier(stack) <= powerTier) return true;
      if (slot >= Info.CB_SLOT_CHARGING && slot < Info.CB_SLOT_CHARGING + 12 && item.getTier(stack) <= baseTier) return true;
      if (slot >= Info.CB_SLOT_UPGRADE && slot < Info.CB_SLOT_UPGRADE + 4 && (stack.isItemEqual(Info.ic2overclockerUpg) || stack.isItemEqual(Info.ic2transformerUpg) || stack.isItemEqual(Info.ic2storageUpg))) return true;
      if (slot == Info.CB_SLOT_INPUT && item.getTier(stack) <= baseTier) return true;
      if (slot == Info.CB_SLOT_OUTPUT) return true; // GUI won't allow placement of items here, but if the bench or an external machine does, it should at least let it sit there as long as it's an electrical item.
    }
    return false;
  }
View Full Code Here


    int chargeReturned = 0;

    ItemStack stack = getStackInSlot(Info.CB_SLOT_POWER_SOURCE);
    if (stack != null && stack.getItem() instanceof IElectricItem && currentEnergy < adjustedStorage)
    {
      IElectricItem powerSource = (IElectricItem)(stack.getItem());

      int emptyItemID = powerSource.getEmptyItemId(stack);
      int chargedItemID = powerSource.getChargedItemId(stack);

      if (stack.itemID == chargedItemID)
      {
        if (powerSource.getTier(stack) <= powerTier && powerSource.canProvideEnergy(stack))
        {
          int itemTransferLimit = powerSource.getTransferLimit(stack);
          int energyNeeded = adjustedStorage - currentEnergy;

          // Test if the amount of energy we have room for is greater than what the item can transfer per tick.
          if (energyNeeded > itemTransferLimit)
          {
View Full Code Here

    for (int i = Info.CB_SLOT_CHARGING; i < Info.CB_SLOT_CHARGING + 12; i++)
    {
      ItemStack stack = contents[i];
      if (stack != null && stack.getItem() instanceof IElectricItem && stack.stackSize == 1)
      {
        IElectricItem item = (IElectricItem)(stack.getItem());
        if (item.getTier(stack) <= baseTier)
        {
          int itemTransferLimit = item.getTransferLimit(stack);
          if (itemTransferLimit == 0) itemTransferLimit = baseMaxInput;
          int adjustedTransferLimit = (int)Math.ceil(chargeFactor * itemTransferLimit);
          int amountNeeded;
          int missing;
          int consumption;
          if (item.getChargedItemId(stack) != item.getEmptyItemId(stack) || stack.isStackable())
          {
            // Running stack.copy() on every item every tick would be a horrible thing for performance, but the workaround is needed
            // for ElectricItem.charge adding stackTagCompounds for charge level to EmptyItemID batteries even when run in simulate mode.
            // Limiting its use by what is hopefully a broad enough test to catch all cases where it's necessary in order to avoid problems.
            // Using it for any item types listed as stackable and for any items where the charged and empty item IDs differ.
            final ItemStack stackCopy = stack.copy();
            amountNeeded = ElectricItem.charge(stackCopy, adjustedTransferLimit, baseTier, true, true);
            if (amountNeeded == adjustedTransferLimit)
            {
              missing = ElectricItem.charge(stackCopy, item.getMaxCharge(stackCopy), baseTier, true, true);
            }
            else missing = amountNeeded;
          }
          else
          {
            amountNeeded = ElectricItem.charge(stack, adjustedTransferLimit, baseTier, true, true);
            if (amountNeeded == adjustedTransferLimit)
            {
              missing = ElectricItem.charge(stack, item.getMaxCharge(stack), baseTier, true, true);
            }
            else missing = amountNeeded;
          }

          // How long will this item take and how much will it drain?
View Full Code Here

  {
    ItemStack stack = contents[Info.CB_SLOT_INPUT];
    if (stack != null && stack.getItem() instanceof IElectricItem)
    {
      // Input slot contains something electrical. If possible, move one of it into the charging area.
      IElectricItem item = (IElectricItem)(stack.getItem());
      for (int slot = Info.CB_SLOT_CHARGING; slot < Info.CB_SLOT_CHARGING + 12; ++slot)
      {
        if (contents[slot] == null)
        {
          // Grab one unit from input and move it to the selected slot.
View Full Code Here

  public boolean isItemValid(int slot, ItemStack stack)
  {
    // Decide if the item is a valid IC2 electrical item
    if (stack != null && stack.getItem() instanceof IElectricItem)
    {
      IElectricItem item = (IElectricItem)(stack.getItem());
      // Is the item appropriate for this slot?
      if (slot == Info.BS_SLOT_OUTPUT) return true; // GUI won't allow placement of items here, but if the bench or an external machine does, it should at least let it sit there as long as it's an electrical item.
      if (item.canProvideEnergy(stack) && item.getTier(stack) <= powerTier)
      {
        if ((slot >= Info.BS_SLOT_POWER_START && slot < Info.BS_SLOT_POWER_START + 12) || slot == Info.BS_SLOT_INPUT) return true;
      }
    }
    return false;
View Full Code Here

      }

      ItemStack stack = contents[i];
      if (stack != null && stack.getItem() instanceof IElectricItem && stack.stackSize == 1)
      {
        IElectricItem item = (IElectricItem)(stack.getItem());
        if (item.getTier(stack) <= powerTier && item.canProvideEnergy(stack))
        {
          int emptyItemID = item.getEmptyItemId(stack);
          int chargedItemID = item.getChargedItemId(stack);

          if (stack.itemID == chargedItemID)
          {
            int transferLimit = item.getTransferLimit(stack);
            //int amountNeeded = baseMaxOutput - currentEnergy;
            if (transferLimit == 0) transferLimit = packetSize;
            //if (transferLimit > amountNeeded) transferLimit = amountNeeded;

            int chargeReturned = ElectricItem.discharge(stack, transferLimit, powerTier, false, false);
View Full Code Here

        if (slot == Info.BS_SLOT_OUTPUT) continue;

        ItemStack currentStack = contents[slot];
        if (currentStack != null && currentStack.getItem() instanceof IElectricItem)
        {
          IElectricItem powerSource = (IElectricItem)(currentStack.getItem());
          if (powerSource.getTier(currentStack) <= powerTier) // && powerSource.canProvideEnergy()
          {
            int emptyItemID = powerSource.getEmptyItemId(currentStack);
            int chargedItemID = powerSource.getChargedItemId(currentStack);
            if (emptyItemID != chargedItemID)
            {
              if (currentStack.itemID == emptyItemID)
              {
                // Pick Me
View Full Code Here

  {
    //System.out.println("aII: opMode " + opMode);
    ItemStack stack = contents[Info.BS_SLOT_INPUT];
    if (stack == null || !(stack.getItem() instanceof IElectricItem) || (opMode == 1 && hasEnoughItems)) return;

    IElectricItem item = (IElectricItem)stack.getItem();
    if (item.canProvideEnergy(stack))
    {
      // Input slot contains a power source. If possible, move one of it into the discharging area.
      for (int slot = Info.BS_SLOT_POWER_START; slot < Info.BS_SLOT_POWER_START + 12; ++slot)
      {
        if (contents[slot] == null)
View Full Code Here

      if (i == Info.BS_SLOT_OUTPUT) continue;

      final ItemStack stack = contents[i];
      if (stack != null && stack.getItem() instanceof IElectricItem && stack.stackSize == 1)
      {
        final IElectricItem item = (IElectricItem)(stack.getItem());
        if (item.getTier(stack) <= powerTier && item.canProvideEnergy(stack) && stack.itemID == item.getChargedItemId(stack))
        {
          final int chargeReturned = ElectricItem.discharge(stack, Integer.MAX_VALUE, powerTier, true, true);
          if (chargeReturned > 0)
          {
            // Add the energy we received to our current energy level
View Full Code Here

  public static boolean isItemChargeable(ItemStack stack, int tier)
  {
    // Decide if the item is a valid IC2 electrical item
    if (stack != null && stack.getItem() instanceof IElectricItem)
    {
      IElectricItem item = (IElectricItem)(stack.getItem());
      if (item.getTier(stack) <= tier) return true;
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of pneumaticCraft.common.thirdparty.ic2.IC2

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.