/** Called when a lightning bolt hits the entity. */ public void onStruckByLightning(EntityLightningBolt par1EntityLightningBolt) { dealFireDamage(5); fire++; if (fire == 0) { setFire(8); } }
/** Tries to moves the entity by the passed in displacement. Args: x, y, z */ public void moveEntity(double par1, double par3, double par5) { if (noClip) { boundingBox.offset(par1, par3, par5); posX = (boundingBox.minX + boundingBox.maxX) / 2D; posY = (boundingBox.minY + (double) yOffset) - (double) ySize; posZ = (boundingBox.minZ + boundingBox.maxZ) / 2D; return; } Profiler.startSection("move"); ySize *= 0.4F; double d = posX; double d1 = posZ; if (isInWeb) { isInWeb = false; par1 *= 0.25D; par3 *= 0.05D; par5 *= 0.25D; motionX = 0.0D; motionY = 0.0D; motionZ = 0.0D; } double d2 = par1; double d3 = par3; double d4 = par5; AxisAlignedBB axisalignedbb = boundingBox.copy(); boolean flag = onGround && isSneaking() && (this instanceof EntityPlayer); if (flag) { double d5 = 0.05D; for (; par1 != 0.0D && worldObj .getCollidingBoundingBoxes( this, boundingBox.getOffsetBoundingBox(par1, -1D, 0.0D)) .size() == 0; d2 = par1) { if (par1 < d5 && par1 >= -d5) { par1 = 0.0D; continue; } if (par1 > 0.0D) { par1 -= d5; } else { par1 += d5; } } for (; par5 != 0.0D && worldObj .getCollidingBoundingBoxes( this, boundingBox.getOffsetBoundingBox(0.0D, -1D, par5)) .size() == 0; d4 = par5) { if (par5 < d5 && par5 >= -d5) { par5 = 0.0D; continue; } if (par5 > 0.0D) { par5 -= d5; } else { par5 += d5; } } } List list = worldObj.getCollidingBoundingBoxes(this, boundingBox.addCoord(par1, par3, par5)); for (int i = 0; i < list.size(); i++) { par3 = ((AxisAlignedBB) list.get(i)).calculateYOffset(boundingBox, par3); } boundingBox.offset(0.0D, par3, 0.0D); if (!field_9293_aM && d3 != par3) { par1 = par3 = par5 = 0.0D; } boolean flag1 = onGround || d3 != par3 && d3 < 0.0D; for (int j = 0; j < list.size(); j++) { par1 = ((AxisAlignedBB) list.get(j)).calculateXOffset(boundingBox, par1); } boundingBox.offset(par1, 0.0D, 0.0D); if (!field_9293_aM && d2 != par1) { par1 = par3 = par5 = 0.0D; } for (int k = 0; k < list.size(); k++) { par5 = ((AxisAlignedBB) list.get(k)).calculateZOffset(boundingBox, par5); } boundingBox.offset(0.0D, 0.0D, par5); if (!field_9293_aM && d4 != par5) { par1 = par3 = par5 = 0.0D; } if (stepHeight > 0.0F && flag1 && (flag || ySize < 0.05F) && (d2 != par1 || d4 != par5)) { double d6 = par1; double d8 = par3; double d10 = par5; par1 = d2; par3 = stepHeight; par5 = d4; AxisAlignedBB axisalignedbb1 = boundingBox.copy(); boundingBox.setBB(axisalignedbb); List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.addCoord(par1, par3, par5)); for (int j2 = 0; j2 < list1.size(); j2++) { par3 = ((AxisAlignedBB) list1.get(j2)).calculateYOffset(boundingBox, par3); } boundingBox.offset(0.0D, par3, 0.0D); if (!field_9293_aM && d3 != par3) { par1 = par3 = par5 = 0.0D; } for (int k2 = 0; k2 < list1.size(); k2++) { par1 = ((AxisAlignedBB) list1.get(k2)).calculateXOffset(boundingBox, par1); } boundingBox.offset(par1, 0.0D, 0.0D); if (!field_9293_aM && d2 != par1) { par1 = par3 = par5 = 0.0D; } for (int l2 = 0; l2 < list1.size(); l2++) { par5 = ((AxisAlignedBB) list1.get(l2)).calculateZOffset(boundingBox, par5); } boundingBox.offset(0.0D, 0.0D, par5); if (!field_9293_aM && d4 != par5) { par1 = par3 = par5 = 0.0D; } if (!field_9293_aM && d3 != par3) { par1 = par3 = par5 = 0.0D; } else { par3 = -stepHeight; for (int i3 = 0; i3 < list1.size(); i3++) { par3 = ((AxisAlignedBB) list1.get(i3)).calculateYOffset(boundingBox, par3); } boundingBox.offset(0.0D, par3, 0.0D); } if (d6 * d6 + d10 * d10 >= par1 * par1 + par5 * par5) { par1 = d6; par3 = d8; par5 = d10; boundingBox.setBB(axisalignedbb1); } else { double d11 = boundingBox.minY - (double) (int) boundingBox.minY; if (d11 > 0.0D) { ySize += d11 + 0.01D; } } } Profiler.endSection(); Profiler.startSection("rest"); posX = (boundingBox.minX + boundingBox.maxX) / 2D; posY = (boundingBox.minY + (double) yOffset) - (double) ySize; posZ = (boundingBox.minZ + boundingBox.maxZ) / 2D; isCollidedHorizontally = d2 != par1 || d4 != par5; isCollidedVertically = d3 != par3; onGround = d3 != par3 && d3 < 0.0D; isCollided = isCollidedHorizontally || isCollidedVertically; updateFallState(par3, onGround); if (d2 != par1) { motionX = 0.0D; } if (d3 != par3) { motionY = 0.0D; } if (d4 != par5) { motionZ = 0.0D; } double d7 = posX - d; double d9 = posZ - d1; if (canTriggerWalking() && !flag && ridingEntity == null) { distanceWalkedModified += (double) MathHelper.sqrt_double(d7 * d7 + d9 * d9) * 0.6D; int l = MathHelper.floor_double(posX); int j1 = MathHelper.floor_double(posY - 0.2D - (double) yOffset); int l1 = MathHelper.floor_double(posZ); int j3 = worldObj.getBlockId(l, j1, l1); if (j3 == 0 && worldObj.getBlockId(l, j1 - 1, l1) == Block.fence.blockID) { j3 = worldObj.getBlockId(l, j1 - 1, l1); } if (distanceWalkedModified > (float) nextStepDistance && j3 > 0) { nextStepDistance = (int) distanceWalkedModified + 1; playStepSound(l, j1, l1, j3); Block.blocksList[j3].onEntityWalking(worldObj, l, j1, l1, this); } } int i1 = MathHelper.floor_double(boundingBox.minX + 0.001D); int k1 = MathHelper.floor_double(boundingBox.minY + 0.001D); int i2 = MathHelper.floor_double(boundingBox.minZ + 0.001D); int k3 = MathHelper.floor_double(boundingBox.maxX - 0.001D); int l3 = MathHelper.floor_double(boundingBox.maxY - 0.001D); int i4 = MathHelper.floor_double(boundingBox.maxZ - 0.001D); if (worldObj.checkChunksExist(i1, k1, i2, k3, l3, i4)) { for (int j4 = i1; j4 <= k3; j4++) { for (int k4 = k1; k4 <= l3; k4++) { for (int l4 = i2; l4 <= i4; l4++) { int i5 = worldObj.getBlockId(j4, k4, l4); if (i5 > 0) { Block.blocksList[i5].onEntityCollidedWithBlock(worldObj, j4, k4, l4, this); } } } } } boolean flag2 = isWet(); if (worldObj.isBoundingBoxBurning(boundingBox.contract(0.001D, 0.001D, 0.001D))) { dealFireDamage(1); if (!flag2) { fire++; if (fire == 0) { setFire(8); } } } else if (fire <= 0) { fire = -fireResistance; } if (flag2 && fire > 0) { worldObj.playSoundAtEntity( this, "random.fizz", 0.7F, 1.6F + (rand.nextFloat() - rand.nextFloat()) * 0.4F); fire = -fireResistance; } Profiler.endSection(); }