Package cofh.api.energy

Examples of cofh.api.energy.IEnergyContainerItem


    int available = Math.min(maxIO, getEnergyStored());
    for (ItemStack item : items) {
      if(item != null && available > 0) {
        int used = 0;
        if(item.getItem() instanceof IEnergyContainerItem) {
          IEnergyContainerItem chargable = (IEnergyContainerItem) item.getItem();

          int max = chargable.getMaxEnergyStored(item);
          int cur = chargable.getEnergyStored(item);
          int canUse = Math.min(available, max - cur);
          if(cur < max) {
            used = chargable.receiveEnergy(item, (int) canUse, false);
          }

        }
        if(used > 0) {
          setEnergyStored(getEnergyStored() - used);
View Full Code Here


    }
    if(! (item.getItem() instanceof IEnergyContainerItem) ) {
      return null;
    }

    IEnergyContainerItem ci = (IEnergyContainerItem)item.getItem();
    return Lang.localize("item.tooltip.power")+ " "+ PowerDisplayUtil.formatPower(ci.getEnergyStored(item)) + "/"
    + PowerDisplayUtil.formatPower(ci.getMaxEnergyStored(item)) + " " + PowerDisplayUtil.abrevation();
  }
View Full Code Here

    double dispDamage = item.getItemDamageForDisplay();
    y = hasEnergyUpgrade ? 14 : 13;
    renderBar(y, maxDam, dispDamage, Color.green, Color.red);

    if(hasEnergyUpgrade) {
      IEnergyContainerItem armor = (IEnergyContainerItem) item.getItem();
      maxDam = armor.getMaxEnergyStored(item);
      dispDamage = armor.getEnergyStored(item);
      y = 12;
      Color color = new Color(0x2D, 0xCE, 0xFA); // electric blue
      renderBar2(y, maxDam, maxDam - dispDamage, color, color);
    }
View Full Code Here

    boolean extracted = false;
    int remaining = cost;
    if(Config.darkSteelDrainPowerFromInventory) {
      for (ItemStack stack : player.inventory.mainInventory) {
        if(stack != null && stack.getItem() instanceof IEnergyContainerItem) {
          IEnergyContainerItem cont = (IEnergyContainerItem) stack.getItem();
          int used = cont.extractEnergy(stack, remaining, false);
          remaining -= used;
          extracted |= used > 0;
          if(remaining <= 0) {   
            return;
          }
View Full Code Here

    int res = 0;

    if(Config.darkSteelDrainPowerFromInventory) {
      for (ItemStack stack : player.inventory.mainInventory) {
        if(stack != null && stack.getItem() instanceof IEnergyContainerItem) {
          IEnergyContainerItem cont = (IEnergyContainerItem) stack.getItem();
          res += cont.extractEnergy(stack, Integer.MAX_VALUE, true);
        }
      }
    }
    if(armor != null) {
      ItemStack stack = player.inventory.armorInventory[3 - armor.armorType];
View Full Code Here

    int available = Math.min(MAX_ENERGY_OUT, storedEnergyRF);
    for (ItemStack item : items) {
      if(item != null && available > 0) {
        int used = 0;
        if(item.getItem() instanceof IEnergyContainerItem) {
          IEnergyContainerItem chargable = (IEnergyContainerItem) item.getItem();

          int max = chargable.getMaxEnergyStored(item);
          int cur = chargable.getEnergyStored(item);
          int canUse = Math.min(available, max - cur);
          if(cur < max) {
            used = chargable.receiveEnergy(item, (int) canUse, false);
          }
        }
        if(used > 0) {
          storedEnergyRF = storedEnergyRF - used;
          chargedItem = true;
View Full Code Here

        double sent = ElectricItem.manager.charge(itemstack, (int)(getEnergy()*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2;
        setEnergy(getEnergy() - sent);
      }
      else if(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem)
      {
        IEnergyContainerItem item = (IEnergyContainerItem)itemstack.getItem();

        int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemstack)), item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack)));
        int toTransfer = (int)Math.round(Math.min(itemEnergy, (getEnergy()*Mekanism.TO_TE)));

        setEnergy(getEnergy() - (item.receiveEnergy(itemstack, toTransfer, false)*Mekanism.FROM_TE));
      }
    }
  }
 
View Full Code Here

        storer.setEnergy(storer.getEnergy() - sent);
      }
      else if(MekanismUtils.useRF() && storer.inventory[slotID].getItem() instanceof IEnergyContainerItem)
      {
        ItemStack itemStack = storer.inventory[slotID];
        IEnergyContainerItem item = (IEnergyContainerItem)storer.inventory[slotID].getItem();

        int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getMaxEnergyStored(itemStack) - item.getEnergyStored(itemStack)));
        int toTransfer = (int)Math.round(Math.min(itemEnergy, (storer.getEnergy()*Mekanism.TO_TE)));

        storer.setEnergy(storer.getEnergy() - (item.receiveEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE));
      }
    }
  }
 
View Full Code Here

    public void convert(final Object value, final Map<Object, Object> output) {
        if (value instanceof ItemStack) {
            final ItemStack stack = (ItemStack) value;
            final Item item = stack.getItem();
            if (item instanceof IEnergyContainerItem) {
                final IEnergyContainerItem energyItem = (IEnergyContainerItem) item;
                output.put("energy", energyItem.getEnergyStored(stack));
                output.put("maxEnergy", energyItem.getMaxEnergyStored(stack));
            }
        }
    }
View Full Code Here

          }
        }
        else if(MekanismUtils.useRF() && inventory[27].getItem() instanceof IEnergyContainerItem)
        {
          ItemStack itemStack = inventory[27];
          IEnergyContainerItem item = (IEnergyContainerItem)inventory[27].getItem();

          int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getEnergyStored(itemStack)));
          int toTransfer = (int)Math.round(Math.min(itemEnergy, ((MAX_ELECTRICITY - getEnergy())*Mekanism.TO_TE)));

          setEnergy(getEnergy() + (item.extractEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE));
        }
        else if(inventory[27].getItem() == Items.redstone && getEnergy()+Mekanism.ENERGY_PER_REDSTONE <= MAX_ELECTRICITY)
        {
          setEnergy(getEnergy() + Mekanism.ENERGY_PER_REDSTONE);
          inventory[27].stackSize--;
View Full Code Here

TOP

Related Classes of cofh.api.energy.IEnergyContainerItem

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.