1 package pcc.chemicraft.base.item;
3 import java.util.ArrayList;
5 import net.minecraft.entity.Entity;
6 import net.minecraft.entity.EntityLiving;
7 import net.minecraft.entity.player.EntityPlayer;
8 import net.minecraft.item.Item;
9 import net.minecraft.item.ItemStack;
10 import net.minecraft.util.DamageSource;
11 import net.minecraft.world.World;
12 import pcc.chemicraft.ChemiCraft;
13 import pcc.chemicraft.base.ChemiCraftBase;
14 import pcc.chemicraft.core.ChemiCraftCore;
16 public class ItemRadiationGun extends Item {
20 public ItemRadiationGun(int par1) {
22 this.setCreativeTab(ChemiCraftCore.creativeTabChemiCraft);
23 this.maxStackSize = 1;
27 public String getTextureFile() {
28 return ChemiCraft.ITEM_TEXTURE;
32 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
33 EntityPlayer par3EntityPlayer) {
35 boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
37 if (this.delay <= 0) {
39 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
40 if (par3EntityPlayer.inventory.hasItem(ChemiCraftBase.instance.itemRadiationBallet.shiftedIndex)) {
41 par3EntityPlayer.inventory.consumeInventoryItem(ChemiCraftBase.instance.itemRadiationBallet.shiftedIndex);
42 par2World.playSound(par3EntityPlayer.posX,
43 par3EntityPlayer.posY,
44 par3EntityPlayer.posZ,
45 "mob.endermen.portal",
50 par2World.playSound(par3EntityPlayer.posX,
51 par3EntityPlayer.posY,
52 par3EntityPlayer.posZ,
53 "ChemiCraft.raditionGun",
57 if (!par2World.isRemote) {
62 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
63 par2World.playSound(par3EntityPlayer.posX,
64 par3EntityPlayer.posY,
65 par3EntityPlayer.posZ,
66 "mob.endermen.portal",
71 par2World.playSound(par3EntityPlayer.posX,
72 par3EntityPlayer.posY,
73 par3EntityPlayer.posZ,
74 "ChemiCraft.raditionGun",
78 if (!par2World.isRemote) {
84 return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
87 private void field_00001(ItemStack par1ItemStack, World par2World,
88 EntityPlayer par3EntityPlayer) {
90 ArrayList<Entity> collisions = ChemiCraftCore.instance.mathAuxiliary.getTriangleEntitysByPlayer(par2World,
91 par3EntityPlayer.posX,
92 par3EntityPlayer.posY,
93 par3EntityPlayer.posZ,
94 par3EntityPlayer.rotationYaw,
95 par3EntityPlayer.rotationPitch,
99 for (int i = 0; i < collisions.size(); i++) {
100 if (collisions.get(i) instanceof EntityLiving && collisions.get(i) != par3EntityPlayer) {
102 EntityLiving entity = (EntityLiving) collisions.get(i);
103 entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
104 } catch (ClassCastException e) {
113 public void onUpdate(ItemStack par1ItemStack, World par2World,
114 Entity par3Entity, int par4, boolean par5) {
115 if (this.delay > 0 && !par2World.isRemote) {