Package ic2.api.recipe

Examples of ic2.api.recipe.ICannerBottleRecipeManager$Input


  public static boolean isItemDrainable(ItemStack stack, int tier)
  {
    // Decide if the item is a valid IC2 power source
    if (stack != null && stack.getItem() instanceof IElectricItem)
    {
      IElectricItem item = (IElectricItem)(stack.getItem());
      if (item.canProvideEnergy(stack) && item.getTier(stack) <= tier) return true;
    }
    return false;
  }
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 IElectricItem) {
                final IElectricItem electricItem = (IElectricItem) item;
                output.put("canProvideEnergy", electricItem.canProvideEnergy(stack));
                output.put("charge", ElectricItem.manager.getCharge(stack));
                output.put("maxCharge", electricItem.getMaxCharge(stack));
                output.put("tier", electricItem.getTier(stack));
                output.put("transferLimit", electricItem.getTransferLimit(stack));
            }
        }
    }
View Full Code Here

    @Override
    public long doDischargeItem(ItemStack itemStack, long joules, boolean doDischarge)
    {
        if (itemStack.getItem() instanceof IElectricItem)
        {
            IElectricItem item = (IElectricItem) itemStack.getItem();

            if (item.canProvideEnergy(itemStack))
            {
                return (long) (ElectricItem.manager.discharge(itemStack, (int) Math.ceil(joules * CompatibilityType.INDUSTRIALCRAFT.ratio), 4, true, !doDischarge) * CompatibilityType.INDUSTRIALCRAFT.reciprocal_ratio);
            }
        }
        return 0;
View Full Code Here

        {
          setEnergy(getEnergy() + EnergizedItemManager.discharge(inventory[27], MAX_ELECTRICITY - getEnergy()));
        }
        else if(MekanismUtils.useIC2() && inventory[27].getItem() instanceof IElectricItem)
        {
          IElectricItem item = (IElectricItem)inventory[27].getItem();

          if(item.canProvideEnergy(inventory[27]))
          {
            double gain = ElectricItem.manager.discharge(inventory[27], (MAX_ELECTRICITY - getEnergy())*Mekanism.TO_IC2, 4, true, true, false)*Mekanism.FROM_IC2;
            setEnergy(getEnergy() + gain);
          }
        }
        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

          {
            setEnergy(itemstack, getEnergy(itemstack) + EnergizedItemManager.discharge(inv.getStackInSlot(54), getMaxEnergy(itemstack) - getEnergy(itemstack)));
          }
          else if(MekanismUtils.useIC2() && inv.getStackInSlot(54).getItem() instanceof IElectricItem)
          {
            IElectricItem item = (IElectricItem)inv.getStackInSlot(54).getItem();

            if(item.canProvideEnergy(inv.getStackInSlot(54)))
            {
              double gain = ElectricItem.manager.discharge(inv.getStackInSlot(54), (int)((getMaxEnergy(itemstack) - getEnergy(itemstack))*Mekanism.TO_IC2), 3, false, true, false)*Mekanism.FROM_IC2;
              setEnergy(itemstack, getEnergy(itemstack) + gain);
            }
          }
          else if(MekanismUtils.useRF() && inv.getStackInSlot(54).getItem() instanceof IEnergyContainerItem)
          {
            ItemStack itemStack = inv.getStackInSlot(54);
            IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(54).getItem();

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

            setEnergy(itemstack, getEnergy(itemstack) + (item.extractEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE));
          }
          else if(inv.getStackInSlot(54).getItem() == Items.redstone && getEnergy(itemstack)+Mekanism.ENERGY_PER_REDSTONE <= getMaxEnergy(itemstack))
          {
            setEnergy(itemstack, getEnergy(itemstack) + Mekanism.ENERGY_PER_REDSTONE);
            inv.getStackInSlot(54).stackSize--;
View Full Code Here

            }
            else if (EnergyConfigHandler.isIndustrialCraft2Loaded())
            {
                if (item instanceof IElectricItem)
                {
                    IElectricItem electricItem = (IElectricItem) item;
                    if (electricItem.canProvideEnergy(itemStack))
                    {
                        double result = 0;
                        double energyDischargeIC2 = energyToDischarge * EnergyConfigHandler.TO_IC2_RATIO;
                        //Do this by reflection:
                        //result = ic2.api.item.ElectricItem.manager.discharge(itemStack, energyDischargeIC2, 4, false, false, false)
                        try
                        {
                            Class<?> clazz = Class.forName("ic2.api.item.IElectricItemManager");
                            Method dischargeMethod = clazz.getMethod("discharge", ItemStack.class, double.class, int.class, boolean.class, boolean.class, boolean.class);
                            result = (Double) dischargeMethod.invoke(ic2.api.item.ElectricItem.manager, itemStack, energyDischargeIC2, 4, false, false, false);
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                        }
                        float energyDischarged = (float) result * EnergyConfigHandler.IC2_RATIO;
                        this.storage.receiveEnergyGC(energyDischarged);
                    }
                }
                else if (item instanceof ISpecialElectricItem)
                {
                    ISpecialElectricItem electricItem = (ISpecialElectricItem) item;
                    if (electricItem.canProvideEnergy(itemStack))
                    {
                        double result = 0;
                        double energyDischargeIC2 = energyToDischarge * EnergyConfigHandler.TO_IC2_RATIO;
                        //Do this by reflection:
                        //result = electricItem.getManager(itemStack).discharge(itemStack, energyDischargeIC2, 4, false, false, false)
                        try
                        {
                            Class<?> clazz = Class.forName("ic2.api.item.IElectricItemManager");
                            Method dischargeMethod = clazz.getMethod("discharge", ItemStack.class, double.class, int.class, boolean.class, boolean.class, boolean.class);
                            result = (Double) dischargeMethod.invoke(electricItem.getManager(itemStack), itemStack, energyDischargeIC2, 4, false, false, false);
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                        }
View Full Code Here

            }
            else if (EnergyConfigHandler.isIndustrialCraft2Loaded())
            {
                if (item instanceof IElectricItem)
                {
                    IElectricItem electricItem = (IElectricItem) item;
                    if (electricItem.canProvideEnergy(itemStack))
                    {
                        double result = 0;
                        int energyDischargeIC2 = (int) (energyToDischarge * EnergyConfigHandler.TO_IC2_RATIO);
                        try
                        {
                            Class<?> clazz = Class.forName("ic2.api.item.IElectricItemManager");
                            Method dischargeMethod = clazz.getMethod("discharge", ItemStack.class, int.class, int.class, boolean.class, boolean.class);
                            result = (Integer) dischargeMethod.invoke(ic2.api.item.ElectricItem.manager, itemStack, energyDischargeIC2, 4, false, false);
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                        }
                        float energyDischarged = (float) result * EnergyConfigHandler.IC2_RATIO;
                        this.storage.receiveEnergyGC(energyDischarged);
                    }
                }
                else if (item instanceof ISpecialElectricItem)
                {
                    ISpecialElectricItem electricItem = (ISpecialElectricItem) item;
                    if (electricItem.canProvideEnergy(itemStack))
                    {
                        double result = 0;
                        int energyDischargeIC2 = (int) (energyToDischarge * EnergyConfigHandler.TO_IC2_RATIO);
                        //Do this by reflection:
                        //result = electricItem.getManager(itemStack).discharge(itemStack, energyDischargeIC2, 4, false, false, false)
                        try
                        {
                            Class<?> clazz = Class.forName("ic2.api.item.IElectricItemManager");
                            Method dischargeMethod = clazz.getMethod("discharge", ItemStack.class, int.class, int.class, boolean.class, boolean.class);
                            result = (Integer) dischargeMethod.invoke(electricItem.getManager(itemStack), itemStack, energyDischargeIC2, 4, false, false);
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                        }
View Full Code Here

    }

    public static boolean canCharge(ItemStack stack, int tier) {
        try {
            if (stack != null && stack.getItem() instanceof IElectricItem) {
                IElectricItem battery = (IElectricItem) stack.getItem();
                return tier >= battery.getTier(stack);
            }
        } catch (Throwable error) {
            Game.logErrorAPI("IC2", error, IElectricItem.class);
        }
        return false;
View Full Code Here

    }

    public static boolean canDischarge(ItemStack stack, int tier) {
        try {
            if (stack != null && stack.getItem() instanceof IElectricItem) {
                IElectricItem battery = (IElectricItem) stack.getItem();
                return battery.canProvideEnergy(stack) && tier >= battery.getTier(stack);
            }
        } catch (Throwable error) {
            Game.logErrorAPI("IC2", error, IElectricItem.class);
        }
        return false;
View Full Code Here

                        this.storage.receiveEnergyGC(energyDischarged);
                    }
                }
                else if (item instanceof ISpecialElectricItem)
                {
                    ISpecialElectricItem electricItem = (ISpecialElectricItem) item;
                    if (electricItem.canProvideEnergy(itemStack))
                    {
                        double result = 0;
                        int energyDischargeIC2 = (int) (energyToDischarge * EnergyConfigHandler.TO_IC2_RATIO);
                        //Do this by reflection:
                        //result = electricItem.getManager(itemStack).discharge(itemStack, energyDischargeIC2, 4, false, false, false)
                        try
                        {
                            Class<?> clazz = Class.forName("ic2.api.item.IElectricItemManager");
                            Method dischargeMethod = clazz.getMethod("discharge", ItemStack.class, int.class, int.class, boolean.class, boolean.class);
                            result = (Integer) dischargeMethod.invoke(electricItem.getManager(itemStack), itemStack, energyDischargeIC2, 4, false, false);
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                        }
View Full Code Here

TOP

Related Classes of ic2.api.recipe.ICannerBottleRecipeManager$Input

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.