public override MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { int l = world.getBlockMetadata(i, j, k) & 7; float f = 0.15F; if (l == 1) { setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); } else if (l == 2) { setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); } else if (l == 3) { setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); } else if (l == 4) { setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); } else { float f1 = 0.1F; setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1); } return(base.collisionRayTrace(world, i, j, k, vec3d, vec3d1)); }
public bool canEntityBeSeen(Entity entity) { return (worldObj.rayTraceBlocks(Vec3D.createVector(posX, posY + getEyeHeight(), posZ), Vec3D.createVector(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ)) == null); }
public double distanceTo(Vec3D vec3d) { double d = vec3d.xCoord - xCoord; double d1 = vec3d.yCoord - yCoord; double d2 = vec3d.zCoord - zCoord; return(MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2)); }
public override void velocityToAddToEntity(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { Vec3D vec3d1 = func_298_c(world, i, j, k); vec3d.xCoord += vec3d1.xCoord; vec3d.yCoord += vec3d1.yCoord; vec3d.zCoord += vec3d1.zCoord; }
public double squareDistanceTo(Vec3D vec3d) { double d = vec3d.xCoord - xCoord; double d1 = vec3d.yCoord - yCoord; double d2 = vec3d.zCoord - zCoord; return(d * d + d1 * d1 + d2 * d2); }
private bool isVecInXY(Vec3D vec3d) { if (vec3d == null) { return(false); } else { return(vec3d.xCoord >= minX && vec3d.xCoord <= maxX && vec3d.yCoord >= minY && vec3d.yCoord <= maxY); } }
private bool isVecInXZ(Vec3D vec3d) { if (vec3d == null) { return(false); } else { return(vec3d.xCoord >= minX && vec3d.xCoord <= maxX && vec3d.zCoord >= minZ && vec3d.zCoord <= maxZ); } }
private bool isVecInYZ(Vec3D vec3d) { if (vec3d == null) { return(false); } else { return(vec3d.yCoord >= minY && vec3d.yCoord <= maxY && vec3d.zCoord >= minZ && vec3d.zCoord <= maxZ); } }
public Vec3D getIntermediateWithZValue(Vec3D vec3d, double d) { double d1 = vec3d.xCoord - xCoord; double d2 = vec3d.yCoord - yCoord; double d3 = vec3d.zCoord - zCoord; if (d3 * d3 < 1.0000000116860974E-007D) { return(null); } double d4 = (d - zCoord) / d3; if (d4 < 0.0D || d4 > 1.0D) { return(null); } else { return(createVector(xCoord + d1 * d4, yCoord + d2 * d4, zCoord + d3 * d4)); } }
public Vec3D getLook(float f) { if (f == 1.0F) { float f1 = MathHelper.cos(-rotationYaw * 0.01745329F - 3.141593F); float f3 = MathHelper.sin(-rotationYaw * 0.01745329F - 3.141593F); float f5 = -MathHelper.cos(-rotationPitch * 0.01745329F); float f7 = MathHelper.sin(-rotationPitch * 0.01745329F); return(Vec3D.createVector(f3 * f5, f7, f1 * f5)); } else { float f2 = prevRotationPitch + (rotationPitch - prevRotationPitch) * f; float f4 = prevRotationYaw + (rotationYaw - prevRotationYaw) * f; float f6 = MathHelper.cos(-f4 * 0.01745329F - 3.141593F); float f8 = MathHelper.sin(-f4 * 0.01745329F - 3.141593F); float f9 = -MathHelper.cos(-f2 * 0.01745329F); float f10 = MathHelper.sin(-f2 * 0.01745329F); return(Vec3D.createVector(f8 * f9, f10, f6 * f9)); } }
public override bool attackEntityFrom(Entity entity, int i) { setBeenAttacked(); if (entity != null) { Vec3D vec3d = entity.getLookVec(); if (vec3d != null) { motionX = vec3d.xCoord; motionY = vec3d.yCoord; motionZ = vec3d.zCoord; field_9199_b = motionX * 0.10000000000000001D; field_9198_c = motionY * 0.10000000000000001D; field_9196_d = motionZ * 0.10000000000000001D; } return(true); } else { return(false); } }
public override MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { setBlockBoundsBasedOnState(world, i, j, k); return(base.collisionRayTrace(world, i, j, k, vec3d, vec3d1)); }
public virtual MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { setBlockBoundsBasedOnState(world, i, j, k); vec3d = vec3d.addVector(-i, -j, -k); vec3d1 = vec3d1.addVector(-i, -j, -k); Vec3D vec3d2 = vec3d.getIntermediateWithXValue(vec3d1, minX); Vec3D vec3d3 = vec3d.getIntermediateWithXValue(vec3d1, maxX); Vec3D vec3d4 = vec3d.getIntermediateWithYValue(vec3d1, minY); Vec3D vec3d5 = vec3d.getIntermediateWithYValue(vec3d1, maxY); Vec3D vec3d6 = vec3d.getIntermediateWithZValue(vec3d1, minZ); Vec3D vec3d7 = vec3d.getIntermediateWithZValue(vec3d1, maxZ); if (!isVecInsideYZBounds(vec3d2)) { vec3d2 = null; } if (!isVecInsideYZBounds(vec3d3)) { vec3d3 = null; } if (!isVecInsideXZBounds(vec3d4)) { vec3d4 = null; } if (!isVecInsideXZBounds(vec3d5)) { vec3d5 = null; } if (!isVecInsideXYBounds(vec3d6)) { vec3d6 = null; } if (!isVecInsideXYBounds(vec3d7)) { vec3d7 = null; } Vec3D vec3d8 = null; if (vec3d2 != null && (vec3d8 == null || vec3d.distanceTo(vec3d2) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d2; } if (vec3d3 != null && (vec3d8 == null || vec3d.distanceTo(vec3d3) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d3; } if (vec3d4 != null && (vec3d8 == null || vec3d.distanceTo(vec3d4) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d4; } if (vec3d5 != null && (vec3d8 == null || vec3d.distanceTo(vec3d5) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d5; } if (vec3d6 != null && (vec3d8 == null || vec3d.distanceTo(vec3d6) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d6; } if (vec3d7 != null && (vec3d8 == null || vec3d.distanceTo(vec3d7) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d7; } if (vec3d8 == null) { return(null); } sbyte byte0 = -1; if (vec3d8 == vec3d2) { byte0 = 4; } if (vec3d8 == vec3d3) { byte0 = 5; } if (vec3d8 == vec3d4) { byte0 = 0; } if (vec3d8 == vec3d5) { byte0 = 1; } if (vec3d8 == vec3d6) { byte0 = 2; } if (vec3d8 == vec3d7) { byte0 = 3; } return(new MovingObjectPosition(i, j, k, byte0, vec3d8.addVector(i, j, k))); }
public void doExplosion() { float f = explosionSize; int i = 16; for (int j = 0; j < i; j++) { for (int l = 0; l < i; l++) { for (int j1 = 0; j1 < i; j1++) { if (j != 0 && j != i - 1 && l != 0 && l != i - 1 && j1 != 0 && j1 != i - 1) { continue; } double d = (j / (i - 1.0F)) * 2.0F - 1.0F; double d1 = (l / (i - 1.0F)) * 2.0F - 1.0F; double d2 = (j1 / (i - 1.0F)) * 2.0F - 1.0F; double d3 = Math.sqrt(d * d + d1 * d1 + d2 * d2); d /= d3; d1 /= d3; d2 /= d3; float f1 = explosionSize * (0.7F + worldObj.rand.nextFloat() * 0.6F); double d5 = explosionX; double d7 = explosionY; double d9 = explosionZ; float f2 = 0.3F; do { if (f1 <= 0.0F) { goto label0; } int j4 = MathHelper.floor_double(d5); int k4 = MathHelper.floor_double(d7); int l4 = MathHelper.floor_double(d9); int i5 = worldObj.getBlockId(j4, k4, l4); if (i5 > 0) { f1 -= (Block.blocksList[i5].getExplosionResistance(exploder) + 0.3F) * f2; } if (f1 > 0.0F) { destroyedBlockPositions.add(new ChunkPosition(j4, k4, l4)); } d5 += d * f2; d7 += d1 * f2; d9 += d2 * f2; f1 -= f2 * 0.75F; } while (true); label0: ; } } } explosionSize *= 2.0F; int k = MathHelper.floor_double(explosionX - explosionSize - 1.0D); int i1 = MathHelper.floor_double(explosionX + explosionSize + 1.0D); int k1 = MathHelper.floor_double(explosionY - explosionSize - 1.0D); int l1 = MathHelper.floor_double(explosionY + explosionSize + 1.0D); int i2 = MathHelper.floor_double(explosionZ - explosionSize - 1.0D); int j2 = MathHelper.floor_double(explosionZ + explosionSize + 1.0D); List list = worldObj.getEntitiesWithinAABBExcludingEntity(exploder, AxisAlignedBB.getBoundingBoxFromPool(k, k1, i2, i1, l1, j2)); Vec3D vec3d = Vec3D.createVector(explosionX, explosionY, explosionZ); for (int k2 = 0; k2 < list.size(); k2++) { var entity = (Entity)list.get(k2); double d4 = entity.getDistance(explosionX, explosionY, explosionZ) / explosionSize; if (d4 <= 1.0D) { double d6 = entity.posX - explosionX; double d8 = entity.posY - explosionY; double d10 = entity.posZ - explosionZ; double d11 = MathHelper.sqrt_double(d6 * d6 + d8 * d8 + d10 * d10); d6 /= d11; d8 /= d11; d10 /= d11; double d12 = worldObj.func_494_a(vec3d, entity.boundingBox); double d13 = (1.0D - d4) * d12; entity.attackEntityFrom(exploder, (int)(((d13 * d13 + d13) / 2D) * 8D * explosionSize + 1.0D)); double d14 = d13; entity.motionX += d6 * d14; entity.motionY += d8 * d14; entity.motionZ += d10 * d14; } } explosionSize = f; var arraylist = new ArrayList(); arraylist.addAll(destroyedBlockPositions); if (isFlaming) { for (int l2 = arraylist.size() - 1; l2 >= 0; l2--) { var chunkposition = (ChunkPosition)arraylist.get(l2); int i3 = chunkposition.x; int j3 = chunkposition.y; int k3 = chunkposition.z; int l3 = worldObj.getBlockId(i3, j3, k3); int i4 = worldObj.getBlockId(i3, j3 - 1, k3); if (l3 == 0 && Block.opaqueCubeLookup[i4] && ExplosionRNG.nextInt(3) == 0) { worldObj.setBlockWithNotify(i3, j3, k3, Block.fire.blockID); } } } }
private Vec3D func_298_c(IBlockAccess iblockaccess, int i, int j, int k) { Vec3D vec3d = Vec3D.createVector(0.0D, 0.0D, 0.0D); int l = func_303_b(iblockaccess, i, j, k); for (int i1 = 0; i1 < 4; i1++) { int j1 = i; int k1 = j; int l1 = k; if (i1 == 0) { j1--; } if (i1 == 1) { l1--; } if (i1 == 2) { j1++; } if (i1 == 3) { l1++; } int i2 = func_303_b(iblockaccess, j1, k1, l1); if (i2 < 0) { if (iblockaccess.getBlockMaterial(j1, k1, l1).getIsSolid()) { continue; } i2 = func_303_b(iblockaccess, j1, k1 - 1, l1); if (i2 >= 0) { int j2 = i2 - (l - 8); vec3d = vec3d.addVector((j1 - i) * j2, (k1 - j) * j2, (l1 - k) * j2); } continue; } if (i2 >= 0) { int k2 = i2 - l; vec3d = vec3d.addVector((j1 - i) * k2, (k1 - j) * k2, (l1 - k) * k2); } } if (iblockaccess.getBlockMetadata(i, j, k) >= 8) { bool flag = false; if (flag || shouldSideBeRendered(iblockaccess, i, j, k - 1, 2)) { flag = true; } if (flag || shouldSideBeRendered(iblockaccess, i, j, k + 1, 3)) { flag = true; } if (flag || shouldSideBeRendered(iblockaccess, i - 1, j, k, 4)) { flag = true; } if (flag || shouldSideBeRendered(iblockaccess, i + 1, j, k, 5)) { flag = true; } if (flag || shouldSideBeRendered(iblockaccess, i, j + 1, k - 1, 2)) { flag = true; } if (flag || shouldSideBeRendered(iblockaccess, i, j + 1, k + 1, 3)) { flag = true; } if (flag || shouldSideBeRendered(iblockaccess, i - 1, j + 1, k, 4)) { flag = true; } if (flag || shouldSideBeRendered(iblockaccess, i + 1, j + 1, k, 5)) { flag = true; } if (flag) { vec3d = vec3d.normalize().addVector(0.0D, -6D, 0.0D); } } vec3d = vec3d.normalize(); return(vec3d); }
public Vec3D func_182_g(double d, double d1, double d2) { int i = MathHelper.floor_double(d); int j = MathHelper.floor_double(d1); int k = MathHelper.floor_double(d2); if (worldObj.getBlockId(i, j - 1, k) == Block.minecartTrack.blockID) { j--; } if (worldObj.getBlockId(i, j, k) == Block.minecartTrack.blockID) { int l = worldObj.getBlockMetadata(i, j, k); d1 = j; if (l >= 2 && l <= 5) { d1 = j + 1; } int[][] ai = field_468_ak[l]; double d3 = 0.0D; double d4 = i + 0.5D + ai[0][0] * 0.5D; double d5 = j + 0.5D + ai[0][1] * 0.5D; double d6 = k + 0.5D + ai[0][2] * 0.5D; double d7 = i + 0.5D + ai[1][0] * 0.5D; double d8 = j + 0.5D + ai[1][1] * 0.5D; double d9 = k + 0.5D + ai[1][2] * 0.5D; double d10 = d7 - d4; double d11 = (d8 - d5) * 2D; double d12 = d9 - d6; if (d10 == 0.0D) { d = i + 0.5D; d3 = d2 - k; } else if (d12 == 0.0D) { d2 = k + 0.5D; d3 = d - i; } else { double d13 = d - d4; double d14 = d2 - d6; double d15 = (d13 * d10 + d14 * d12) * 2D; d3 = d15; } d = d4 + d10 * d3; d1 = d5 + d11 * d3; d2 = d6 + d12 * d3; if (d11 < 0.0D) { d1++; } if (d11 > 0.0D) { d1 += 0.5D; } return(Vec3D.createVector(d, d1, d2)); } else { return(null); } }
public override void onUpdate() { if (field_9167_b > 0) { field_9167_b--; } if (damageTaken > 0) { damageTaken--; } if (worldObj.singleplayerWorld && field_9163_an > 0) { if (field_9163_an > 0) { double d = posX + (field_9162_ao - posX) / field_9163_an; double d1 = posY + (field_9161_ap - posY) / field_9163_an; double d3 = posZ + (field_9160_aq - posZ) / field_9163_an; double d4; for (d4 = field_9159_ar - rotationYaw; d4 < -180D; d4 += 360D) { } for (; d4 >= 180D; d4 -= 360D) { } rotationYaw += (float)(d4 / field_9163_an); rotationPitch += (float)((field_9158_as - rotationPitch) / field_9163_an); field_9163_an--; setPosition(d, d1, d3); setRotation(rotationYaw, rotationPitch); } else { setPosition(posX, posY, posZ); setRotation(rotationYaw, rotationPitch); } return; } prevPosX = posX; prevPosY = posY; prevPosZ = posZ; motionY -= 0.039999999105930328D; int i = MathHelper.floor_double(posX); int j = MathHelper.floor_double(posY); int k = MathHelper.floor_double(posZ); if (worldObj.getBlockId(i, j - 1, k) == Block.minecartTrack.blockID) { j--; } double d2 = 0.40000000000000002D; bool flag = false; double d5 = 0.0078125D; if (worldObj.getBlockId(i, j, k) == Block.minecartTrack.blockID) { Vec3D vec3d = func_182_g(posX, posY, posZ); int l = worldObj.getBlockMetadata(i, j, k); posY = j; if (l >= 2 && l <= 5) { posY = j + 1; } if (l == 2) { motionX -= d5; } if (l == 3) { motionX += d5; } if (l == 4) { motionZ += d5; } if (l == 5) { motionZ -= d5; } int[][] ai = field_468_ak[l]; double d8 = ai[1][0] - ai[0][0]; double d10 = ai[1][2] - ai[0][2]; double d11 = Math.sqrt(d8 * d8 + d10 * d10); double d12 = motionX * d8 + motionZ * d10; if (d12 < 0.0D) { d8 = -d8; d10 = -d10; } double d13 = Math.sqrt(motionX * motionX + motionZ * motionZ); motionX = (d13 * d8) / d11; motionZ = (d13 * d10) / d11; double d16 = 0.0D; double d17 = i + 0.5D + ai[0][0] * 0.5D; double d18 = k + 0.5D + ai[0][2] * 0.5D; double d19 = i + 0.5D + ai[1][0] * 0.5D; double d20 = k + 0.5D + ai[1][2] * 0.5D; d8 = d19 - d17; d10 = d20 - d18; if (d8 == 0.0D) { posX = i + 0.5D; d16 = posZ - k; } else if (d10 == 0.0D) { posZ = k + 0.5D; d16 = posX - i; } else { double d21 = posX - d17; double d23 = posZ - d18; double d25 = (d21 * d8 + d23 * d10) * 2D; d16 = d25; } posX = d17 + d8 * d16; posZ = d18 + d10 * d16; setPosition(posX, posY + yOffset, posZ); double d22 = motionX; double d24 = motionZ; if (riddenByEntity != null) { d22 *= 0.75D; d24 *= 0.75D; } if (d22 < -d2) { d22 = -d2; } if (d22 > d2) { d22 = d2; } if (d24 < -d2) { d24 = -d2; } if (d24 > d2) { d24 = d2; } moveEntity(d22, 0.0D, d24); if (ai[0][1] != 0 && MathHelper.floor_double(posX) - i == ai[0][0] && MathHelper.floor_double(posZ) - k == ai[0][2]) { setPosition(posX, posY + ai[0][1], posZ); } else if (ai[1][1] != 0 && MathHelper.floor_double(posX) - i == ai[1][0] && MathHelper.floor_double(posZ) - k == ai[1][2]) { setPosition(posX, posY + ai[1][1], posZ); } if (riddenByEntity != null) { motionX *= 0.99699997901916504D; motionY *= 0.0D; motionZ *= 0.99699997901916504D; } else { if (minecartType == 2) { double d26 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); if (d26 > 0.01D) { flag = true; pushX /= d26; pushZ /= d26; double d28 = 0.040000000000000001D; motionX *= 0.80000001192092896D; motionY *= 0.0D; motionZ *= 0.80000001192092896D; motionX += pushX * d28; motionZ += pushZ * d28; } else { motionX *= 0.89999997615814209D; motionY *= 0.0D; motionZ *= 0.89999997615814209D; } } motionX *= 0.95999997854232788D; motionY *= 0.0D; motionZ *= 0.95999997854232788D; } Vec3D vec3d1 = func_182_g(posX, posY, posZ); if (vec3d1 != null && vec3d != null) { double d27 = (vec3d.yCoord - vec3d1.yCoord) * 0.050000000000000003D; double d14 = Math.sqrt(motionX * motionX + motionZ * motionZ); if (d14 > 0.0D) { motionX = (motionX / d14) * (d14 + d27); motionZ = (motionZ / d14) * (d14 + d27); } setPosition(posX, vec3d1.yCoord, posZ); } int j1 = MathHelper.floor_double(posX); int k1 = MathHelper.floor_double(posZ); if (j1 != i || k1 != k) { double d15 = Math.sqrt(motionX * motionX + motionZ * motionZ); motionX = d15 * (j1 - i); motionZ = d15 * (k1 - k); } if (minecartType == 2) { double d29 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); if (d29 > 0.01D && motionX * motionX + motionZ * motionZ > 0.001D) { pushX /= d29; pushZ /= d29; if (pushX * motionX + pushZ * motionZ < 0.0D) { pushX = 0.0D; pushZ = 0.0D; } else { pushX = motionX; pushZ = motionZ; } } } } else { if (motionX < -d2) { motionX = -d2; } if (motionX > d2) { motionX = d2; } if (motionZ < -d2) { motionZ = -d2; } if (motionZ > d2) { motionZ = d2; } if (onGround) { motionX *= 0.5D; motionY *= 0.5D; motionZ *= 0.5D; } moveEntity(motionX, motionY, motionZ); if (!onGround) { motionX *= 0.94999998807907104D; motionY *= 0.94999998807907104D; motionZ *= 0.94999998807907104D; } } rotationPitch = 0.0F; double d6 = prevPosX - posX; double d7 = prevPosZ - posZ; if (d6 * d6 + d7 * d7 > 0.001D) { rotationYaw = (float)((Math.atan2(d7, d6) * 180D) / 3.1415926535897931D); if (field_469_aj) { rotationYaw += 180F; } } double d9; for (d9 = rotationYaw - prevRotationYaw; d9 >= 180D; d9 -= 360D) { } for (; d9 < -180D; d9 += 360D) { } if (d9 < -170D || d9 >= 170D) { rotationYaw += 180F; field_469_aj = !field_469_aj; } setRotation(rotationYaw, rotationPitch); List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); if (list != null && list.size() > 0) { for (int i1 = 0; i1 < list.size(); i1++) { var entity = (Entity)list.get(i1); if (entity != riddenByEntity && entity.canBePushed() && (entity is EntityMinecart)) { entity.applyEntityCollision(this); } } } if (riddenByEntity != null && riddenByEntity.isDead) { riddenByEntity = null; } if (flag && rand.nextInt(4) == 0) { fuel--; if (fuel < 0) { pushX = pushZ = 0.0D; } worldObj.spawnParticle("largesmoke", posX, posY + 0.80000000000000004D, posZ, 0.0D, 0.0D, 0.0D); } }
public virtual void velocityToAddToEntity(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { }
public override void onUpdate() { base.onUpdate(); if (field_6149_an > 0) { double d = posX + (field_6148_ao - posX) / field_6149_an; double d1 = posY + (field_6147_ap - posY) / field_6149_an; double d2 = posZ + (field_6146_aq - posZ) / field_6149_an; double d4; for (d4 = field_6145_ar - rotationYaw; d4 < -180D; d4 += 360D) { } for (; d4 >= 180D; d4 -= 360D) { } rotationYaw += (float)(d4 / field_6149_an); rotationPitch += (float)((field_6144_as - rotationPitch) / field_6149_an); field_6149_an--; setPosition(d, d1, d2); setRotation(rotationYaw, rotationPitch); return; } if (!worldObj.singleplayerWorld) { ItemStack itemstack = angler.getCurrentEquippedItem(); if (angler.isDead || !angler.isEntityAlive() || itemstack == null || itemstack.getItem() != Item.fishingRod || getDistanceSqToEntity(angler) > 1024D) { setEntityDead(); angler.fishEntity = null; return; } if (bobber != null) { if (bobber.isDead) { bobber = null; } else { posX = bobber.posX; posY = bobber.boundingBox.minY + 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++; } 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); } Entity entity = null; List 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.size(); j++) { var entity1 = (Entity)list.get(j); if (!entity1.canBeCollidedWith() || entity1 == angler && ticksInAir < 5) { continue; } float f2 = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2); 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 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 = 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.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) * (l + 0)) / k) - 0.125D) + 0.125D; double d9 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (l + 1)) / k) - 0.125D) + 0.125D; AxisAlignedBB axisalignedbb1 = AxisAlignedBB.getBoundingBoxFromPool(boundingBox.minX, d8, boundingBox.minZ, boundingBox.maxX, d9, boundingBox.maxZ); if (worldObj.isAABBInMaterial(axisalignedbb1, Material.water)) { d5 += 1.0D / k; } } if (d5 > 0.0D) { if (ticksCatchable > 0) { ticksCatchable--; } else if (rand.nextInt(500) == 0) { ticksCatchable = rand.nextInt(30) + 10; motionY -= 0.20000000298023224D; worldObj.playSoundAtEntity(this, "random.splash", 0.25F, 1.0F + (rand.nextFloat() - rand.nextFloat()) * 0.4F); float f3 = MathHelper.floor_double(boundingBox.minY); for (int i1 = 0; 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 + f4, f3 + 1.0F, posZ + f6, motionX, motionY - (rand.nextFloat() * 0.2F), motionZ); } for (int j1 = 0; 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 + f5, f3 + 1.0F, posZ + f7, motionX, motionY, motionZ); } } } if (ticksCatchable > 0) { motionY -= (rand.nextFloat() * rand.nextFloat() * rand.nextFloat()) * 0.20000000000000001D; } double d7 = d5 * 2D - 1.0D; motionY += 0.039999999105930328D * d7; if (d5 > 0.0D) { f1 = (float)(f1 * 0.90000000000000002D); motionY *= 0.80000000000000004D; } motionX *= f1; motionY *= f1; motionZ *= f1; setPosition(posX, posY, posZ); }
public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { float f = 1.0F; float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f; float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f; double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * f; double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * f + 1.6200000000000001D) - entityplayer.yOffset; double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * f; Vec3D vec3d = Vec3D.createVector(d, d1, d2); float f3 = MathHelper.cos(-f2 * 0.01745329F - 3.141593F); float f4 = MathHelper.sin(-f2 * 0.01745329F - 3.141593F); float f5 = -MathHelper.cos(-f1 * 0.01745329F); float f6 = MathHelper.sin(-f1 * 0.01745329F); float f7 = f4 * f5; float f8 = f6; float f9 = f3 * f5; double d3 = 5D; Vec3D vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3); MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do(vec3d, vec3d1, isFull == 0); if (movingobjectposition == null) { return(itemstack); } if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (!world.canMineBlock(entityplayer, i, j, k)) { return(itemstack); } if (isFull == 0) { if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0) { world.setBlockWithNotify(i, j, k, 0); return(new ItemStack(bucketWater)); } if (world.getBlockMaterial(i, j, k) == Material.lava && world.getBlockMetadata(i, j, k) == 0) { world.setBlockWithNotify(i, j, k, 0); return(new ItemStack(bucketLava)); } } else { if (isFull < 0) { return(new ItemStack(bucketEmpty)); } if (movingobjectposition.sideHit == 0) { j--; } if (movingobjectposition.sideHit == 1) { j++; } if (movingobjectposition.sideHit == 2) { k--; } if (movingobjectposition.sideHit == 3) { k++; } if (movingobjectposition.sideHit == 4) { i--; } if (movingobjectposition.sideHit == 5) { i++; } if (world.isAirBlock(i, j, k) || !world.getBlockMaterial(i, j, k).isSolid()) { if (world.worldProvider.isHellWorld && isFull == Block.waterStill.blockID) { world.playSoundEffect(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); for (int l = 0; l < 8; l++) { world.spawnParticle("largesmoke", i + Math.random(), j + Math.random(), k + Math.random(), 0.0D, 0.0D, 0.0D); } } else { world.setBlockAndMetadataWithNotify(i, j, k, isFull, 0); } return(new ItemStack(bucketEmpty)); } } } else if (isFull == 0 && (movingobjectposition.entityHit is EntityCow)) { return(new ItemStack(bucketMilk)); } return(itemstack); }
public override void updatePlayerActionState() { if (worldObj.difficultySetting == 0) { setEntityDead(); } prevAttackCounter = attackCounter; double d = waypointX - posX; double d1 = waypointY - posY; double d2 = waypointZ - posZ; double d3 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2); if (d3 < 1.0D || d3 > 60D) { waypointX = posX + ((rand.nextFloat() * 2.0F - 1.0F) * 16F); waypointY = posY + ((rand.nextFloat() * 2.0F - 1.0F) * 16F); waypointZ = posZ + ((rand.nextFloat() * 2.0F - 1.0F) * 16F); } if (courseChangeCooldown-- <= 0) { courseChangeCooldown += rand.nextInt(5) + 2; if (isCourseTraversable(waypointX, waypointY, waypointZ, d3)) { motionX += (d / d3) * 0.10000000000000001D; motionY += (d1 / d3) * 0.10000000000000001D; motionZ += (d2 / d3) * 0.10000000000000001D; } else { waypointX = posX; waypointY = posY; waypointZ = posZ; } } if (targetedEntity != null && targetedEntity.isDead) { targetedEntity = null; } if (targetedEntity == null || aggroCooldown-- <= 0) { targetedEntity = worldObj.getClosestPlayerToEntity(this, 100D); if (targetedEntity != null) { aggroCooldown = 20; } } double d4 = 64D; if (targetedEntity != null && targetedEntity.getDistanceSqToEntity(this) < d4 * d4) { double d5 = targetedEntity.posX - posX; double d6 = (targetedEntity.boundingBox.minY + (targetedEntity.height / 2.0F)) - (posY + (height / 2.0F)); double d7 = targetedEntity.posZ - posZ; renderYawOffset = rotationYaw = (-(float)Math.atan2(d5, d7) * 180F) / 3.141593F; if (canEntityBeSeen(targetedEntity)) { if (attackCounter == 10) { worldObj.playSoundAtEntity(this, "mob.ghast.charge", getSoundVolume(), (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); } attackCounter++; if (attackCounter == 20) { worldObj.playSoundAtEntity(this, "mob.ghast.fireball", getSoundVolume(), (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); var entityfireball = new EntityFireball(worldObj, this, d5, d6, d7); double d8 = 4D; Vec3D vec3d = getLook(1.0F); entityfireball.posX = posX + vec3d.xCoord * d8; entityfireball.posY = posY + (height / 2.0F) + 0.5D; entityfireball.posZ = posZ + vec3d.zCoord * d8; worldObj.entityJoinedWorld(entityfireball); attackCounter = -40; } } else if (attackCounter > 0) { attackCounter--; } } else { renderYawOffset = rotationYaw = (-(float)Math.atan2(motionX, motionZ) * 180F) / 3.141593F; if (attackCounter > 0) { attackCounter--; } } texture = attackCounter <= 10 ? "/mob/ghast.png" : "/mob/ghast_fire.png"; }
public override void onUpdate() { lastTickPosX = posX; lastTickPosY = posY; lastTickPosZ = posZ; base.onUpdate(); 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; field_20081_ak = 0; field_20079_al = 0; } else { field_20081_ak++; if (field_20081_ak == 1200) { setEntityDead(); } return; } } else { field_20079_al++; } 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.singleplayerWorld) { 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 i1 = 0; i1 < list.size(); i1++) { var entity1 = (Entity)list.get(i1); if (!entity1.canBeCollidedWith() || entity1 == field_20083_aj && field_20079_al < 5) { continue; } float f4 = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f4, f4, f4); 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 MovingObjectPosition(entity); } } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (!movingobjectposition.entityHit.attackEntityFrom(field_20083_aj, 0)) { ; } } if (!worldObj.singleplayerWorld && rand.nextInt(8) == 0) { byte byte0 = 1; if (rand.nextInt(32) == 0) { byte0 = 4; } for (int k = 0; k < byte0; k++) { var entitychicken = new EntityChicken(worldObj); entitychicken.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F); worldObj.entityJoinedWorld(entitychicken); } } 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 (handleWaterMovement()) { for (int l = 0; l < 4; l++) { float f3 = 0.25F; worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3, posZ - motionZ * 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(); fire = 10; 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; field_9190_an = 0; ticksInAir = 0; } else { field_9190_an++; if (field_9190_an == 1200) { setEntityDead(); } return; } } else { ticksInAir++; } 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); } 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 j = 0; j < list.size(); j++) { var entity1 = (Entity)list.get(j); if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 25) { continue; } float f2 = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2); 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 MovingObjectPosition(entity); } if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { if (!movingobjectposition.entityHit.attackEntityFrom(owner, 0)) { ; } } worldObj.newExplosion(null, posX, posY, posZ, 1.0F, true); 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.95F; if (handleWaterMovement()) { for (int k = 0; k < 4; k++) { float f3 = 0.25F; worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3, posZ - motionZ * f3, motionX, motionY, motionZ); } f1 = 0.8F; } motionX += field_9199_b; motionY += field_9198_c; motionZ += field_9196_d; motionX *= f1; motionY *= f1; motionZ *= f1; worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D); setPosition(posX, posY, posZ); }
public override void onUpdate() { base.onUpdate(); if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); prevRotationYaw = rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D); prevRotationPitch = rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); } if (arrowShake > 0) { arrowShake--; } 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++; } 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); } 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 j = 0; j < list.size(); j++) { var entity1 = (Entity)list.get(j); if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5) { continue; } float f4 = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f4, f4, f4); 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 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); motionX = (float)(movingobjectposition.hitVec.xCoord - posX); motionY = (float)(movingobjectposition.hitVec.yCoord - posY); motionZ = (float)(movingobjectposition.hitVec.zCoord - posZ); float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ); posX -= (motionX / f1) * 0.05000000074505806D; posY -= (motionY / f1) * 0.05000000074505806D; posZ -= (motionZ / 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 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D); for (rotationPitch = (float)((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 (handleWaterMovement()) { for (int k = 0; k < 4; k++) { float f6 = 0.25F; worldObj.spawnParticle("bubble", posX - motionX * f6, posY - motionY * f6, posZ - motionZ * f6, motionX, motionY, motionZ); } f3 = 0.8F; } motionX *= f3; motionY *= f3; motionZ *= f3; motionY -= f5; setPosition(posX, posY, posZ); }
public override void velocityToAddToEntity(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { modelBlock.velocityToAddToEntity(world, i, j, k, entity, vec3d); }
public override void updatePlayerActionState() { hasAttacked = false; float f = 16F; if (playerToAttack == null) { playerToAttack = findPlayerToAttack(); if (playerToAttack != null) { pathToEntity = worldObj.getPathToEntity(this, playerToAttack, f); } } else if (!playerToAttack.isEntityAlive()) { playerToAttack = null; } else { float f1 = playerToAttack.getDistanceToEntity(this); if (canEntityBeSeen(playerToAttack)) { attackEntity(playerToAttack, f1); } } if (!hasAttacked && playerToAttack != null && (pathToEntity == null || rand.nextInt(20) == 0)) { pathToEntity = worldObj.getPathToEntity(this, playerToAttack, f); } else if (pathToEntity == null && rand.nextInt(80) == 0 || rand.nextInt(80) == 0) { bool flag = false; int j = -1; int k = -1; int l = -1; float f2 = -99999F; for (int i1 = 0; i1 < 10; i1++) { int j1 = MathHelper.floor_double((posX + rand.nextInt(13)) - 6D); int k1 = MathHelper.floor_double((posY + rand.nextInt(7)) - 3D); int l1 = MathHelper.floor_double((posZ + rand.nextInt(13)) - 6D); float f3 = getBlockPathWeight(j1, k1, l1); if (f3 > f2) { f2 = f3; j = j1; k = k1; l = l1; flag = true; } } if (flag) { pathToEntity = worldObj.getEntityPathToXYZ(this, j, k, l, 10F); } } int i = MathHelper.floor_double(boundingBox.minY); bool flag1 = handleWaterMovement(); bool flag2 = handleLavaMovement(); rotationPitch = 0.0F; if (pathToEntity == null || rand.nextInt(100) == 0) { base.updatePlayerActionState(); pathToEntity = null; return; } Vec3D vec3d = pathToEntity.getPosition(this); for (double d = width * 2.0F; vec3d != null && vec3d.squareDistanceTo(posX, vec3d.yCoord, posZ) < d * d;) { pathToEntity.incrementPathIndex(); if (pathToEntity.isFinished()) { vec3d = null; pathToEntity = null; } else { vec3d = pathToEntity.getPosition(this); } } isJumping = false; if (vec3d != null) { double d1 = vec3d.xCoord - posX; double d2 = vec3d.zCoord - posZ; double d3 = vec3d.yCoord - i; float f4 = (float)((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F; float f5 = f4 - rotationYaw; moveForward = moveSpeed; for (; f5 < -180F; f5 += 360F) { } for (; f5 >= 180F; f5 -= 360F) { } if (f5 > 30F) { f5 = 30F; } if (f5 < -30F) { f5 = -30F; } rotationYaw += f5; if (hasAttacked && playerToAttack != null) { double d4 = playerToAttack.posX - posX; double d5 = playerToAttack.posZ - posZ; float f7 = rotationYaw; rotationYaw = (float)((Math.atan2(d5, d4) * 180D) / 3.1415927410125732D) - 90F; float f6 = (((f7 - rotationYaw) + 90F) * 3.141593F) / 180F; moveStrafing = -MathHelper.sin(f6) * moveForward * 1.0F; moveForward = MathHelper.cos(f6) * moveForward * 1.0F; } if (d3 > 0.0D) { isJumping = true; } } if (playerToAttack != null) { faceEntity(playerToAttack, 30F); } if (isCollidedHorizontally) { isJumping = true; } if (rand.nextFloat() < 0.8F && (flag1 || flag2)) { isJumping = true; } }
public MovingObjectPosition func_706_a(Vec3D vec3d, Vec3D vec3d1) { Vec3D vec3d2 = vec3d.getIntermediateWithXValue(vec3d1, minX); Vec3D vec3d3 = vec3d.getIntermediateWithXValue(vec3d1, maxX); Vec3D vec3d4 = vec3d.getIntermediateWithYValue(vec3d1, minY); Vec3D vec3d5 = vec3d.getIntermediateWithYValue(vec3d1, maxY); Vec3D vec3d6 = vec3d.getIntermediateWithZValue(vec3d1, minZ); Vec3D vec3d7 = vec3d.getIntermediateWithZValue(vec3d1, maxZ); if (!isVecInYZ(vec3d2)) { vec3d2 = null; } if (!isVecInYZ(vec3d3)) { vec3d3 = null; } if (!isVecInXZ(vec3d4)) { vec3d4 = null; } if (!isVecInXZ(vec3d5)) { vec3d5 = null; } if (!isVecInXY(vec3d6)) { vec3d6 = null; } if (!isVecInXY(vec3d7)) { vec3d7 = null; } Vec3D vec3d8 = null; if (vec3d2 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d2) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d2; } if (vec3d3 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d3) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d3; } if (vec3d4 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d4) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d4; } if (vec3d5 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d5) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d5; } if (vec3d6 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d6) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d6; } if (vec3d7 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d7) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d7; } if (vec3d8 == null) { return(null); } sbyte byte0 = -1; if (vec3d8 == vec3d2) { byte0 = 4; } if (vec3d8 == vec3d3) { byte0 = 5; } if (vec3d8 == vec3d4) { byte0 = 0; } if (vec3d8 == vec3d5) { byte0 = 1; } if (vec3d8 == vec3d6) { byte0 = 2; } if (vec3d8 == vec3d7) { byte0 = 3; } return(new MovingObjectPosition(0, 0, 0, byte0, vec3d8)); }