1 package pcc.chemicraft.item;
3 import java.util.ArrayList;
4 import java.util.Iterator;
6 import net.minecraft.entity.Entity;
7 import net.minecraft.entity.EntityLiving;
8 import net.minecraft.entity.player.EntityPlayer;
9 import net.minecraft.item.Item;
10 import net.minecraft.item.ItemStack;
11 import net.minecraft.potion.Potion;
12 import net.minecraft.potion.PotionEffect;
13 import net.minecraft.util.AxisAlignedBB;
14 import net.minecraft.util.DamageSource;
15 import net.minecraft.util.MovingObjectPosition;
16 import net.minecraft.util.Vec3;
17 import net.minecraft.util.Vec3Pool;
18 import net.minecraft.world.World;
19 import pcc.chemicraft.ChemiCraft;
21 public class ItemRadiationGun extends Item {
25 public ItemRadiationGun(int par1) {
27 this.setCreativeTab(ChemiCraft.creativeTabChemiCraft);
28 this.maxStackSize = 1;
32 public String getTextureFile() {
33 return ChemiCraft.instance.ITEM_TEXTURE;
37 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
38 EntityPlayer par3EntityPlayer) {
40 boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
42 if (this.delay <= 0) {
44 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
45 if (par3EntityPlayer.inventory.hasItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex)) {
46 par3EntityPlayer.inventory.consumeInventoryItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex);
47 par2World.playSound(par3EntityPlayer.posX,
48 par3EntityPlayer.posY,
49 par3EntityPlayer.posZ,
50 "mob.endermen.portal",
55 par2World.playSound(par3EntityPlayer.posX,
56 par3EntityPlayer.posY,
57 par3EntityPlayer.posZ,
58 "ChemiCraft.raditionGun",
62 if (!par2World.isRemote) {
67 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
68 par2World.playSound(par3EntityPlayer.posX,
69 par3EntityPlayer.posY,
70 par3EntityPlayer.posZ,
71 "mob.endermen.portal",
76 par2World.playSound(par3EntityPlayer.posX,
77 par3EntityPlayer.posY,
78 par3EntityPlayer.posZ,
79 "ChemiCraft.raditionGun",
83 if (!par2World.isRemote) {
89 return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
92 private void field_00001(ItemStack par1ItemStack, World par2World,
93 EntityPlayer par3EntityPlayer) {
95 ArrayList<Entity> collisions = ChemiCraft.instance.mathAuxiliary.getTriangleEntitys(par2World,
96 par3EntityPlayer.posX,
97 par3EntityPlayer.posY,
98 par3EntityPlayer.posZ,
99 par3EntityPlayer.rotationYaw,
100 par3EntityPlayer.rotationPitch,
104 for (int i = 0; i < collisions.size(); i++) {
105 if (collisions.get(i) instanceof EntityLiving) {
107 EntityLiving entity = (EntityLiving) collisions.get(i);
108 entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
109 } catch (ClassCastException e) {
118 public void onUpdate(ItemStack par1ItemStack, World par2World,
119 Entity par3Entity, int par4, boolean par5) {
120 if (this.delay > 0 && !par2World.isRemote) {