Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void spin(Entity entity, WeatherEntityConfig conf, Entity entity1) {
- double maxHeight = tornadoHeight;
- double radius = 10D;
- double scale = conf.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)(conf.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 (entity1.motionY > -2.0) {
- entity1.fallDistance = 0F;
- }
- //System.out.println(adjPull);
- }
- if (debug) {
- //globals
- //tornadoMaxParticles = 2200;
- //tornadoMaxBlocks = 1000;
- //rarityOfDisintegrate = 150;
- //rarityOfBreakOnFall = 5;
- //mod_EntMover.activeTornado.getStorm().tor
- //temp debugs
- //tornadoInitialSpeed = 0.0F;
- //grabPlayer = false;
- //mod_EntMover.activeTornado.getStorm().tornadoInitialSpeed = 0.0F;
- }
- grab += conf.relTornadoSize;
- f1 = (float)((double)f1 + (75D + grab - (10D * scale)));
- float f3 = (float)Math.cos(-f1 * 0.01745329F - 3.141593F);
- float f4 = (float)Math.sin(-f1 * 0.01745329F - 3.141593F);
- float f5 = conf.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
- float str = 1F;
- if (entity instanceof EntTornado) {
- str = ((EntTornado)entity).strength;
- }
- pullY *= str / 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);
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement