Exemplo n.º 1
0
 protected internal override void AttackEntity(net.minecraft.src.Entity entity, float
                                               f)
 {
     if (f > 2.0F && f < 6F && rand.Next(10) == 0)
     {
         if (onGround)
         {
             double d  = entity.posX - posX;
             double d1 = entity.posZ - posZ;
             float  f1 = net.minecraft.src.MathHelper.Sqrt_double(d * d + d1 * d1);
             motionX = (d / (double)f1) * 0.5D * 0.80000001192092896D + motionX * 0.20000000298023224D;
             motionZ = (d1 / (double)f1) * 0.5D * 0.80000001192092896D + motionZ * 0.20000000298023224D;
             motionY = 0.40000000596046448D;
         }
     }
     else
     {
         if ((double)f < 1.5D && entity.boundingBox.maxY > boundingBox.minY && entity.boundingBox
             .minY < boundingBox.maxY)
         {
             attackTime = 20;
             byte byte0 = 2;
             if (IsTamed())
             {
                 byte0 = 4;
             }
             entity.AttackEntityFrom(this, byte0);
         }
     }
 }
Exemplo n.º 2
0
 protected internal override void AttackEntity(net.minecraft.src.Entity entity, float
                                               f)
 {
     if (attackTime <= 0 && f < 2.0F && entity.boundingBox.maxY > boundingBox.minY &&
         entity.boundingBox.minY < boundingBox.maxY)
     {
         attackTime = 20;
         entity.AttackEntityFrom(this, attackStrength);
     }
 }
Exemplo n.º 3
0
        public virtual void AttackTargetEntityWithCurrentItem(net.minecraft.src.Entity entity
                                                              )
        {
            int i = inventory.GetDamageVsEntity(entity);

            if (i > 0)
            {
                if (motionY < 0.0D)
                {
                    i++;
                }

                if (!entity.AttackEntityFrom(this, i))
                {
                    return;                                    // CRAFTBUKKIT -- Bypass durability if attack failed
                }
                net.minecraft.src.ItemStack itemstack = GetCurrentEquippedItem();
                if (itemstack != null && (entity is net.minecraft.src.EntityLiving))
                {
                    itemstack.HitEntity((net.minecraft.src.EntityLiving)entity, this);
                    if (itemstack.stackSize <= 0)
                    {
                        itemstack.Func_577_a(this);
                        DestroyCurrentEquippedItem();
                    }
                }
                if (entity is net.minecraft.src.EntityLiving)
                {
                    if (entity.IsEntityAlive())
                    {
                        SetOwnedEntitiesToAttack((net.minecraft.src.EntityLiving)entity, true);
                    }
                    AddStat(net.minecraft.src.StatList.StatDamageDealt, i);
                }
            }
        }
Exemplo n.º 4
0
        public virtual void DoExplosion()
        {
            float f = explosionSize;
            int   i = 16;

            for (int j = 0; j < i; j++)
            {
                for (int l = 0; l < i; l++)
                {
                    for (int j1 = 0; j1 < i; j1++)
                    {
                        if (j != 0 && j != i - 1 && l != 0 && l != i - 1 && j1 != 0 && j1 != i - 1)
                        {
                            continue;
                        }
                        double d  = ((float)j / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d1 = ((float)l / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d2 = ((float)j1 / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d3 = System.Math.Sqrt(d * d + d1 * d1 + d2 * d2);
                        d  /= d3;
                        d1 /= d3;
                        d2 /= d3;
                        float  f1 = explosionSize * (0.7F + worldObj.rand.NextFloat() * 0.6F);
                        double d5 = explosionX;
                        double d7 = explosionY;
                        double d9 = explosionZ;
                        float  f2 = 0.3F;
                        do
                        {
                            if (f1 <= 0.0F)
                            {
                                goto label0_continue;
                            }
                            int j4 = net.minecraft.src.MathHelper.Floor_double(d5);
                            int k4 = net.minecraft.src.MathHelper.Floor_double(d7);
                            int l4 = net.minecraft.src.MathHelper.Floor_double(d9);
                            int i5 = worldObj.GetBlockId(j4, k4, l4);
                            if (i5 > 0)
                            {
                                f1 -= (net.minecraft.src.Block.blocksList[i5].GetExplosionResistance(exploder) +
                                       0.3F) * f2;
                            }
                            if (f1 > 0.0F)
                            {
                                destroyedBlockPositions.Add(new net.minecraft.src.ChunkPosition(j4, k4, l4));
                            }
                            d5 += d * (double)f2;
                            d7 += d1 * (double)f2;
                            d9 += d2 * (double)f2;
                            f1 -= f2 * 0.75F;
                        }while (true);
                        label0_continue :;
                    }
                    label0_break :;
                }
            }
            explosionSize *= 2.0F;
            int           k    = net.minecraft.src.MathHelper.Floor_double(explosionX - (double)explosionSize - 1.0D);
            int           i1   = net.minecraft.src.MathHelper.Floor_double(explosionX + (double)explosionSize + 1.0D);
            int           k1   = net.minecraft.src.MathHelper.Floor_double(explosionY - (double)explosionSize - 1.0D);
            int           l1   = net.minecraft.src.MathHelper.Floor_double(explosionY + (double)explosionSize + 1.0D);
            int           i2   = net.minecraft.src.MathHelper.Floor_double(explosionZ - (double)explosionSize - 1.0D);
            int           j2   = net.minecraft.src.MathHelper.Floor_double(explosionZ + (double)explosionSize + 1.0D);
            List <Entity> list = worldObj.GetEntitiesWithinAABBExcludingEntity(exploder, net.minecraft.src.AxisAlignedBB.GetBoundingBoxFromPool(k, k1, i2, i1, l1, j2));

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(explosionX, explosionY, explosionZ);
            for (int k2 = 0; k2 < list.Count; k2++)
            {
                net.minecraft.src.Entity entity = (net.minecraft.src.Entity)list[k2];
                double d4 = entity.GetDistance(explosionX, explosionY, explosionZ) / (double)explosionSize;
                if (d4 <= 1.0D)
                {
                    double d6  = entity.posX - explosionX;
                    double d8  = entity.posY - explosionY;
                    double d10 = entity.posZ - explosionZ;
                    double d11 = net.minecraft.src.MathHelper.Sqrt_double(d6 * d6 + d8 * d8 + d10 * d10
                                                                          );
                    d6  /= d11;
                    d8  /= d11;
                    d10 /= d11;
                    double d12 = worldObj.Func_494_a(vec3d, entity.boundingBox);
                    double d13 = (1.0D - d4) * d12;
                    entity.AttackEntityFrom(exploder, (int)(((d13 * d13 + d13) / 2D) * 8D * (double)explosionSize
                                                            + 1.0D));
                    double d14 = d13;
                    entity.motionX += d6 * d14;
                    entity.motionY += d8 * d14;
                    entity.motionZ += d10 * d14;
                }
            }
            explosionSize = f;
            List <ChunkPosition> arraylist = new List <ChunkPosition>();

            arraylist.AddRange(destroyedBlockPositions);
            if (isFlaming)
            {
                for (int l2 = arraylist.Count - 1; l2 >= 0; l2--)
                {
                    net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                                    arraylist[l2];
                    int i3 = chunkposition.x;
                    int j3 = chunkposition.y;
                    int k3 = chunkposition.z;
                    int l3 = worldObj.GetBlockId(i3, j3, k3);
                    int i4 = worldObj.GetBlockId(i3, j3 - 1, k3);
                    if (l3 == 0 && net.minecraft.src.Block.opaqueCubeLookup[i4] && ExplosionRNG.NextInt
                            (3) == 0)
                    {
                        worldObj.SetBlockWithNotify(i3, j3, k3, net.minecraft.src.Block.FIRE.ID);
                    }
                }
            }
        }
Exemplo n.º 5
0
 public override void OnEntityCollidedWithBlock(net.minecraft.src.World world, int
                                                i, int j, int k, net.minecraft.src.Entity entity)
 {
     entity.AttackEntityFrom(null, 1);
 }