Exemple #1
0
        public override void fall(float f)
        {
            var i = (int)Math.ceil(f - 3F);

            if (i > 0)
            {
                attackEntityFrom(null, i);
                int j = worldObj.getBlockId(MathHelper.floor_double(posX),
                                            MathHelper.floor_double(posY - 0.20000000298023224D - yOffset),
                                            MathHelper.floor_double(posZ));
                if (j > 0)
                {
                    StepSound stepsound = Block.blocksList[j].stepSound;
                    worldObj.playSoundAtEntity(this, stepsound.func_737_c(), stepsound.func_738_a() * 0.5F,
                                               stepsound.func_739_b() * 0.75F);
                }
            }
        }
Exemple #2
0
        public void moveEntity(double d, double d1, double d2)
        {
            if (noClip)
            {
                boundingBox.offset(d, d1, d2);
                posX = (boundingBox.minX + boundingBox.maxX) / 2D;
                posY = (boundingBox.minY + yOffset) - ySize;
                posZ = (boundingBox.minZ + boundingBox.maxZ) / 2D;
                return;
            }
            double        d3            = posX;
            double        d4            = posZ;
            double        d5            = d;
            double        d6            = d1;
            double        d7            = d2;
            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)).size() == 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)).size() ==
                     0;
                     d7 = d2)
                {
                    if (d2 < d8 && d2 >= -d8)
                    {
                        d2 = 0.0D;
                        continue;
                    }
                    if (d2 > 0.0D)
                    {
                        d2 -= d8;
                    }
                    else
                    {
                        d2 += d8;
                    }
                }
            }
            List list = worldObj.getCollidingBoundingBoxes(this, boundingBox.addCoord(d, d1, d2));

            for (int i = 0; i < list.size(); i++)
            {
                d1 = ((AxisAlignedBB)list.get(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.size(); j++)
            {
                d = ((AxisAlignedBB)list.get(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.size(); k++)
            {
                d2 = ((AxisAlignedBB)list.get(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 && ySize < 0.05F && (d5 != d || d7 != d2))
            {
                double d9  = d;
                double d11 = d1;
                double d13 = d2;
                d  = d5;
                d1 = stepHeight;
                d2 = d7;
                AxisAlignedBB axisalignedbb1 = boundingBox.copy();
                boundingBox.setBB(axisalignedbb);
                List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.addCoord(d, d1, d2));
                for (int j2 = 0; j2 < list1.size(); j2++)
                {
                    d1 = ((AxisAlignedBB)list1.get(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.size(); k2++)
                {
                    d = ((AxisAlignedBB)list1.get(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.size(); l2++)
                {
                    d2 = ((AxisAlignedBB)list1.get(l2)).calculateZOffset(boundingBox, d2);
                }

                boundingBox.offset(0.0D, 0.0D, d2);
                if (!field_9077_F && d7 != d2)
                {
                    d = d1 = d2 = 0.0D;
                }
                if (d9 * d9 + d13 * d13 >= d * d + d2 * d2)
                {
                    d  = d9;
                    d1 = d11;
                    d2 = d13;
                    boundingBox.setBB(axisalignedbb1);
                }
                else
                {
                    ySize += (float)0.5D;
                }
            }
            posX = (boundingBox.minX + boundingBox.maxX) / 2D;
            posY = (boundingBox.minY + yOffset) - 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 (entityWalks && !flag)
            {
                distanceWalkedModified +=
                    (float)(MathHelper.sqrt_double(d10 * d10 + d12 * d12) * 0.59999999999999998D);
                int l  = MathHelper.floor_double(posX);
                int j1 = MathHelper.floor_double(posY - 0.20000000298023224D - yOffset);
                int l1 = MathHelper.floor_double(posZ);
                int i3 = worldObj.getBlockId(l, j1, l1);
                if (distanceWalkedModified > nextStepDistance && i3 > 0)
                {
                    nextStepDistance++;
                    StepSound stepsound = Block.blocksList[i3].stepSound;
                    if (worldObj.getBlockId(l, j1 + 1, l1) == Block.snow.blockID)
                    {
                        stepsound = Block.snow.stepSound;
                        worldObj.playSoundAtEntity(this, stepsound.func_737_c(), stepsound.func_738_a() * 0.15F,
                                                   stepsound.func_739_b());
                    }
                    else if (!Block.blocksList[i3].blockMaterial.getIsLiquid())
                    {
                        worldObj.playSoundAtEntity(this, stepsound.func_737_c(), stepsound.func_738_a() * 0.15F,
                                                   stepsound.func_739_b());
                    }
                    Block.blocksList[i3].onEntityWalking(worldObj, l, j1, l1, this);
                }
            }
            int i1 = MathHelper.floor_double(boundingBox.minX);
            int k1 = MathHelper.floor_double(boundingBox.minY);
            int i2 = MathHelper.floor_double(boundingBox.minZ);
            int j3 = MathHelper.floor_double(boundingBox.maxX);
            int k3 = MathHelper.floor_double(boundingBox.maxY);
            int l3 = MathHelper.floor_double(boundingBox.maxZ);

            if (worldObj.checkChunksExist(i1, k1, i2, j3, k3, l3))
            {
                for (int i4 = i1; i4 <= j3; i4++)
                {
                    for (int j4 = k1; j4 <= k3; j4++)
                    {
                        for (int k4 = i2; k4 <= l3; k4++)
                        {
                            int l4 = worldObj.getBlockId(i4, j4, k4);
                            if (l4 > 0)
                            {
                                Block.blocksList[l4].onEntityCollidedWithBlock(worldObj, i4, j4, k4, this);
                            }
                        }
                    }
                }
            }
            ySize *= 0.4F;
            bool flag2 = handleWaterMovement();

            if (worldObj.isBoundingBoxBurning(boundingBox))
            {
                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;
            }
        }