OSDN Git Service

音声修正
[chemicraft/chemicraft.git] / common / pcc / chemicraft / item / ItemRadiationGun.java
1 package pcc.chemicraft.item;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5
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;
20
21 public class ItemRadiationGun extends Item {
22
23         private short delay;
24
25         public ItemRadiationGun(int par1) {
26                 super(par1);
27                 this.setCreativeTab(ChemiCraft.creativeTabChemiCraft);
28                 this.maxStackSize = 1;
29         }
30
31         @Override
32         public String getTextureFile() {
33                 return ChemiCraft.instance.ITEM_TEXTURE;
34         }
35
36         @Override
37         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
38                         EntityPlayer par3EntityPlayer) {
39
40                 boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
41
42                 if (this.delay <= 0) {
43                         if (!isCreative) {
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",
51                                                         1.0F,
52                                                         1.3F,
53                                                         false);
54
55                                         par2World.playSound(par3EntityPlayer.posX,
56                                                         par3EntityPlayer.posY,
57                                                         par3EntityPlayer.posZ,
58                                                         "ChemiCraft.raditionGun",
59                                                         1.0F,
60                                                         1.3F,
61                                                         false);
62                                         if (!par2World.isRemote) {
63                                                 this.delay = 100;
64                                         }
65                                 }
66                         } else {
67                                 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
68                                 par2World.playSound(par3EntityPlayer.posX,
69                                                 par3EntityPlayer.posY,
70                                                 par3EntityPlayer.posZ,
71                                                 "mob.endermen.portal",
72                                                 1.0F,
73                                                 1.3F,
74                                                 false);
75
76                                 par2World.playSound(par3EntityPlayer.posX,
77                                                 par3EntityPlayer.posY,
78                                                 par3EntityPlayer.posZ,
79                                                 "ChemiCraft.raditionGun",
80                                                 1.0F,
81                                                 1.3F,
82                                                 false);
83                                 if (!par2World.isRemote) {
84                                         this.delay = 100;
85                                 }
86                         }
87                 }
88
89                 return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
90         }
91
92         private void field_00001(ItemStack par1ItemStack, World par2World,
93                         EntityPlayer par3EntityPlayer) {
94
95                 ArrayList<Entity> collisions = ChemiCraft.instance.mathAuxiliary.getTriangleEntitys(par2World,
96                                 par3EntityPlayer.posX,
97                                 par3EntityPlayer.posY,
98                                 par3EntityPlayer.posZ,
99                                 par3EntityPlayer.rotationYaw,
100                                 par3EntityPlayer.rotationPitch,
101                                 30,
102                                 15);
103
104                 for (int i = 0; i < collisions.size(); i++) {
105                         if (collisions.get(i) instanceof EntityLiving) {
106                                 try {
107                                         EntityLiving entity = (EntityLiving) collisions.get(i);
108                                         entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
109                                 } catch (ClassCastException e) {
110                                         break;
111                                 }
112                         }
113                 }
114
115         }
116
117         @Override
118         public void onUpdate(ItemStack par1ItemStack, World par2World,
119                         Entity par3Entity, int par4, boolean par5) {
120                 if (this.delay > 0 && !par2World.isRemote) {
121                         this.delay--;
122                 }
123         }
124
125
126 }