Ejemplo n.º 1
0
        /// <summary>
        /// Called when the entity is attacked.
        /// </summary>
        public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2)
        {
            if (WorldObj.IsRemote || IsDead)
            {
                return(true);
            }

            SetForwardDirection(-GetForwardDirection());
            SetTimeSinceHit(10);
            SetDamageTaken(GetDamageTaken() + par2 * 10);
            SetBeenAttacked();

            if (GetDamageTaken() > 40)
            {
                if (RiddenByEntity != null)
                {
                    RiddenByEntity.MountEntity(this);
                }

                for (int i = 0; i < 3; i++)
                {
                    DropItemWithOffset(Block.Planks.BlockID, 1, 0.0F);
                }

                for (int j = 0; j < 2; j++)
                {
                    DropItemWithOffset(Item.Stick.ShiftedIndex, 1, 0.0F);
                }

                SetDead();
            }

            return(true);
        }
Ejemplo n.º 2
0
 public override void UpdateRiderPosition()
 {
     if (RiddenByEntity == null)
     {
         return;
     }
     else
     {
         float d  = (float)Math.Cos((RotationYaw * Math.PI) / 180) * 0.40000000000000002F;
         float d1 = (float)Math.Sin((RotationYaw * Math.PI) / 180) * 0.40000000000000002F;
         RiddenByEntity.SetPosition(PosX + d, PosY + GetMountedYOffset() + RiddenByEntity.GetYOffset(), PosZ + d1);
         return;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when the entity is attacked.
        /// </summary>
        public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2)
        {
            if (WorldObj.IsRemote || IsDead)
            {
                return(true);
            }

            Func_41029_h(-Func_41030_m());
            Func_41028_c(10);
            SetBeenAttacked();
            Func_41024_b(Func_41025_i() + par2 * 10);

            if (Func_41025_i() > 40)
            {
                if (RiddenByEntity != null)
                {
                    RiddenByEntity.MountEntity(this);
                }

                SetDead();
                DropItemWithOffset(Item.MinecartEmpty.ShiftedIndex, 1, 0.0F);

                if (MinecartType == 1)
                {
                    EntityMinecart entityminecart = this;
label0:

                    for (int i = 0; i < entityminecart.GetSizeInventory(); i++)
                    {
                        ItemStack itemstack = entityminecart.GetStackInSlot(i);

                        if (itemstack == null)
                        {
                            continue;
                        }

                        float f  = Rand.NextFloat() * 0.8F + 0.1F;
                        float f1 = Rand.NextFloat() * 0.8F + 0.1F;
                        float f2 = Rand.NextFloat() * 0.8F + 0.1F;

                        do
                        {
                            if (itemstack.StackSize <= 0)
                            {
                                goto label0;
                            }

                            int j = Rand.Next(21) + 10;

                            if (j > itemstack.StackSize)
                            {
                                j = itemstack.StackSize;
                            }

                            itemstack.StackSize -= j;
                            EntityItem entityitem = new EntityItem(WorldObj, PosX + f, PosY + f1, PosZ + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage()));
                            float      f3         = 0.05F;
                            entityitem.MotionX = (float)Rand.NextGaussian() * f3;
                            entityitem.MotionY = (float)Rand.NextGaussian() * f3 + 0.2F;
                            entityitem.MotionZ = (float)Rand.NextGaussian() * f3;
                            WorldObj.SpawnEntityInWorld(entityitem);
                        }while (true);
                    }

                    DropItemWithOffset(Block.Chest.BlockID, 1, 0.0F);
                }
                else if (MinecartType == 2)
                {
                    DropItemWithOffset(Block.StoneOvenIdle.BlockID, 1, 0.0F);
                }
            }

            return(true);
        }