public override void OnUpdate() { base.OnUpdate(); if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { float f = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ * motionZ); prevRotationYaw = rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D ) / 3.1415927410125732D); prevRotationPitch = rotationPitch = (float)((System.Math.Atan2(motionY, f) * 180D ) / 3.1415927410125732D); } int i = worldObj.GetBlockId(xTile, yTile, zTile); if (i > 0) { net.minecraft.src.Block.blocksList[i].SetBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); net.minecraft.src.AxisAlignedBB axisalignedbb = net.minecraft.src.Block.blocksList [i].GetCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); if (axisalignedbb != null && axisalignedbb.IsVecInXYZ(net.minecraft.src.Vec3D.CreateVector (posX, posY, posZ))) { inGround = true; } } if (arrowShake > 0) { arrowShake--; } if (inGround) { int j = worldObj.GetBlockId(xTile, yTile, zTile); int k = worldObj.GetBlockMetadata(xTile, yTile, zTile); if (j != inTile || k != field_28011_h) { inGround = false; motionX *= rand.NextFloat() * 0.2F; motionY *= rand.NextFloat() * 0.2F; motionZ *= rand.NextFloat() * 0.2F; ticksInGround = 0; ticksInAir = 0; return; } ticksInGround++; if (ticksInGround == 1200) { SetEntityDead(); } return; } ticksInAir++; net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ); net.minecraft.src.Vec3D vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX , posY + motionY, posZ + motionZ); net.minecraft.src.MovingObjectPosition movingobjectposition = worldObj.Func_28099_a (vec3d, vec3d1, false, true); vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ); vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX, posY + motionY, posZ + motionZ); if (movingobjectposition != null) { vec3d1 = net.minecraft.src.Vec3D.CreateVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } net.minecraft.src.Entity entity = null; List <Entity> 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.Count; l++) { net.minecraft.src.Entity entity1 = (net.minecraft.src.Entity)list[l]; if (!entity1.CanBeCollidedWith() || entity1 == owner && ticksInAir < 5) { continue; } float f4 = 0.3F; net.minecraft.src.AxisAlignedBB axisalignedbb1 = entity1.boundingBox.Expand(f4, f4 , f4); net.minecraft.src.MovingObjectPosition movingobjectposition1 = axisalignedbb1.Func_706_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 net.minecraft.src.MovingObjectPosition(entity); } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (movingobjectposition.entityHit.AttackEntityFrom(owner, 4)) { worldObj.PlaySoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.NextFloat() * 0.2F + 0.9F)); SetEntityDead(); } else { motionX *= -0.10000000149011612D; motionY *= -0.10000000149011612D; motionZ *= -0.10000000149011612D; rotationYaw += 180F; prevRotationYaw += 180F; ticksInAir = 0; } } else { xTile = movingobjectposition.blockX; yTile = movingobjectposition.blockY; zTile = movingobjectposition.blockZ; inTile = worldObj.GetBlockId(xTile, yTile, zTile); field_28011_h = worldObj.GetBlockMetadata(xTile, yTile, zTile); motionX = (float)(movingobjectposition.hitVec.xCoord - posX); motionY = (float)(movingobjectposition.hitVec.yCoord - posY); motionZ = (float)(movingobjectposition.hitVec.zCoord - posZ); float f1 = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ); posX -= (motionX / (double)f1) * 0.05000000074505806D; posY -= (motionY / (double)f1) * 0.05000000074505806D; posZ -= (motionZ / (double)f1) * 0.05000000074505806D; worldObj.PlaySoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.NextFloat() * 0.2F + 0.9F)); inGround = true; arrowShake = 7; } } posX += motionX; posY += motionY; posZ += motionZ; float f2 = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D) / 3.1415927410125732D ); for (rotationPitch = (float)((System.Math.Atan2(motionY, f2) * 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 f3 = 0.99F; float f5 = 0.03F; if (IsInWater()) { for (int i1 = 0; i1 < 4; i1++) { float f6 = 0.25F; worldObj.SpawnParticle("bubble", posX - motionX * (double)f6, posY - motionY * (double )f6, posZ - motionZ * (double)f6, motionX, motionY, motionZ); } f3 = 0.8F; } motionX *= f3; motionY *= f3; motionZ *= f3; motionY -= f5; SetPosition(posX, posY, posZ); }
public override void OnUpdate() { lastTickPosX = posX; lastTickPosY = posY; lastTickPosZ = posZ; base.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; ticksOnGround = 0; ticksInAir = 0; } else { ticksOnGround++; if (ticksOnGround == 1200) { SetEntityDead(); } return; } } else { ticksInAir++; } net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ); net.minecraft.src.Vec3D vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX , posY + motionY, posZ + motionZ); net.minecraft.src.MovingObjectPosition movingobjectposition = worldObj.RayTraceBlocks (vec3d, vec3d1); vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ); vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX, posY + motionY, posZ + motionZ); if (movingobjectposition != null) { vec3d1 = net.minecraft.src.Vec3D.CreateVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } if (!worldObj.singleplayerWorld) { net.minecraft.src.Entity entity = null; System.Collections.Generic.List <Entity> 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.Count; l++) { net.minecraft.src.Entity entity1 = (net.minecraft.src.Entity)list[l]; if (!entity1.CanBeCollidedWith() || entity1 == owner && ticksInAir < 5) { continue; } float f4 = 0.3F; net.minecraft.src.AxisAlignedBB axisalignedbb = entity1.boundingBox.Expand(f4, f4 , f4); net.minecraft.src.MovingObjectPosition movingobjectposition1 = axisalignedbb.Func_706_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 net.minecraft.src.MovingObjectPosition(entity); } } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (!movingobjectposition.entityHit.AttackEntityFrom(owner, 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 = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D) / 3.1415927410125732D ); for (rotationPitch = (float)((System.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; motionY *= f1; motionZ *= f1; motionY -= f2; SetPosition(posX, posY, posZ); }
public override void OnUpdate() { base.OnUpdate(); if (field_6149_an > 0) { double d = posX + (field_6148_ao - posX) / (double)field_6149_an; double d1 = posY + (field_6147_ap - posY) / (double)field_6149_an; double d2 = posZ + (field_6146_aq - posZ) / (double)field_6149_an; double d4; for (d4 = field_6145_ar - (double)rotationYaw; d4 < -180D; d4 += 360D) { } for (; d4 >= 180D; d4 -= 360D) { } rotationYaw += (float)(d4 / (double)field_6149_an); rotationPitch += (float)((field_6144_as - (double)rotationPitch) / (double)field_6149_an); field_6149_an--; SetPosition(d, d1, d2); SetRotation(rotationYaw, rotationPitch); return; } if (!worldObj.singleplayerWorld) { net.minecraft.src.ItemStack itemstack = angler.GetCurrentEquippedItem(); if (angler.isDead || !angler.IsEntityAlive() || itemstack == null || itemstack.GetItem () != net.minecraft.src.Item.FISHING_ROD || GetDistanceSqToEntity(angler) > 1024D) { SetEntityDead(); angler.fishEntity = null; return; } if (bobber != null) { if (bobber.isDead) { bobber = null; } else { posX = bobber.posX; posY = bobber.boundingBox.minY + (double)bobber.height * 0.80000000000000004D; posZ = bobber.posZ; return; } } } if (shake > 0) { shake--; } if (inGround) { int i = worldObj.GetBlockId(xTile, yTile, zTile); if (i != inTile) { inGround = false; motionX *= rand.NextFloat() * 0.2F; motionY *= rand.NextFloat() * 0.2F; motionZ *= rand.NextFloat() * 0.2F; ticksInGround = 0; ticksInAir = 0; } else { ticksInGround++; if (ticksInGround == 1200) { SetEntityDead(); } return; } } else { ticksInAir++; } net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ); net.minecraft.src.Vec3D vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX , posY + motionY, posZ + motionZ); net.minecraft.src.MovingObjectPosition movingobjectposition = worldObj.RayTraceBlocks (vec3d, vec3d1); vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ); vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX, posY + motionY, posZ + motionZ); if (movingobjectposition != null) { vec3d1 = net.minecraft.src.Vec3D.CreateVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } net.minecraft.src.Entity entity = null; System.Collections.Generic.List <Entity> list = worldObj.GetEntitiesWithinAABBExcludingEntity(this , boundingBox.AddCoord(motionX, motionY, motionZ).Expand(1.0D, 1.0D, 1.0D)); double d3 = 0.0D; for (int j = 0; j < list.Count; j++) { net.minecraft.src.Entity entity1 = (net.minecraft.src.Entity)list[j]; if (!entity1.CanBeCollidedWith() || entity1 == angler && ticksInAir < 5) { continue; } float f2 = 0.3F; net.minecraft.src.AxisAlignedBB axisalignedbb = entity1.boundingBox.Expand(f2, f2 , f2); net.minecraft.src.MovingObjectPosition movingobjectposition1 = axisalignedbb.Func_706_a (vec3d, vec3d1); if (movingobjectposition1 == null) { continue; } double d6 = vec3d.DistanceTo(movingobjectposition1.hitVec); if (d6 < d3 || d3 == 0.0D) { entity = entity1; d3 = d6; } } if (entity != null) { movingobjectposition = new net.minecraft.src.MovingObjectPosition(entity); } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (movingobjectposition.entityHit.AttackEntityFrom(angler, 0)) { bobber = movingobjectposition.entityHit; } } else { inGround = true; } } if (inGround) { return; } MoveEntity(motionX, motionY, motionZ); float f = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D) / 3.1415927410125732D ); for (rotationPitch = (float)((System.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.92F; if (onGround || isCollidedHorizontally) { f1 = 0.5F; } int k = 5; double d5 = 0.0D; for (int l = 0; l < k; l++) { double d8 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double )(l + 0)) / (double)k) - 0.125D) + 0.125D; double d9 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double )(l + 1)) / (double)k) - 0.125D) + 0.125D; net.minecraft.src.AxisAlignedBB axisalignedbb1 = net.minecraft.src.AxisAlignedBB. GetBoundingBoxFromPool(boundingBox.minX, d8, boundingBox.minZ, boundingBox.maxX, d9, boundingBox.maxZ); if (worldObj.IsAABBInMaterial(axisalignedbb1, net.minecraft.src.Material.water)) { d5 += 1.0D / (double)k; } } if (d5 > 0.0D) { if (ticksCatchable > 0) { ticksCatchable--; } else { char c = '\u01F4'; if (worldObj.CanLightningStrikeAt(net.minecraft.src.MathHelper.Floor_double(posX) , net.minecraft.src.MathHelper.Floor_double(posY) + 1, net.minecraft.src.MathHelper .Floor_double(posZ))) { c = '\u012C'; } if (rand.Next(c) == 0) { ticksCatchable = rand.Next(30) + 10; motionY -= 0.20000000298023224D; worldObj.PlaySoundAtEntity(this, "random.splash", 0.25F, 1.0F + (rand.NextFloat() - rand.NextFloat()) * 0.4F); float f3 = net.minecraft.src.MathHelper.Floor_double(boundingBox.minY); for (int i1 = 0; (float)i1 < 1.0F + width * 20F; i1++) { float f4 = (rand.NextFloat() * 2.0F - 1.0F) * width; float f6 = (rand.NextFloat() * 2.0F - 1.0F) * width; worldObj.SpawnParticle("bubble", posX + (double)f4, f3 + 1.0F, posZ + (double)f6, motionX, motionY - (double)(rand.NextFloat() * 0.2F), motionZ); } for (int j1 = 0; (float)j1 < 1.0F + width * 20F; j1++) { float f5 = (rand.NextFloat() * 2.0F - 1.0F) * width; float f7 = (rand.NextFloat() * 2.0F - 1.0F) * width; worldObj.SpawnParticle("splash", posX + (double)f5, f3 + 1.0F, posZ + (double)f7, motionX, motionY, motionZ); } } } } if (ticksCatchable > 0) { motionY -= (double)(rand.NextFloat() * rand.NextFloat() * rand.NextFloat()) * 0.20000000000000001D; } double d7 = d5 * 2D - 1.0D; motionY += 0.039999999105930328D * d7; if (d5 > 0.0D) { f1 = (float)((double)f1 * 0.90000000000000002D); motionY *= 0.80000000000000004D; } motionX *= f1; motionY *= f1; motionZ *= f1; SetPosition(posX, posY, posZ); }