/// <summary> /// Checks if the entity's current position is a valid location to spawn this entity. /// </summary> public override bool GetCanSpawnHere() { if (WorldObj.Rand.Next(3) == 0) { return(false); } if (WorldObj.CheckIfAABBIsClear(BoundingBox) && WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox)) { int i = MathHelper2.Floor_double(PosX); int j = MathHelper2.Floor_double(BoundingBox.MinY); int k = MathHelper2.Floor_double(PosZ); if (j < 63) { return(false); } int l = WorldObj.GetBlockId(i, j - 1, k); if (l == Block.Grass.BlockID || l == Block.Leaves.BlockID) { return(true); } } return(false); }
/// <summary> /// Checks if the entity's current position is a valid location to spawn this entity. /// </summary> public override bool GetCanSpawnHere() { return(WorldObj.DifficultySetting > 0 && WorldObj.CheckIfAABBIsClear(BoundingBox) && WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox)); }
/// <summary> /// Teleport the enderman /// </summary> protected virtual bool TeleportTo(float par1, float par3, float par5) { float d = PosX; float d1 = PosY; float d2 = PosZ; PosX = par1; PosY = par3; PosZ = par5; bool flag = false; int i = MathHelper2.Floor_double(PosX); int j = MathHelper2.Floor_double(PosY); int k = MathHelper2.Floor_double(PosZ); if (WorldObj.BlockExists(i, j, k)) { bool flag1; for (flag1 = false; !flag1 && j > 0;) { int i1 = WorldObj.GetBlockId(i, j - 1, k); if (i1 == 0 || !Block.BlocksList[i1].BlockMaterial.BlocksMovement()) { PosY--; j--; } else { flag1 = true; } } if (flag1) { SetPosition(PosX, PosY, PosZ); if (WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox)) { flag = true; } } } if (!flag) { SetPosition(d, d1, d2); return(false); } int l = 128; for (int j1 = 0; j1 < l; j1++) { double d3 = (double)j1 / ((double)l - 1.0D); float f = (Rand.NextFloat() - 0.5F) * 0.2F; float f1 = (Rand.NextFloat() - 0.5F) * 0.2F; float f2 = (Rand.NextFloat() - 0.5F) * 0.2F; double d4 = d + (PosX - d) * d3 + (Rand.NextDouble() - 0.5D) * (double)Width * 2D; double d5 = d1 + (PosY - d1) * d3 + Rand.NextDouble() * (double)Height; double d6 = d2 + (PosZ - d2) * d3 + (Rand.NextDouble() - 0.5D) * (double)Width * 2D; WorldObj.SpawnParticle("portal", d4, d5, d6, f, f1, f2); } WorldObj.PlaySoundEffect(d, d1, d2, "mob.endermen.portal", 1.0F, 1.0F); WorldObj.PlaySoundAtEntity(this, "mob.endermen.portal", 1.0F, 1.0F); return(true); }