OSDN Git Service

tc
authormozipi <mozipi@users.sourceforge.jp>
Tue, 26 Mar 2013 05:02:58 +0000 (14:02 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Tue, 26 Mar 2013 05:02:58 +0000 (14:02 +0900)
common/pcc/chemicraft/item/ItemRadiationGun.java
common/pcc/chemicraft/util/Auxiliary.java

index 887fd5a..56a477e 100644 (file)
@@ -56,7 +56,7 @@ public class ItemRadiationGun extends Item {
                                                        par3EntityPlayer.posY,
                                                        par3EntityPlayer.posZ,
                                                        "ChemiCraft.raditionGun",
-                                                       1.0F,
+                                                       2.0F,
                                                        1.3F,
                                                        false);
                                        if (!par2World.isRemote) {
@@ -77,7 +77,7 @@ public class ItemRadiationGun extends Item {
                                                par3EntityPlayer.posY,
                                                par3EntityPlayer.posZ,
                                                "ChemiCraft.raditionGun",
-                                               1.0F,
+                                               2.0F,
                                                1.3F,
                                                false);
                                if (!par2World.isRemote) {
@@ -92,7 +92,7 @@ public class ItemRadiationGun extends Item {
        private void field_00001(ItemStack par1ItemStack, World par2World,
                        EntityPlayer par3EntityPlayer) {
 
-               ArrayList<Entity> collisions = ChemiCraft.instance.mathAuxiliary.getTriangleEntitys(par2World,
+               ArrayList<Entity> collisions = ChemiCraft.instance.mathAuxiliary.getTriangleEntitysByPlayer(par2World,
                                par3EntityPlayer.posX,
                                par3EntityPlayer.posY,
                                par3EntityPlayer.posZ,
@@ -102,7 +102,7 @@ public class ItemRadiationGun extends Item {
                                15);
 
                for (int i = 0; i < collisions.size(); i++) {
-                       if (collisions.get(i) instanceof EntityLiving) {
+                       if (collisions.get(i) instanceof EntityLiving && collisions.get(i) != par3EntityPlayer) {
                                try {
                                        EntityLiving entity = (EntityLiving) collisions.get(i);
                                        entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
index 8e42b4f..d7c7743 100644 (file)
@@ -244,7 +244,7 @@ public class Auxiliary {
 
        public static class MathAuxiliary {
 
-               public static ArrayList<Entity> getTriangleEntitys(World par1World,
+               public static ArrayList<Entity> getTriangleEntitysByPlayer(World par1World,
                                double par2, double par3, double par4,
                                double yaw,
                                double pitch,
@@ -254,6 +254,7 @@ public class Auxiliary {
                        ArrayList<Entity> entitys = (ArrayList<Entity>) par1World.loadedEntityList;
                        ArrayList<Entity> result = new ArrayList<Entity>();
                        for (int i = 0; i < entitys.size(); i++) {
+                               String a = "";
                                Entity entity = entitys.get(i);
                                double x = entity.posX;
                                double y = entity.posY;
@@ -282,6 +283,43 @@ public class Auxiliary {
                        return result;
                }
 
+               public static ArrayList<Entity> getTriangleEntitys(World par1World,
+                               double par2, double par3, double par4,
+                               double yaw,
+                               double pitch,
+                               double angle,
+                               double rad) {
+
+                       ArrayList<Entity> entitys = (ArrayList<Entity>) par1World.loadedEntityList;
+                       ArrayList<Entity> result = new ArrayList<Entity>();
+                       for (int i = 0; i < entitys.size(); i++) {
+                               String a = "";
+                               Entity entity = entitys.get(i);
+                               double x = entity.posX;
+                               double y = entity.posY;
+                               double z = entity.posZ;
+                               double bx = par2;
+                               double by = par3;
+                               double bz = par4;
+                               double playerToEntityAngleXZ = Math.sin(Math.atan2(bx - x, bz - z)) * 180;
+                               double playerToEntityAngleY = Math.toDegrees(Math.atan(y - by));
+                               double length =
+                                               Math.sqrt(
+                                                               Math.pow(Math.abs(bx - x), 2) +
+                                                               Math.pow(Math.abs(by - y), 2) +
+                                                               Math.pow(Math.abs(bz - z), 2));
+
+                               if (playerToEntityAngleXZ + angle/2 > playerToEntityAngleXZ && playerToEntityAngleXZ - angle/2 < playerToEntityAngleXZ) {
+                                       if (length < rad) {
+                                               result.add(entity);
+                                       }
+                               }
+
+                       }
+
+                       return result;
+               }
+
        }
 
 }