Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void spin(Entity entity, Entity entity1) {
- double maxHeight = tornadoHeight;
- double radius = 10D;
- double scale = tornadoWidthScale;
- double d1 = entity.posX - entity1.posX;
- double d2 = entity.posZ - entity1.posZ;
- float f = (float)((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F;
- float f1;
- for(f1 = f; f1 < -180F; f1 += 360F) { }
- for(; f1 >= 180F; f1 -= 360F) { }
- double distY = entity.posY - entity1.posY;
- double distXZ = Math.sqrt(Math.abs(d1)) + Math.sqrt(Math.abs(d2));
- if(entity1.posY - entity.posY < 0.0D) {
- distY = 1.0D;
- } else {
- distY = entity1.posY - entity.posY;
- }
- if(distY > maxHeight) {
- distY = maxHeight;
- }
- double grab = (10D / getWeight(entity1))/* / ((distY / maxHeight) * 1D)*/ * ((Math.abs((maxHeight - distY)) / maxHeight));
- float pullY = 0.0F;
- //some random y pull
- if (entity.rand.nextInt(5) != 0) {
- //pullY = 0.035F;
- }
- if(distXZ > 5D) {
- grab = grab * (radius / distXZ);
- }
- pullY += (float)(tornadoLiftRate / (getWeight(entity1) / 2F)/* * (Math.abs(radius - distXZ) / radius)*/);
- //} else {
- //pullY = pullY / getWeight(entity1);
- //}
- if (entity1 instanceof EntityPlayer) {
- double adjPull = 0.2D / ((getWeight(entity1) * ((distXZ+1D) / radius)));
- /*if (!entity1.onGround) {
- adjPull /= (((float)(((double)playerInAirTime+1D) / 200D)) * 15D);
- }*/
- pullY += adjPull;
- //0.2D / ((getWeight(entity1) * ((distXZ+1D) / radius)) * (((distY) / maxHeight)) * 3D);
- //grab = grab + (10D * ((distY / maxHeight) * 1D));
- double adjGrab = (10D * (((float)(((double)playerInAirTime+1D) / 200D))));
- if (adjGrab > 50) {
- adjGrab = 50D;
- }
- grab = grab - adjGrab;
- if (entity1.motionY > -2.0) {
- entity1.fallDistance = 0F;
- }
- //System.out.println(adjPull);
- } else if (entity1 instanceof EntityLiving) {
- double adjPull = 0.005D / ((getWeight(entity1) * ((distXZ+1D) / radius)));
- /*if (!entity1.onGround) {
- adjPull /= (((float)(((double)playerInAirTime+1D) / 200D)) * 15D);
- }*/
- pullY -= adjPull;
- //0.2D / ((getWeight(entity1) * ((distXZ+1D) / radius)) * (((distY) / maxHeight)) * 3D);
- //grab = grab + (10D * ((distY / maxHeight) * 1D));
- double adjGrab = (10D * (((float)(((double)(((EntityLiving)entity1).entityAge + 150)+1D) / 200D))));
- if (adjGrab > 50) {
- adjGrab = 50D;
- }
- grab = grab - adjGrab;
- if (entity instanceof EntTornado) {
- }
- if (entity1.motionY > -2.0) {
- entity1.fallDistance = 0F;
- }
- //System.out.println(adjPull);
- }
- f1 = (float)((double)f1 + (75D + grab - (10D * scale)));
- float f3 = MathHelper.cos(-f1 * 0.01745329F - 3.141593F);
- float f4 = MathHelper.sin(-f1 * 0.01745329F - 3.141593F);
- float f5 = tornadoPullRate;
- if (entity1 instanceof EntityPlayer || entity1 instanceof EntityLiving) {
- f5 /= (getWeight(entity1) * ((distXZ+1D) / radius));
- }
- float moveX = f3 * f5;
- float moveZ = f4 * f5;
- //tornado strength changes
- pullY *= ((EntTornado)entity).strength / 100F;
- setVel(entity1, -moveX, pullY, moveZ);
- //player Yaxis safety check
- /*if (entity1 instanceof EntityPlayer && entity1.posY > 100D) {
- entity1.posY = 100D;
- //entity1.motionY -= 1.0D;
- entity1.setPosition(entity1.posX, entity1.posY, entity1.posZ);
- }*/
- }
- public static float getWeight(Entity entity1) {
- if (entity1 instanceof MovingBlock) {
- return 1.0F + ((float)((MovingBlock) entity1).age / 200);
- }
- if (entity1 instanceof EntityPlayer) {
- if (entity1.onGround || entity1.handleWaterMovement()) {
- playerInAirTime = 0;
- } else {
- //System.out.println(playerInAirTime);
- playerInAirTime++;
- }
- return 5.0F/* + ((float)(playerInAirTime / 200))*/;
- }
- if (entity1 instanceof EntityFX) {
- return 1.0F + ((float)((EntityFX) entity1).particleAge / 200);
- }
- if (entity1 instanceof EntityLiving) {
- if (entity1.onGround || entity1.handleWaterMovement()) {
- entity1.onGround = false;
- ((EntityLiving)entity1).entityAge = -150;
- }
- if (!entToAge.containsKey(entity1)) {
- try {
- /*float stepdist = 0F;
- try {
- stepdist = (float)Float.valueOf(ModLoader.getPrivateValue(Entity.class, entity1, "b").toString()).floatValue();
- } catch (Exception ex) {
- stepdist = (float)Float.valueOf(ModLoader.getPrivateValue(Entity.class, entity1, "nextStepDistance").toString()).floatValue();
- }*/
- //entToAge.put(entity1, ((EntityLiving)entity1).entityAge);
- //entity1.onGround = false;
- //return 1.0F + ((entity1.distanceWalkedModified - stepdist) / 150);
- } catch (Exception ex) {
- //if (this.distanceWalkedModified > (float)this.nextStepDistance)
- }
- }
- //System.out.println(((EntityLiving)entity1).entityAge+150);
- //int age = ((Integer)entToAge.get(entity1)).intValue();
- //System.out.println(age);
- return 1.0F + ((((EntityLiving)entity1).entityAge + 150) / 50);
- }
- return 1F;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement