OSDN Git Service

音声修正
[chemicraft/ChemiCraftNext.git] / common / pcc / chemicraft / item / ItemRadiationGun.java
index 0d202ea..887fd5a 100644 (file)
@@ -1,5 +1,6 @@
 package pcc.chemicraft.item;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 
 import net.minecraft.entity.Entity;
@@ -11,6 +12,9 @@ import net.minecraft.potion.Potion;
 import net.minecraft.potion.PotionEffect;
 import net.minecraft.util.AxisAlignedBB;
 import net.minecraft.util.DamageSource;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.Vec3;
+import net.minecraft.util.Vec3Pool;
 import net.minecraft.world.World;
 import pcc.chemicraft.ChemiCraft;
 
@@ -36,9 +40,9 @@ public class ItemRadiationGun extends Item {
                boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
 
                if (this.delay <= 0) {
-                       if (isCreative) {
+                       if (!isCreative) {
+                               this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
                                if (par3EntityPlayer.inventory.hasItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex)) {
-                                       this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
                                        par3EntityPlayer.inventory.consumeInventoryItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex);
                                        par2World.playSound(par3EntityPlayer.posX,
                                                        par3EntityPlayer.posY,
@@ -47,15 +51,11 @@ public class ItemRadiationGun extends Item {
                                                        1.0F,
                                                        1.3F,
                                                        false);
-                                       if (!par2World.isRemote) {
-                                               this.delay = 100;
-                                       }
-                               } else {
-                                       this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
+
                                        par2World.playSound(par3EntityPlayer.posX,
                                                        par3EntityPlayer.posY,
                                                        par3EntityPlayer.posZ,
-                                                       "mob.endermen.portal",
+                                                       "ChemiCraft.raditionGun",
                                                        1.0F,
                                                        1.3F,
                                                        false);
@@ -63,6 +63,26 @@ public class ItemRadiationGun extends Item {
                                                this.delay = 100;
                                        }
                                }
+                       } else {
+                               this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
+                               par2World.playSound(par3EntityPlayer.posX,
+                                               par3EntityPlayer.posY,
+                                               par3EntityPlayer.posZ,
+                                               "mob.endermen.portal",
+                                               1.0F,
+                                               1.3F,
+                                               false);
+
+                               par2World.playSound(par3EntityPlayer.posX,
+                                               par3EntityPlayer.posY,
+                                               par3EntityPlayer.posZ,
+                                               "ChemiCraft.raditionGun",
+                                               1.0F,
+                                               1.3F,
+                                               false);
+                               if (!par2World.isRemote) {
+                                       this.delay = 100;
+                               }
                        }
                }
 
@@ -71,33 +91,27 @@ public class ItemRadiationGun extends Item {
 
        private void field_00001(ItemStack par1ItemStack, World par2World,
                        EntityPlayer par3EntityPlayer) {
-               int distance = 0;
-               double minX = par3EntityPlayer.posX;
-               double minZ = par3EntityPlayer.posZ;
-               double maxX = par3EntityPlayer.posX - Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * 20;
-               double maxZ = par3EntityPlayer.posZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * 20;
-               double posY = par3EntityPlayer.posY;
-               for(distance = 0;distance < Math.abs(((minX-maxX) + (minZ-maxZ))) / 2;distance++){
-                       AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
-                                       minX + -Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
-                                       posY + 1,
-                                       minZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
-                                       minX + -Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
-                                       posY + 1,
-                                       minZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance
-                                       ).expand(1.5, 3, 1.5);
-
-                       Iterator itr = par2World.getEntitiesWithinAABB(EntityLiving.class, aabb).iterator();
-                       while(itr.hasNext()){
-                               EntityLiving entity = (EntityLiving) itr.next();
-                               if(entity != par3EntityPlayer){
-                                       entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), 10);
+
+               ArrayList<Entity> collisions = ChemiCraft.instance.mathAuxiliary.getTriangleEntitys(par2World,
+                               par3EntityPlayer.posX,
+                               par3EntityPlayer.posY,
+                               par3EntityPlayer.posZ,
+                               par3EntityPlayer.rotationYaw,
+                               par3EntityPlayer.rotationPitch,
+                               30,
+                               15);
+
+               for (int i = 0; i < collisions.size(); i++) {
+                       if (collisions.get(i) instanceof EntityLiving) {
+                               try {
+                                       EntityLiving entity = (EntityLiving) collisions.get(i);
                                        entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
-                                       entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 1, 20*20));
-                                       entity.addPotionEffect(new PotionEffect(Potion.weakness.getId(), 1, 20*20));
+                               } catch (ClassCastException e) {
+                                       break;
                                }
                        }
                }
+
        }
 
        @Override