1 package asia.tcrs.ccnp.chemicraftnext.base.item;
3 import java.util.ArrayList;
5 import asia.tcrs.ccnp.chemicraftnext.ChemiCraft;
6 import asia.tcrs.ccnp.chemicraftnext.base.ChemiCraftBase;
7 import asia.tcrs.ccnp.chemicraftnext.core.ChemiCraftCore;
9 import cpw.mods.fml.relauncher.Side;
10 import cpw.mods.fml.relauncher.SideOnly;
12 import net.minecraft.client.renderer.texture.IconRegister;
13 import net.minecraft.entity.Entity;
14 import net.minecraft.entity.EntityLiving;
15 import net.minecraft.entity.player.EntityPlayer;
16 import net.minecraft.item.Item;
17 import net.minecraft.item.ItemStack;
18 import net.minecraft.util.DamageSource;
19 import net.minecraft.world.World;
25 public class ItemRadiationGun extends Item {
32 public ItemRadiationGun(int par1) {
34 this.setCreativeTab(ChemiCraftCore.creativeTabChemiCraft);
35 this.maxStackSize = 1;
39 @SideOnly(Side.CLIENT)
40 public void registerIcons(IconRegister par1IconRegister){
41 this.itemIcon = par1IconRegister.registerIcon(ChemiCraft.TEXTURE + "radiation_gun");
45 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
46 EntityPlayer par3EntityPlayer) {
48 boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
50 if (this.delay <= 0) {
52 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
53 if (par3EntityPlayer.inventory.hasItem(ChemiCraftBase.instance.itemRadiationBallet.itemID)) {
54 par3EntityPlayer.inventory.consumeInventoryItem(ChemiCraftBase.instance.itemRadiationBallet.itemID);
55 par2World.playSound(par3EntityPlayer.posX,
56 par3EntityPlayer.posY,
57 par3EntityPlayer.posZ,
58 "mob.endermen.portal",
63 par2World.playSound(par3EntityPlayer.posX,
64 par3EntityPlayer.posY,
65 par3EntityPlayer.posZ,
66 "ChemiCraft.raditionGun",
70 if (!par2World.isRemote) {
75 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
76 par2World.playSound(par3EntityPlayer.posX,
77 par3EntityPlayer.posY,
78 par3EntityPlayer.posZ,
79 "mob.endermen.portal",
84 par2World.playSound(par3EntityPlayer.posX,
85 par3EntityPlayer.posY,
86 par3EntityPlayer.posZ,
87 "ChemiCraft.raditionGun",
91 if (!par2World.isRemote) {
97 return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
100 private void field_00001(ItemStack par1ItemStack, World par2World,
101 EntityPlayer par3EntityPlayer) {
103 ArrayList<Entity> collisions = ChemiCraftCore.instance.mathAuxiliary.getTriangleEntitysByPlayer(par2World,
104 par3EntityPlayer.posX,
105 par3EntityPlayer.posY,
106 par3EntityPlayer.posZ,
107 par3EntityPlayer.rotationYaw,
108 par3EntityPlayer.rotationPitch,
112 for (int i = 0; i < collisions.size(); i++) {
113 if (collisions.get(i) instanceof EntityLiving && collisions.get(i) != par3EntityPlayer) {
115 EntityLiving entity = (EntityLiving) collisions.get(i);
116 entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
117 } catch (ClassCastException e) {
126 public void onUpdate(ItemStack par1ItemStack, World par2World,
127 Entity par3Entity, int par4, boolean par5) {
128 if (this.delay > 0 && !par2World.isRemote) {