ic2.api.item.ElectricItem Java Examples
The following examples show how to use
ic2.api.item.ElectricItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemStreamChainsaw.java From Electro-Magic-Tools with GNU General Public License v3.0 | 6 votes |
@Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { Block bi = world.getBlock(x, y, z); if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) { if (!world.isRemote) { if (BlockUtils.breakFurthestBlock(world, x, y, z, bi, player)) { world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F); ElectricItem.manager.use(itemstack, cost, player); this.alternateServer = (!this.alternateServer); } } else { player.swingItem(); ElectricItem.manager.use(itemstack, cost, player); this.alternateClient = (!this.alternateClient); } } return super.onItemUse(itemstack, player, world, x, y, z, par7, par8, par9, par10); }
Example #2
Source File: ItemWandChargingFocus.java From Electro-Magic-Tools with GNU General Public License v3.0 | 6 votes |
@Override public void onUsingFocusTick(ItemStack itemstack, EntityPlayer player, int integer) { if (!player.worldObj.isRemote) { ItemWandCasting wandItem = (ItemWandCasting) itemstack.getItem(); ItemStack armor = player.inventory.armorInventory[1]; if (armor != null) { if ((ElectricItem.manager.use(armor, ConfigHandler.wandChargeFocusCost / 4, player) && (ElectricItem.manager.use(armor, ConfigHandler.wandChargeFocusCost / 4, player)) && (ElectricItem.manager.use(armor, ConfigHandler.wandChargeFocusCost / 4, player)) && (ElectricItem.manager.use(armor, ConfigHandler.wandChargeFocusCost / 4, player)))) { wandItem.addVis(itemstack, Aspect.ORDER, 1, true); wandItem.addVis(itemstack, Aspect.FIRE, 1, true); wandItem.addVis(itemstack, Aspect.ENTROPY, 1, true); wandItem.addVis(itemstack, Aspect.WATER, 1, true); wandItem.addVis(itemstack, Aspect.EARTH, 1, true); wandItem.addVis(itemstack, Aspect.AIR, 1, true); } } } }
Example #3
Source File: ItemStreamChainsaw.java From Electro-Magic-Tools with GNU General Public License v3.0 | 6 votes |
@Override public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { World world = player.worldObj; Block bi = world.getBlock(x, y, z); if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) { if (!world.isRemote) { BlockUtils.breakFurthestBlock(world, x, y, z, bi, player); PacketHandler.INSTANCE.sendToAllAround(new PacketFXBlockBubble(x, y, z, new Color(0.33F, 0.33F, 1.0F).getRGB()), new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D)); world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F); } ElectricItem.manager.use(itemstack, cost, player); return true; } return super.onBlockStartBreak(itemstack, x, y, z, player); }
Example #4
Source File: GTTileChargeOMat.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public void tryDischarge() { // Try to discharge for (int i = 0; i < 9; ++i) { if (!this.inventory.get(i).isEmpty()) { if (this.canFill()) { int added = (int) ElectricItem.manager.discharge(this.inventory.get(i), (double) (this.maxEnergy - this.energy), this.tier, false, true, false); this.energy += added; if (added > 0) { this.getNetwork().updateTileGuiField(this, "energy"); } } // If the Item is fully discharged attempt to move it to the first open slot if (ElectricItem.manager.getCharge(this.inventory.get(i)) == 0.0D) { for (int j = 9; j < 18; ++j) { if (this.inventory.get(j).isEmpty()) { this.inventory.set(j, StackUtil.copyWithSize(this.inventory.get(i), 1)); this.inventory.get(i).shrink(1); } } } // MABYEDO limit discharge to one item at a time? } } }
Example #5
Source File: GTTileChargeOMat.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public void tryCharge() { // Here I iterate the input slots to try to charge items for (int i = 0; i < 9; ++i) { if (!this.inventory.get(i).isEmpty()) { if (hasEnergy()) { int removed = (int) ElectricItem.manager.charge((ItemStack) this.inventory.get(i), (double) this.energy, this.tier, false, false); this.energy -= removed; if (removed > 0) { this.getNetwork().updateTileGuiField(this, "energy"); } } // If the Item is fully charged attempt to move it to the first open slot if (ElectricItem.manager.getCharge(this.inventory.get(i)) == ElectricItem.manager.getMaxCharge(this.inventory.get(i))) { for (int j = 9; j < 18; ++j) { if (this.inventory.get(j).isEmpty()) { this.inventory.set(j, StackUtil.copyWithSize(this.inventory.get(i), 1)); this.inventory.get(i).shrink(1); } } } // MABYEDO limit charge to one item at a time? } } }
Example #6
Source File: ItemNanoGoggles.java From Electro-Magic-Tools with GNU General Public License v3.0 | 6 votes |
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if (ConfigHandler.nightVisionOff == false) { if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) { int x = MathHelper.floor_double(player.posX); int z = MathHelper.floor_double(player.posZ); int y = MathHelper.floor_double(player.posY); int lightlevel = player.worldObj.getBlockLightValue(x, y, z); if (lightlevel >= 0) player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3)); ElectricItem.manager.use(itemStack, 1 / 1000, player); } else { player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true)); } } }
Example #7
Source File: ItemElectricBootsTraveller.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { if (source.isUnblockable()) { return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3); } else { double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio(); int energyPerDamage = getEnergyPerDamage(); double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage; return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit); } }
Example #8
Source File: ItemElectricBootsTraveller.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage()) { return (int) Math.round(20D * getBaseAbsorptionRatio() * getDamageAbsorptionRatio()); } else { return 0; } }
Example #9
Source File: ItemThaumiumDrill.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); itemList.add(charged); } if (getEmptyItem(itemStack) == this) { itemList.add(new ItemStack(this, 1, getMaxDamage())); } }
Example #10
Source File: ItemElectricGoggles.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { if (source.isUnblockable()) { return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 0); } else { double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio(); int energyPerDamage = getEnergyPerDamage(); double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage; return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, absorptionRatio, (int) damageLimit); } }
Example #11
Source File: ItemNanoWing.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage()) { return (int) Math.round(20D * getBaseAbsorptionRatio() * getDamageAbsorptionRatio()); } else { return 0; } }
Example #12
Source File: ItemNanoWing.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { if (source.isUnblockable()) { return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3); } else { double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio(); int energyPerDamage = getEnergyPerDamage(); double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage; return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit); } }
Example #13
Source File: ItemNanoWing.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); itemList.add(charged); } if (getEmptyItem(itemStack) == this) { itemList.add(new ItemStack(this, 1, getMaxDamage())); } }
Example #14
Source File: ItemElectricGoggles.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); itemList.add(charged); } if (getEmptyItem(itemStack) == this) { itemList.add(new ItemStack(this, 1, getMaxDamage())); } }
Example #15
Source File: TileSlotCharge.java From Production-Line with MIT License | 5 votes |
public double charge(double amount) { if(amount <= 0.0D) { throw new IllegalArgumentException("Amount must be > 0."); } else { ItemStack itemStack = this.getStack(); return itemStack == null ? 0.0D : ElectricItem.manager.charge(itemStack, amount, ((TileElectricContainer) this.tile).tier, false, false); } }
Example #16
Source File: ElectricItemMetaProvider.java From OpenPeripheral-Integration with MIT License | 5 votes |
@Override public Object getMeta(IElectricItem target, ItemStack stack) { Map<String, Object> electricInfo = Maps.newHashMap(); electricInfo.put("tier", target.getTier(stack)); electricInfo.put("maxCharge", target.getMaxCharge(stack)); electricInfo.put("transferLimit", target.getTransferLimit(stack)); electricInfo.put("canProvideEnergy", target.canProvideEnergy(stack)); electricInfo.put("charge", ElectricItem.manager.getCharge(stack)); return electricInfo; }
Example #17
Source File: TileSlotCharge.java From Production-Line with MIT License | 5 votes |
/** * Whether the current item can be inputted. * * @param itemStack Input item. */ @SuppressWarnings("NumericOverflow") @Override public boolean canInput(ItemStack itemStack) { if (this.tile instanceof IEnergySink) { return ElectricItem.manager.charge(itemStack, 1.0D / 0.0, ((IEnergySink) this.tile).getSinkTier(), true, true) > 0.0D; } else if (this.tile instanceof IEnergySource) { return ElectricItem.manager.charge(itemStack, 1.0D / 0.0, ((IEnergySource) this.tile).getSourceTier(), true, true) > 0.0D; } return false; }
Example #18
Source File: ItemOmnitoolIron.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) { if (ElectricItem.manager.use(itemstack, hitCost, attacker)) { entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 8F); } return false; }
Example #19
Source File: ItemRockbreakerDrill.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) { if (ElectricItem.manager.use(itemstack, hitCost, attacker)) { entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 12F); } return false; }
Example #20
Source File: ItemGravityRay.java From Production-Line with MIT License | 5 votes |
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ @Override @Nonnull public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) { if (player.capabilities.isCreativeMode || ElectricItem.manager.getCharge(stack) >= 100) { player.setActiveHand(hand); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } return new ActionResult<>(EnumActionResult.PASS, stack); }
Example #21
Source File: ItemOmnitoolDiamond.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int par4, int par5, int par6, EntityLivingBase entityLiving) { if (!ConfigHandler.toolsInBore) { cost = 200; } else { cost = 1; } ElectricItem.manager.use(stack, cost, entityLiving); return true; }
Example #22
Source File: ItemElectricPL.java From Production-Line with MIT License | 5 votes |
@SuppressWarnings({"NumericOverflow", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); ElectricItem.manager.charge(itemStack, 0.0D, Integer.MAX_VALUE, true, false); itemList.add(itemStack); ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); itemList.add(charged); }
Example #23
Source File: ItemOmnitoolDiamond.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) { if (ElectricItem.manager.use(itemstack, hitCost, attacker)) { entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 10F); } return false; }
Example #24
Source File: GTItemSurvivalScanner.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (!canScan(player.getHeldItemMainhand())) { return EnumActionResult.PASS; } else { ElectricItem.manager.use(player.getHeldItemMainhand(), energyCost, (EntityLivingBase) null); return GTItemCreativeScanner.scanBlock(player, world, pos, side, hand); } }
Example #25
Source File: ItemOmnitoolIron.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); itemList.add(charged); } if (getEmptyItem(itemStack) == this) { itemList.add(new ItemStack(this, 1, getMaxDamage())); } }
Example #26
Source File: ItemOmnitoolIron.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int par4, int par5, int par6, EntityLivingBase entityLiving) { if (!ConfigHandler.toolsInBore) { cost = 100; } else { cost = 1; } ElectricItem.manager.use(stack, cost, entityLiving); return true; }
Example #27
Source File: GTItemRockCutter.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) { if (!isInCreativeTab(tab)) { return; } ItemStack empty = new ItemStack(this, 1, 0); ItemStack full = new ItemStack(this, 1, 0); ElectricItem.manager.discharge(empty, 2.147483647E9D, Integer.MAX_VALUE, true, false, false); ElectricItem.manager.charge(full, 2.147483647E9D, Integer.MAX_VALUE, true, false); empty.addEnchantment(Enchantments.SILK_TOUCH, 1); full.addEnchantment(Enchantments.SILK_TOUCH, 1); items.add(empty); items.add(full); }
Example #28
Source File: GTItemJackHammer.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
public void breakBlock(BlockPos pos, World world, EntityPlayer player, ItemStack drill) { IBlockState blockState = world.getBlockState(pos); if (!isValidState(blockState) || !ElectricItem.manager.canUse(drill, this.getEnergyCost(drill))) { return; } ElectricItem.manager.use(drill, this.getEnergyCost(drill), player); blockState.getBlock().harvestBlock(world, player, pos, blockState, world.getTileEntity(pos), drill); world.setBlockToAir(pos); world.removeTileEntity(pos); }
Example #29
Source File: ItemOmnitoolIron.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public float getDigSpeed(ItemStack stack, Block block, int meta) { if (!ElectricItem.manager.canUse(stack, cost)) { return 1.0F; } if (Items.wooden_axe.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_sword.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_shovel.getDigSpeed(stack, block, meta) > 1.0F || Items.shears.getDigSpeed(stack, block, meta) > 1.0F) { return efficiencyOnProperMaterial; } else { return super.getDigSpeed(stack, block, meta); } }
Example #30
Source File: GTItemCreativeScanner.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) { if (this.isInCreativeTab(tab)) { ItemStack full = new ItemStack(this, 1, 0); ElectricItem.manager.charge(full, 2.147483647E9D, Integer.MAX_VALUE, true, false); items.add(full); } }