/// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            if (IsEntityAlive())
            {
                LastActiveTime = TimeSinceIgnited;
                int i = GetCreeperState();

                if (i > 0 && TimeSinceIgnited == 0)
                {
                    WorldObj.PlaySoundAtEntity(this, "random.fuse", 1.0F, 0.5F);
                }

                TimeSinceIgnited += i;

                if (TimeSinceIgnited < 0)
                {
                    TimeSinceIgnited = 0;
                }

                if (TimeSinceIgnited >= 30)
                {
                    TimeSinceIgnited = 30;

                    if (!WorldObj.IsRemote)
                    {
                        if (GetPowered())
                        {
                            WorldObj.CreateExplosion(this, PosX, PosY, PosZ, 6F);
                        }
                        else
                        {
                            WorldObj.CreateExplosion(this, PosX, PosY, PosZ, 3F);
                        }

                        SetDead();
                    }
                }
            }

            base.OnUpdate();
        }
        /// <summary>
        /// Called when the entity is attacked.
        /// </summary>
        public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2)
        {
            if (!IsDead && !WorldObj.IsRemote)
            {
                Health = 0;

                if (Health <= 0)
                {
                    if (!WorldObj.IsRemote)
                    {
                        SetDead();
                        WorldObj.CreateExplosion(null, PosX, PosY, PosZ, 6F);
                    }
                    else
                    {
                        SetDead();
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void Explode()
        {
            float f = 4F;

            WorldObj.CreateExplosion(null, PosX, PosY, PosZ, f);
        }