Advertisement
Corosus

Untitled

Sep 30th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.01 KB | None | 0 0
  1. public static void spin(Entity entity, Entity entity1) {
  2.         double maxHeight = tornadoHeight;
  3.         double radius = 10D;
  4.         double scale = tornadoWidthScale;
  5.         double d1 = entity.posX - entity1.posX;
  6.         double d2 = entity.posZ - entity1.posZ;
  7.         float f = (float)((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F;
  8.         float f1;
  9.  
  10.         for(f1 = f; f1 < -180F; f1 += 360F) { }
  11.  
  12.         for(; f1 >= 180F; f1 -= 360F) { }
  13.  
  14.         double distY = entity.posY - entity1.posY;
  15.         double distXZ = Math.sqrt(Math.abs(d1)) + Math.sqrt(Math.abs(d2));
  16.  
  17.         if(entity1.posY - entity.posY < 0.0D) {
  18.             distY = 1.0D;
  19.         } else {
  20.             distY = entity1.posY - entity.posY;
  21.         }
  22.  
  23.         if(distY > maxHeight) {
  24.             distY = maxHeight;
  25.         }
  26.  
  27.         double grab = (10D / getWeight(entity1))/* / ((distY / maxHeight) * 1D)*/ * ((Math.abs((maxHeight - distY)) / maxHeight));
  28.         float pullY = 0.0F;
  29.  
  30.         //some random y pull
  31.         if (entity.rand.nextInt(5) != 0) {
  32.             //pullY = 0.035F;
  33.         }
  34.  
  35.         if(distXZ > 5D) {
  36.             grab = grab * (radius / distXZ);
  37.         }
  38.  
  39.         pullY += (float)(tornadoLiftRate / (getWeight(entity1) / 2F)/* * (Math.abs(radius - distXZ) / radius)*/);
  40.         //} else {
  41.         //pullY = pullY / getWeight(entity1);
  42.         //}
  43.  
  44.         if  (entity1 instanceof EntityPlayer) {
  45.             double adjPull = 0.2D / ((getWeight(entity1) * ((distXZ+1D) / radius)));
  46.             /*if (!entity1.onGround) {
  47.                 adjPull /= (((float)(((double)playerInAirTime+1D) / 200D)) * 15D);
  48.  
  49.             }*/
  50.             pullY += adjPull;
  51.             //0.2D / ((getWeight(entity1) * ((distXZ+1D) / radius)) * (((distY) / maxHeight)) * 3D);
  52.             //grab = grab + (10D * ((distY / maxHeight) * 1D));
  53.             double adjGrab = (10D * (((float)(((double)playerInAirTime+1D) / 200D))));
  54.  
  55.             if (adjGrab > 50) {
  56.                 adjGrab = 50D;
  57.             }
  58.  
  59.             grab = grab - adjGrab;
  60.  
  61.             if (entity1.motionY > -2.0) {
  62.                 entity1.fallDistance = 0F;
  63.             }
  64.  
  65.             //System.out.println(adjPull);
  66.         } else if (entity1 instanceof EntityLiving) {
  67.             double adjPull = 0.005D / ((getWeight(entity1) * ((distXZ+1D) / radius)));
  68.             /*if (!entity1.onGround) {
  69.                 adjPull /= (((float)(((double)playerInAirTime+1D) / 200D)) * 15D);
  70.  
  71.             }*/
  72.             pullY -= adjPull;
  73.             //0.2D / ((getWeight(entity1) * ((distXZ+1D) / radius)) * (((distY) / maxHeight)) * 3D);
  74.             //grab = grab + (10D * ((distY / maxHeight) * 1D));
  75.             double adjGrab = (10D * (((float)(((double)(((EntityLiving)entity1).entityAge + 150)+1D) / 200D))));
  76.  
  77.             if (adjGrab > 50) {
  78.                 adjGrab = 50D;
  79.             }
  80.  
  81.             grab = grab - adjGrab;
  82.  
  83.             if (entity instanceof EntTornado) {
  84.             }
  85.  
  86.             if (entity1.motionY > -2.0) {
  87.                 entity1.fallDistance = 0F;
  88.             }
  89.  
  90.             //System.out.println(adjPull);
  91.         }
  92.  
  93.         f1 = (float)((double)f1 + (75D + grab - (10D * scale)));
  94.         float f3 = MathHelper.cos(-f1 * 0.01745329F - 3.141593F);
  95.         float f4 = MathHelper.sin(-f1 * 0.01745329F - 3.141593F);
  96.         float f5 = tornadoPullRate;
  97.  
  98.         if  (entity1 instanceof EntityPlayer || entity1 instanceof EntityLiving) {
  99.             f5 /= (getWeight(entity1) * ((distXZ+1D) / radius));
  100.         }
  101.  
  102.         float moveX = f3 * f5;
  103.         float moveZ = f4 * f5;
  104.         //tornado strength changes
  105.         pullY *= ((EntTornado)entity).strength / 100F;
  106.         setVel(entity1, -moveX, pullY, moveZ);
  107.         //player Yaxis safety check
  108.         /*if  (entity1 instanceof EntityPlayer && entity1.posY > 100D) {
  109.             entity1.posY = 100D;
  110.             //entity1.motionY -= 1.0D;
  111.             entity1.setPosition(entity1.posX, entity1.posY, entity1.posZ);
  112.         }*/
  113.     }
  114.     public static float getWeight(Entity entity1) {
  115.         if (entity1 instanceof MovingBlock) {
  116.             return 1.0F + ((float)((MovingBlock) entity1).age / 200);
  117.         }
  118.  
  119.         if (entity1 instanceof EntityPlayer) {
  120.             if (entity1.onGround || entity1.handleWaterMovement()) {
  121.                 playerInAirTime = 0;
  122.             } else {
  123.                 //System.out.println(playerInAirTime);
  124.                 playerInAirTime++;
  125.             }
  126.  
  127.             return 5.0F/* + ((float)(playerInAirTime / 200))*/;
  128.         }
  129.  
  130.         if (entity1 instanceof EntityFX) {
  131.             return 1.0F + ((float)((EntityFX) entity1).particleAge / 200);
  132.         }
  133.  
  134.         if (entity1 instanceof EntityLiving) {
  135.             if (entity1.onGround || entity1.handleWaterMovement()) {
  136.                 entity1.onGround = false;
  137.                 ((EntityLiving)entity1).entityAge = -150;
  138.             }
  139.  
  140.             if (!entToAge.containsKey(entity1)) {
  141.                 try {
  142.                     /*float stepdist = 0F;
  143.                     try {
  144.                         stepdist = (float)Float.valueOf(ModLoader.getPrivateValue(Entity.class, entity1, "b").toString()).floatValue();
  145.                     } catch (Exception ex) {
  146.                         stepdist = (float)Float.valueOf(ModLoader.getPrivateValue(Entity.class, entity1, "nextStepDistance").toString()).floatValue();
  147.                     }*/
  148.                     //entToAge.put(entity1, ((EntityLiving)entity1).entityAge);
  149.                     //entity1.onGround = false;
  150.                     //return 1.0F + ((entity1.distanceWalkedModified - stepdist) / 150);
  151.                 } catch (Exception ex) {
  152.                     //if (this.distanceWalkedModified > (float)this.nextStepDistance)
  153.                 }
  154.             }
  155.  
  156.             //System.out.println(((EntityLiving)entity1).entityAge+150);
  157.             //int age = ((Integer)entToAge.get(entity1)).intValue();
  158.             //System.out.println(age);
  159.             return 1.0F + ((((EntityLiving)entity1).entityAge + 150) / 50);
  160.         }
  161.  
  162.         return 1F;
  163.     }
  164.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement