/// <summary>
        /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
        /// cleared to be reused)
        /// </summary>
        public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            bool  flag  = CanConnectFenceTo(par1World, par2, par3, par4 - 1);
            bool  flag1 = CanConnectFenceTo(par1World, par2, par3, par4 + 1);
            bool  flag2 = CanConnectFenceTo(par1World, par2 - 1, par3, par4);
            bool  flag3 = CanConnectFenceTo(par1World, par2 + 1, par3, par4);
            float f     = 0.375F;
            float f1    = 0.625F;
            float f2    = 0.375F;
            float f3    = 0.625F;

            if (flag)
            {
                f2 = 0.0F;
            }

            if (flag1)
            {
                f3 = 1.0F;
            }

            if (flag2)
            {
                f = 0.0F;
            }

            if (flag3)
            {
                f1 = 1.0F;
            }

            return(AxisAlignedBB.GetBoundingBoxFromPool((float)par2 + f, par3, (float)par4 + f2, (float)par2 + f1, (float)par3 + 1.5F, (float)par4 + f3));
        }
Example #2
0
        /// <summary>
        /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
        /// cleared to be reused)
        /// </summary>
        public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            int i = par1World.GetBlockMetadata(par2, par3, par4);

            if (IsFenceGateOpen(i))
            {
                return(null);
            }

            if (i == 2 || i == 0)
            {
                return(AxisAlignedBB.GetBoundingBoxFromPool(par2, par3, (float)par4 + 0.375F, par2 + 1, (float)par3 + 1.5F, (float)par4 + 0.625F));
            }
            else
            {
                return(AxisAlignedBB.GetBoundingBoxFromPool((float)par2 + 0.375F, par3, par4, (float)par2 + 0.625F, (float)par3 + 1.5F, par4 + 1));
            }
        }
 /// <summary>
 /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
 /// cleared to be reused)
 /// </summary>
 public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
 {
     return(AxisAlignedBB.GetBoundingBoxFromPool(par2 + MinX, par3 + MinY, par4 + MinZ, par2 + MaxX, par3 + MaxY, par4 + MaxZ));
 }
        /// <summary>
        /// Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
        /// ticks and creates a new spawn inside its implementation.
        /// </summary>
        public override void UpdateEntity()
        {
            Yaw2 = Yaw;

            if (!AnyPlayerInRange())
            {
                return;
            }

            double d  = (float)XCoord + WorldObj.Rand.NextFloat();
            double d1 = (float)YCoord + WorldObj.Rand.NextFloat();
            double d2 = (float)ZCoord + WorldObj.Rand.NextFloat();

            WorldObj.SpawnParticle("smoke", d, d1, d2, 0.0F, 0.0F, 0.0F);
            WorldObj.SpawnParticle("flame", d, d1, d2, 0.0F, 0.0F, 0.0F);

            for (Yaw += 1000F / ((float)Delay + 200F); Yaw > 360D;)
            {
                Yaw  -= 360D;
                Yaw2 -= 360D;
            }

            if (!WorldObj.IsRemote)
            {
                if (Delay == -1)
                {
                    UpdateDelay();
                }

                if (Delay > 0)
                {
                    Delay--;
                    return;
                }

                sbyte byte0 = 4;

                for (int i = 0; i < byte0; i++)
                {
                    EntityLiving entityliving = (EntityLiving)EntityList.CreateEntityByName(MobID, WorldObj);

                    if (entityliving == null)
                    {
                        return;
                    }

                    int j = WorldObj.GetEntitiesWithinAABB(entityliving.GetType(), AxisAlignedBB.GetBoundingBoxFromPool(XCoord, YCoord, ZCoord, XCoord + 1, YCoord + 1, ZCoord + 1).Expand(8F, 4F, 8F)).Count;

                    if (j >= 6)
                    {
                        UpdateDelay();
                        return;
                    }

                    if (entityliving == null)
                    {
                        continue;
                    }

                    float d3 = XCoord + (WorldObj.Rand.NextFloat() - WorldObj.Rand.NextFloat()) * 4F;
                    float d4 = (YCoord + WorldObj.Rand.Next(3)) - 1;
                    float d5 = ZCoord + (WorldObj.Rand.NextFloat() - WorldObj.Rand.NextFloat()) * 4F;
                    entityliving.SetLocationAndAngles(d3, d4, d5, WorldObj.Rand.NextFloat() * 360F, 0.0F);

                    if (entityliving.GetCanSpawnHere())
                    {
                        WorldObj.SpawnEntityInWorld(entityliving);
                        WorldObj.PlayAuxSFX(2004, XCoord, YCoord, ZCoord, 0);
                        entityliving.SpawnExplosionParticle();
                        UpdateDelay();
                    }
                }
            }

            base.UpdateEntity();
        }
        /// <summary>
        /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
        /// cleared to be reused)
        /// </summary>
        public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            float f = 0.125F;

            return(AxisAlignedBB.GetBoundingBoxFromPool(par2, par3, par4, par2 + 1, (float)(par3 + 1) - f, par4 + 1));
        }