package net.shadowfacts.zcraft.item.tool;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.shadowfacts.zcraft.entity.EntityLaserBolt;
import net.shadowfacts.zcraft.item.ZItems;

public class ItemLaserPistol extends Item {

	public ItemLaserPistol() {
		super();
		this.setMaxStackSize(1);
		this.setMaxDamage(512);
	}
	
	@Override
	public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
		itemStack.damageItem(1, player);
		world.playSoundAtEntity(player, "random.bow", 0.5f, 0.4f / (itemRand.nextFloat() * 0.4f + 0.8f));
		if (!world.isRemote) {
			world.spawnEntityInWorld(new EntityLaserBolt(world, player));
		}
		
		return itemStack;
	}

}

@@ -154,16 +154,57 @@
 mStack;%0A
+import net.minecraft.nbt.NBTTagCompound;%0A
 import n
@@ -294,42 +294,44 @@
 ort 
-net.shadowfacts.zcraft.item.Z
+cofh.api.energy.IEnergyContainer
 Item
-s
 ;%0A%0Ap
@@ -371,17 +371,150 @@
 ds Item 
-%7B
+implements IEnergyContainerItem %7B%0A%09%0A%09// Redstone Flux%0A%09protected int capacity;%0A%09protected int maxRecieve;%0A%09protected int maxExtract;%0A%09
 %0A%0A%09publi
@@ -599,16 +599,90 @@
 e(512);%0A
+%09%09this.capacity = 500000;%0A%09%09this.maxExtract = 75;%0A%09%09this.maxRecieve = 75;%0A
 %09%7D%0A%09%0A%09@O
@@ -1037,10 +1037,1355 @@
 ck;%0A%09%7D%0A%0A
+%09// Redstone Flux%0A%09%0A%09@Override%0A%09public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) %7B%0A%09%09if (container.stackTagCompound == null) %7B%0A%09%09%09container.stackTagCompound = new NBTTagCompound();%0A%09%09%7D%0A%09%09%0A%09%09int energy = container.stackTagCompound.getInteger(%22Energy%22);%0A%09%09int energyRecieved = Math.min(capacity - energy, Math.min(this.maxRecieve, maxReceive));%0A%09%09%0A%09%09if (!simulate) %7B%0A%09%09%09energy += energyRecieved;%0A%09%09%09container.stackTagCompound.setInteger(%22Energy%22, energy);%0A%09%09%7D%0A%09%09%0A%09%09return energyRecieved;%0A%09%7D%0A%0A%09@Override%0A%09public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) %7B%0A%09%09if (container.stackTagCompound == null %7C%7C !container.stackTagCompound.hasKey(%22Energy%22)) %7B%0A%09%09%09return 0;%0A%09%09%7D%0A%09%09%0A%09%09int energy = container.stackTagCompound.getInteger(%22Energy%22);%0A%09%09int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));%0A%09%09%0A%09%09if (!simulate) %7B%0A%09%09%09energy -= energyExtracted;%0A%09%09%09container.stackTagCompound.setInteger(%22Energt%22, energy);%0A%09%09%7D%0A%09%09%0A%09%09return energyExtracted;%0A%09%7D%0A%0A%09@Override%0A%09public int getEnergyStored(ItemStack container) %7B%0A%09%09if (container.stackTagCompound == null %7C%7C !container.stackTagCompound.hasKey(%22Energy%22)) %7B%0A%09%09%09return 0;%0A%09%09%7D%0A%09%09%0A%09%09return container.stackTagCompound.getInteger(%22Energy%22);%0A%09%7D%0A%0A%09@Override%0A%09public int getMaxEnergyStored(ItemStack container) %7B%0A%09%09return capacity;%0A%09%7D%0A%0A
 %7D%0A

Add Redstone Flux to laser pistol