Beispiel #1
0
        protected internal override void Fall(float f)
        {
            base.Fall(f);
            int i = (int)System.Math.Ceiling(f - 3F);

            if (i > 0)
            {
                AttackEntityFrom(null, i);
                int j = worldObj.GetBlockId(net.minecraft.src.MathHelper.Floor_double(posX), net.minecraft.src.MathHelper
                                            .Floor_double(posY - 0.20000000298023224D - (double)yOffset), net.minecraft.src.MathHelper
                                            .Floor_double(posZ));
                if (j > 0)
                {
                    net.minecraft.src.StepSound stepsound = net.minecraft.src.Block.blocksList[j].stepSound;
                    worldObj.PlaySoundAtEntity(this, stepsound.Func_737_c(), stepsound.GetVolume() *
                                               0.5F, stepsound.GetPitch() * 0.75F);
                }
            }
        }
Beispiel #2
0
        public virtual void MoveEntity(double d, double d1, double d2)
        {
            if (d == 0 && d1 == 0 && d2 == 0)
            {
                return;                               // CRAFTBUKKIT
            }
            if (noClip)
            {
                boundingBox.Offset(d, d1, d2);
                posX = (boundingBox.minX + boundingBox.maxX) / 2D;
                posY = (boundingBox.minY + (double)yOffset) - (double)ySize;
                posZ = (boundingBox.minZ + boundingBox.maxZ) / 2D;
                return;
            }
            ySize *= 0.4F;
            double d3 = posX;
            double d4 = posZ;

            if (field_27012_bb)
            {
                field_27012_bb = false;
                d      *= 0.25D;
                d1     *= 0.05000000074505806D;
                d2     *= 0.25D;
                motionX = 0.0D;
                motionY = 0.0D;
                motionZ = 0.0D;
            }
            double d5 = d;
            double d6 = d1;
            double d7 = d2;

            net.minecraft.src.AxisAlignedBB axisalignedbb = boundingBox.Copy();
            bool flag = onGround && IsSneaking();

            if (flag)
            {
                double d8 = 0.050000000000000003D;
                for (; d != 0.0D && worldObj.GetCollidingBoundingBoxes(this, boundingBox.GetOffsetBoundingBox
                                                                           (d, -1D, 0.0D)).Count == 0; d5 = d)
                {
                    if (d < d8 && d >= -d8)
                    {
                        d = 0.0D;
                        continue;
                    }
                    if (d > 0.0D)
                    {
                        d -= d8;
                    }
                    else
                    {
                        d += d8;
                    }
                }
                for (; d2 != 0.0D && worldObj.GetCollidingBoundingBoxes(this, boundingBox.GetOffsetBoundingBox
                                                                            (0.0D, -1D, d2)).Count == 0; d7 = d2)
                {
                    if (d2 < d8 && d2 >= -d8)
                    {
                        d2 = 0.0D;
                        continue;
                    }
                    if (d2 > 0.0D)
                    {
                        d2 -= d8;
                    }
                    else
                    {
                        d2 += d8;
                    }
                }
            }
            List <AxisAlignedBB> list = worldObj.GetCollidingBoundingBoxes(this, boundingBox
                                                                           .AddCoord(d, d1, d2));

            for (int i = 0; i < list.Count; i++)
            {
                d1 = ((net.minecraft.src.AxisAlignedBB)list[i]).CalculateYOffset(boundingBox, d1);
            }
            boundingBox.Offset(0.0D, d1, 0.0D);
            if (!field_9077_F && d6 != d1)
            {
                d = d1 = d2 = 0.0D;
            }
            bool flag1 = onGround || d6 != d1 && d6 < 0.0D;

            for (int j = 0; j < list.Count; j++)
            {
                d = ((net.minecraft.src.AxisAlignedBB)list[j]).CalculateXOffset(boundingBox, d);
            }
            boundingBox.Offset(d, 0.0D, 0.0D);
            if (!field_9077_F && d5 != d)
            {
                d = d1 = d2 = 0.0D;
            }
            for (int k = 0; k < list.Count; k++)
            {
                d2 = ((net.minecraft.src.AxisAlignedBB)list[k]).CalculateZOffset(boundingBox, d2);
            }
            boundingBox.Offset(0.0D, 0.0D, d2);
            if (!field_9077_F && d7 != d2)
            {
                d = d1 = d2 = 0.0D;
            }
            if (stepHeight > 0.0F && flag1 && (flag || ySize < 0.05F) && (d5 != d || d7 != d2
                                                                          ))
            {
                double d9  = d;
                double d11 = d1;
                double d13 = d2;
                d  = d5;
                d1 = stepHeight;
                d2 = d7;
                net.minecraft.src.AxisAlignedBB axisalignedbb1 = boundingBox.Copy();
                boundingBox.SetBB(axisalignedbb);
                List <AxisAlignedBB> list1 = worldObj.GetCollidingBoundingBoxes(this, boundingBox
                                                                                .AddCoord(d, d1, d2));
                for (int j2 = 0; j2 < list1.Count; j2++)
                {
                    d1 = ((net.minecraft.src.AxisAlignedBB)list1[j2]).CalculateYOffset(boundingBox, d1
                                                                                       );
                }
                boundingBox.Offset(0.0D, d1, 0.0D);
                if (!field_9077_F && d6 != d1)
                {
                    d = d1 = d2 = 0.0D;
                }
                for (int k2 = 0; k2 < list1.Count; k2++)
                {
                    d = ((net.minecraft.src.AxisAlignedBB)list1[k2]).CalculateXOffset(boundingBox, d);
                }
                boundingBox.Offset(d, 0.0D, 0.0D);
                if (!field_9077_F && d5 != d)
                {
                    d = d1 = d2 = 0.0D;
                }
                for (int l2 = 0; l2 < list1.Count; l2++)
                {
                    d2 = ((net.minecraft.src.AxisAlignedBB)list1[l2]).CalculateZOffset(boundingBox, d2
                                                                                       );
                }
                boundingBox.Offset(0.0D, 0.0D, d2);
                if (!field_9077_F && d7 != d2)
                {
                    d = d1 = d2 = 0.0D;
                }
                if (!field_9077_F && d6 != d1)
                {
                    d = d1 = d2 = 0.0D;
                }
                else
                {
                    d1 = -stepHeight;
                    for (int i3 = 0; i3 < list1.Count; i3++)
                    {
                        d1 = ((net.minecraft.src.AxisAlignedBB)list1[i3]).CalculateYOffset(boundingBox, d1
                                                                                           );
                    }
                    boundingBox.Offset(0.0D, d1, 0.0D);
                }
                if (d9 * d9 + d13 * d13 >= d * d + d2 * d2)
                {
                    d  = d9;
                    d1 = d11;
                    d2 = d13;
                    boundingBox.SetBB(axisalignedbb1);
                }
                else
                {
                    double d14 = boundingBox.minY - (double)(int)boundingBox.minY;
                    if (d14 > 0.0D)
                    {
                        ySize += (float)(d14 + 0.01D);
                    }
                }
            }
            posX = (boundingBox.minX + boundingBox.maxX) / 2D;
            posY = (boundingBox.minY + (double)yOffset) - (double)ySize;
            posZ = (boundingBox.minZ + boundingBox.maxZ) / 2D;
            isCollidedHorizontally = d5 != d || d7 != d2;
            isCollidedVertically   = d6 != d1;
            onGround   = d6 != d1 && d6 < 0.0D;
            isCollided = isCollidedHorizontally || isCollidedVertically;
            UpdateFallState(d1, onGround);
            if (d5 != d)
            {
                motionX = 0.0D;
            }
            if (d6 != d1)
            {
                motionY = 0.0D;
            }
            if (d7 != d2)
            {
                motionZ = 0.0D;
            }
            double d10 = posX - d3;
            double d12 = posZ - d4;

            if (Func_25017_l() && !flag && ridingEntity == null)
            {
                distanceWalkedModified += (float)((double)net.minecraft.src.MathHelper.Sqrt_double(d10 * d10 + d12 * d12) * 0.59999999999999998D);
                int l  = net.minecraft.src.MathHelper.Floor_double(posX);
                int j1 = net.minecraft.src.MathHelper.Floor_double(posY - 0.20000000298023224D -
                                                                   (double)yOffset);
                int l1 = net.minecraft.src.MathHelper.Floor_double(posZ);
                int j3 = worldObj.GetBlockId(l, j1, l1);
                if (worldObj.GetBlockId(l, j1 - 1, l1) == net.minecraft.src.Block.FENCE.ID)
                {
                    j3 = worldObj.GetBlockId(l, j1 - 1, l1);
                }
                if (distanceWalkedModified > (float)nextStepDistance && j3 > 0)
                {
                    nextStepDistance++;
                    net.minecraft.src.StepSound stepsound = net.minecraft.src.Block.blocksList[j3].stepSound;
                    if (worldObj.GetBlockId(l, j1 + 1, l1) == net.minecraft.src.Block.SNOW.ID)
                    {
                        stepsound = net.minecraft.src.Block.SNOW.stepSound;
                        worldObj.PlaySoundAtEntity(this, stepsound.Func_737_c(), stepsound.GetVolume() *
                                                   0.15F, stepsound.GetPitch());
                    }
                    else
                    {
                        if (!net.minecraft.src.Block.blocksList[j3].blockMaterial.GetIsLiquid())
                        {
                            worldObj.PlaySoundAtEntity(this, stepsound.Func_737_c(), stepsound.GetVolume() *
                                                       0.15F, stepsound.GetPitch());
                        }
                    }
                    net.minecraft.src.Block.blocksList[j3].OnEntityWalking(worldObj, l, j1, l1, this);
                }
            }
            int i1 = net.minecraft.src.MathHelper.Floor_double(boundingBox.minX + 0.001D);
            int k1 = net.minecraft.src.MathHelper.Floor_double(boundingBox.minY + 0.001D);
            int i2 = net.minecraft.src.MathHelper.Floor_double(boundingBox.minZ + 0.001D);
            int k3 = net.minecraft.src.MathHelper.Floor_double(boundingBox.maxX - 0.001D);
            int l3 = net.minecraft.src.MathHelper.Floor_double(boundingBox.maxY - 0.001D);
            int i4 = net.minecraft.src.MathHelper.Floor_double(boundingBox.maxZ - 0.001D);

            if (worldObj.CheckChunksExist(i1, k1, i2, k3, l3, i4))
            {
                for (int j4 = i1; j4 <= k3; j4++)
                {
                    for (int k4 = k1; k4 <= l3; k4++)
                    {
                        for (int l4 = i2; l4 <= i4; l4++)
                        {
                            int i5 = worldObj.GetBlockId(j4, k4, l4);
                            if (i5 > 0)
                            {
                                net.minecraft.src.Block.blocksList[i5].OnEntityCollidedWithBlock(worldObj, j4, k4
                                                                                                 , l4, this);
                            }
                        }
                    }
                }
            }
            bool flag2 = Func_27008_Y();

            if (worldObj.IsBoundingBoxBurning(boundingBox.GetInsetBoundingBox(0.001D, 0.001D,
                                                                              0.001D)))
            {
                DealFireDamage(1);
                if (!flag2)
                {
                    fire++;
                    if (fire == 0)
                    {
                        fire = 300;
                    }
                }
            }
            else
            {
                if (fire <= 0)
                {
                    fire = -fireResistance;
                }
            }
            if (flag2 && fire > 0)
            {
                worldObj.PlaySoundAtEntity(this, "random.fizz", 0.7F, 1.6F + (rand.NextFloat() -
                                                                              rand.NextFloat()) * 0.4F);
                fire = -fireResistance;
            }
        }