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;
20 public class ItemRadiationGun extends Item {
27 public ItemRadiationGun(int par1) {
29 this.setCreativeTab(ChemiCraftCore.creativeTabChemiCraft);
30 this.maxStackSize = 1;
34 public String getTextureFile() {
35 return ChemiCraft.ITEM_TEXTURE;
39 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
40 EntityPlayer par3EntityPlayer) {
42 boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
44 if (this.delay <= 0) {
46 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
47 if (par3EntityPlayer.inventory.hasItem(ChemiCraftBase.instance.itemRadiationBallet.shiftedIndex)) {
48 par3EntityPlayer.inventory.consumeInventoryItem(ChemiCraftBase.instance.itemRadiationBallet.shiftedIndex);
49 par2World.playSound(par3EntityPlayer.posX,
50 par3EntityPlayer.posY,
51 par3EntityPlayer.posZ,
52 "mob.endermen.portal",
57 par2World.playSound(par3EntityPlayer.posX,
58 par3EntityPlayer.posY,
59 par3EntityPlayer.posZ,
60 "ChemiCraft.raditionGun",
64 if (!par2World.isRemote) {
69 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
70 par2World.playSound(par3EntityPlayer.posX,
71 par3EntityPlayer.posY,
72 par3EntityPlayer.posZ,
73 "mob.endermen.portal",
78 par2World.playSound(par3EntityPlayer.posX,
79 par3EntityPlayer.posY,
80 par3EntityPlayer.posZ,
81 "ChemiCraft.raditionGun",
85 if (!par2World.isRemote) {
91 return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
94 private void field_00001(ItemStack par1ItemStack, World par2World,
95 EntityPlayer par3EntityPlayer) {
97 ArrayList<Entity> collisions = ChemiCraftCore.instance.mathAuxiliary.getTriangleEntitysByPlayer(par2World,
98 par3EntityPlayer.posX,
99 par3EntityPlayer.posY,
100 par3EntityPlayer.posZ,
101 par3EntityPlayer.rotationYaw,
102 par3EntityPlayer.rotationPitch,
106 for (int i = 0; i < collisions.size(); i++) {
107 if (collisions.get(i) instanceof EntityLiving && collisions.get(i) != par3EntityPlayer) {
109 EntityLiving entity = (EntityLiving) collisions.get(i);
110 entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
111 } catch (ClassCastException e) {
120 public void onUpdate(ItemStack par1ItemStack, World par2World,
121 Entity par3Entity, int par4, boolean par5) {
122 if (this.delay > 0 && !par2World.isRemote) {