Guest User

Untitled

a guest
Feb 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.61 KB | None | 0 0
  1.     public void onUpdate()
  2.     {
  3.         lastTickPosX = posX;
  4.         lastTickPosY = posY;
  5.         lastTickPosZ = posZ;
  6.         super.onUpdate();
  7.         if(shakeSnowball > 0)
  8.         {
  9.             shakeSnowball--;
  10.         }
  11.         if(inGroundSnowball)
  12.         {
  13.             int i = worldObj.getBlockId(xTileSnowball, yTileSnowball, zTileSnowball);
  14.             if(i != inTileSnowball)
  15.             {
  16.                 inGroundSnowball = false;
  17.                 motionX *= rand.nextFloat() * 0.2F;
  18.                 motionY *= rand.nextFloat() * 0.2F;
  19.                 motionZ *= rand.nextFloat() * 0.2F;
  20.                 ticksInGroundSnowball = 0;
  21.                 ticksInAirSnowball = 0;
  22.             } else
  23.             {
  24.                 ticksInGroundSnowball++;
  25.                 if(ticksInGroundSnowball == 1200)
  26.                 {
  27.                     setEntityDead();
  28.                 }
  29.                 return;
  30.             }
  31.         } else
  32.         {
  33.             ticksInAirSnowball++;
  34.         }
  35.         Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
  36.         Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
  37.         MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
  38.         vec3d = Vec3D.createVector(posX, posY, posZ);
  39.         vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
  40.         if(movingobjectposition != null)
  41.         {
  42.             vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
  43.         }
  44.         if(!worldObj.multiplayerWorld)
  45.         {
  46.             Entity entity = null;
  47.             List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
  48.             double d = 0.0D;
  49.             for(int l = 0; l < list.size(); l++)
  50.             {
  51.                 Entity entity1 = (Entity)list.get(l);
  52.                 if(!entity1.canBeCollidedWith() || entity1 == shootingEntity && ticksInAirSnowball < 5)
  53.                 {
  54.                     continue;
  55.                 }
  56.                 float f4 = 0.3F;
  57.                 AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f4, f4, f4);
  58.                 MovingObjectPosition movingobjectposition1 = axisalignedbb.func_1169_a(vec3d, vec3d1);
  59.                 if(movingobjectposition1 == null)
  60.                 {
  61.                     continue;
  62.                 }
  63.                 double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
  64.                 if(d1 < d || d == 0.0D)
  65.                 {
  66.                     entity = entity1;
  67.                     d = d1;
  68.                 }
  69.             }
  70.  
  71.             if(entity != null)
  72.             {
  73.                 movingobjectposition = new MovingObjectPosition(entity);
  74.             }
  75.         }
  76.         if(movingobjectposition != null)
  77.         {
  78.             if(movingobjectposition.entityHit != null)
  79.             {
  80.                 if(!movingobjectposition.entityHit.attackEntityFrom(DamageSource.func_35524_a(this, shootingEntity), 0));
  81.             }
  82.             for(int j = 0; j < 8; j++)
  83.             {
  84.                 worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
  85.             }
  86.  
  87.             setEntityDead();
  88.         }
  89.         posX += motionX;
  90.         posY += motionY;
  91.         posZ += motionZ;
  92.         float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
  93.         rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
  94.         for(rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) { }
  95.         for(; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) { }
  96.         for(; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) { }
  97.         for(; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) { }
  98.         rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
  99.         rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
  100.         float f1 = 0.99F;
  101.         float f2 = 0.03F;
  102.         if(isInWater())
  103.         {
  104.             for(int k = 0; k < 4; k++)
  105.             {
  106.                 float f3 = 0.25F;
  107.                 worldObj.spawnParticle("bubble", posX - motionX * (double)f3, posY - motionY * (double)f3, posZ - motionZ * (double)f3, motionX, motionY, motionZ);
  108.             }
  109.  
  110.             f1 = 0.8F;
  111.         }
  112.         motionX *= f1+5F;
  113.         motionZ *= f1+5F;
  114.         setPosition(posX, posY, posZ);
  115.     }
Add Comment
Please, Sign In to add comment