Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onUpdate()
- {
- lastTickPosX = posX;
- lastTickPosY = posY;
- lastTickPosZ = posZ;
- super.onUpdate();
- if(shakeSnowball > 0)
- {
- shakeSnowball--;
- }
- if(inGroundSnowball)
- {
- int i = worldObj.getBlockId(xTileSnowball, yTileSnowball, zTileSnowball);
- if(i != inTileSnowball)
- {
- inGroundSnowball = false;
- motionX *= rand.nextFloat() * 0.2F;
- motionY *= rand.nextFloat() * 0.2F;
- motionZ *= rand.nextFloat() * 0.2F;
- ticksInGroundSnowball = 0;
- ticksInAirSnowball = 0;
- } else
- {
- ticksInGroundSnowball++;
- if(ticksInGroundSnowball == 1200)
- {
- setEntityDead();
- }
- return;
- }
- } else
- {
- ticksInAirSnowball++;
- }
- Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
- Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
- MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
- vec3d = Vec3D.createVector(posX, posY, posZ);
- vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
- if(movingobjectposition != null)
- {
- vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
- }
- if(!worldObj.multiplayerWorld)
- {
- Entity entity = null;
- List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
- double d = 0.0D;
- for(int l = 0; l < list.size(); l++)
- {
- Entity entity1 = (Entity)list.get(l);
- if(!entity1.canBeCollidedWith() || entity1 == shootingEntity && ticksInAirSnowball < 5)
- {
- continue;
- }
- float f4 = 0.3F;
- AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f4, f4, f4);
- MovingObjectPosition movingobjectposition1 = axisalignedbb.func_1169_a(vec3d, vec3d1);
- if(movingobjectposition1 == null)
- {
- continue;
- }
- double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
- if(d1 < d || d == 0.0D)
- {
- entity = entity1;
- d = d1;
- }
- }
- if(entity != null)
- {
- movingobjectposition = new MovingObjectPosition(entity);
- }
- }
- if(movingobjectposition != null)
- {
- if(movingobjectposition.entityHit != null)
- {
- if(!movingobjectposition.entityHit.attackEntityFrom(DamageSource.func_35524_a(this, shootingEntity), 0));
- }
- for(int j = 0; j < 8; j++)
- {
- worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
- }
- setEntityDead();
- }
- posX += motionX;
- posY += motionY;
- posZ += motionZ;
- float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
- rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
- for(rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) { }
- for(; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) { }
- for(; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) { }
- for(; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) { }
- rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
- rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
- float f1 = 0.99F;
- float f2 = 0.03F;
- if(isInWater())
- {
- for(int k = 0; k < 4; k++)
- {
- float f3 = 0.25F;
- worldObj.spawnParticle("bubble", posX - motionX * (double)f3, posY - motionY * (double)f3, posZ - motionZ * (double)f3, motionX, motionY, motionZ);
- }
- f1 = 0.8F;
- }
- motionX *= f1+5F;
- motionZ *= f1+5F;
- setPosition(posX, posY, posZ);
- }
Add Comment
Please, Sign In to add comment