Exemple #1
0
        public virtual void getEntitiesOfTypeWithinAAAB(Class class1, AxisAlignedBB axisalignedbb, List list)
        {
            int i = MathHelper.floor_double((axisalignedbb.minY - 2D) / 16D);
            int j = MathHelper.floor_double((axisalignedbb.maxY + 2D) / 16D);

            if (i < 0)
            {
                i = 0;
            }
            if (j >= entities.Length)
            {
                j = entities.Length - 1;
            }
            for (int k = i; k <= j; k++)
            {
                List list1 = entities[k];
                for (int l = 0; l < list1.size(); l++)
                {
                    var entity = (Entity)list1.get(l);
                    if (class1.isAssignableFrom(entity.GetType()) && entity.boundingBox.intersectsWith(axisalignedbb))
                    {
                        list.add(entity);
                    }
                }
            }
        }
Exemple #2
0
 public double calculateZOffset(AxisAlignedBB axisalignedbb, double d)
 {
     if (axisalignedbb.maxX <= minX || axisalignedbb.minX >= maxX)
     {
         return(d);
     }
     if (axisalignedbb.maxY <= minY || axisalignedbb.minY >= maxY)
     {
         return(d);
     }
     if (d > 0.0D && axisalignedbb.maxZ <= minZ)
     {
         double d1 = minZ - axisalignedbb.maxZ;
         if (d1 < d)
         {
             d = d1;
         }
     }
     if (d < 0.0D && axisalignedbb.minZ >= maxZ)
     {
         double d2 = maxZ - axisalignedbb.minZ;
         if (d2 > d)
         {
             d = d2;
         }
     }
     return(d);
 }
Exemple #3
0
        public virtual void getEntitiesWithinAABBForEntity(Entity entity, AxisAlignedBB axisalignedbb, List list)
        {
            int i = MathHelper.floor_double((axisalignedbb.minY - 2D) / 16D);
            int j = MathHelper.floor_double((axisalignedbb.maxY + 2D) / 16D);

            if (i < 0)
            {
                i = 0;
            }
            if (j >= entities.Length)
            {
                j = entities.Length - 1;
            }
            for (int k = i; k <= j; k++)
            {
                List list1 = entities[k];
                for (int l = 0; l < list1.size(); l++)
                {
                    var entity1 = (Entity)list1.get(l);
                    if (entity1 != entity && entity1.boundingBox.intersectsWith(axisalignedbb))
                    {
                        list.add(entity1);
                    }
                }
            }
        }
Exemple #4
0
        public override AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
        {
            float f = 0.0625F;

            return(AxisAlignedBB.getBoundingBoxFromPool(i + f, j, k + f, (i + 1) - f,
                                                        (j + 1) - f, (k + 1) - f));
        }
Exemple #5
0
 public override void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb,
     ArrayList arraylist)
 {
     int l = world.getBlockMetadata(i, j, k);
     if (l == 0)
     {
         setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 1.0F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
         setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
     }
     else if (l == 1)
     {
         setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 1.0F, 1.0F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
         setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
     }
     else if (l == 2)
     {
         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
         setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 1.0F, 1.0F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
     }
     else if (l == 3)
     {
         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
         setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F);
         base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
     }
     setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
 }
Exemple #6
0
 public void setBB(AxisAlignedBB axisalignedbb)
 {
     minX = axisalignedbb.minX;
     minY = axisalignedbb.minY;
     minZ = axisalignedbb.minZ;
     maxX = axisalignedbb.maxX;
     maxY = axisalignedbb.maxY;
     maxZ = axisalignedbb.maxZ;
 }
Exemple #7
0
        public virtual void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb,
                                                      ArrayList arraylist)
        {
            AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(world, i, j, k);

            if (axisalignedbb1 != null && axisalignedbb.intersectsWith(axisalignedbb1))
            {
                arraylist.add(axisalignedbb1);
            }
        }
Exemple #8
0
        public override AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
        {
            int   l  = world.getBlockMetadata(i, j, k);
            float f  = 0.0625F;
            float f1 = (1 + l * 2) / 16F;
            float f2 = 0.5F;

            return(AxisAlignedBB.getBoundingBoxFromPool(i + f1, j, k + f, (i + 1) - f,
                                                        (j + f2) - f, (k + 1) - f));
        }
Exemple #9
0
        public bool isOffsetPositionInLiquid(double d, double d1, double d2)
        {
            AxisAlignedBB axisalignedbb = boundingBox.getOffsetBoundingBox(d, d1, d2);
            List          list          = worldObj.getCollidingBoundingBoxes(this, axisalignedbb);

            if (list.size() > 0)
            {
                return(false);
            }
            return(!worldObj.getIsAnyLiquid(axisalignedbb));
        }
Exemple #10
0
 public bool intersectsWith(AxisAlignedBB axisalignedbb)
 {
     if (axisalignedbb.maxX <= minX || axisalignedbb.minX >= maxX)
     {
         return(false);
     }
     if (axisalignedbb.maxY <= minY || axisalignedbb.minY >= maxY)
     {
         return(false);
     }
     return(axisalignedbb.maxZ > minZ && axisalignedbb.minZ < maxZ);
 }
Exemple #11
0
        private bool isCourseTraversable(double d, double d1, double d2, double d3)
        {
            double        d4            = (waypointX - posX) / d3;
            double        d5            = (waypointY - posY) / d3;
            double        d6            = (waypointZ - posZ) / d3;
            AxisAlignedBB axisalignedbb = boundingBox.copy();

            for (int i = 1; i < d3; i++)
            {
                axisalignedbb.offset(d4, d5, d6);
                if (worldObj.getCollidingBoundingBoxes(this, axisalignedbb).size() > 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #12
0
        public override void onUpdate()
        {
            lastTickPosX = posX;
            lastTickPosY = posY;
            lastTickPosZ = posZ;
            base.onUpdate();
            if (shake > 0)
            {
                shake--;
            }
            if (inGround)
            {
                int i = worldObj.getBlockId(xTile, yTile, zTile);
                if (i != inTile)
                {
                    inGround       = false;
                    motionX       *= rand.nextFloat() * 0.2F;
                    motionY       *= rand.nextFloat() * 0.2F;
                    motionZ       *= rand.nextFloat() * 0.2F;
                    field_20081_ak = 0;
                    field_20079_al = 0;
                }
                else
                {
                    field_20081_ak++;
                    if (field_20081_ak == 1200)
                    {
                        setEntityDead();
                    }
                    return;
                }
            }
            else
            {
                field_20079_al++;
            }
            Vec3D vec3d  = Vec3D.createVector(posX, posY, posZ);
            Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.createVector(posX, posY, posZ);
            vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord,
                                            movingobjectposition.hitVec.zCoord);
            }
            if (!worldObj.singleplayerWorld)
            {
                Entity entity = null;
                List   list   = worldObj.getEntitiesWithinAABBExcludingEntity(this,
                                                                              boundingBox.addCoord(motionX, motionY, motionZ)
                                                                              .expand(1.0D, 1.0D, 1.0D));
                double d = 0.0D;
                for (int i1 = 0; i1 < list.size(); i1++)
                {
                    var entity1 = (Entity)list.get(i1);
                    if (!entity1.canBeCollidedWith() || entity1 == field_20083_aj && field_20079_al < 5)
                    {
                        continue;
                    }
                    float                f4                    = 0.3F;
                    AxisAlignedBB        axisalignedbb         = entity1.boundingBox.expand(f4, f4, f4);
                    MovingObjectPosition movingobjectposition1 = axisalignedbb.func_706_a(vec3d, vec3d1);
                    if (movingobjectposition1 == null)
                    {
                        continue;
                    }
                    double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
                    if (d1 < d || d == 0.0D)
                    {
                        entity = entity1;
                        d      = d1;
                    }
                }

                if (entity != null)
                {
                    movingobjectposition = new MovingObjectPosition(entity);
                }
            }
            if (movingobjectposition != null)
            {
                if (movingobjectposition.entityHit != null)
                {
                    if (!movingobjectposition.entityHit.attackEntityFrom(field_20083_aj, 0))
                    {
                        ;
                    }
                }
                if (!worldObj.singleplayerWorld && rand.nextInt(8) == 0)
                {
                    byte byte0 = 1;
                    if (rand.nextInt(32) == 0)
                    {
                        byte0 = 4;
                    }
                    for (int k = 0; k < byte0; k++)
                    {
                        var entitychicken = new EntityChicken(worldObj);
                        entitychicken.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
                        worldObj.entityJoinedWorld(entitychicken);
                    }
                }
                for (int j = 0; j < 8; j++)
                {
                    worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
                }

                setEntityDead();
            }
            posX += motionX;
            posY += motionY;
            posZ += motionZ;
            float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);

            rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
            for (rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
                 rotationPitch - prevRotationPitch < -180F;
                 prevRotationPitch -= 360F)
            {
            }
            for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
            {
            }
            rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
            rotationYaw   = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
            float f1 = 0.99F;
            float f2 = 0.03F;

            if (handleWaterMovement())
            {
                for (int l = 0; l < 4; l++)
                {
                    float f3 = 0.25F;
                    worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3,
                                           posZ - motionZ * f3, motionX, motionY, motionZ);
                }

                f1 = 0.8F;
            }
            motionX *= f1;
            motionY *= f1;
            motionZ *= f1;
            motionY -= f2;
            setPosition(posX, posY, posZ);
        }
Exemple #13
0
        public override void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb,
                                                       ArrayList arraylist)
        {
            int l = world.getBlockMetadata(i, j, k);

            if (l == 0)
            {
                setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 1.0F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
                setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
            }
            else if (l == 1)
            {
                setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 1.0F, 1.0F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
                setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
            }
            else if (l == 2)
            {
                setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
                setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 1.0F, 1.0F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
            }
            else if (l == 3)
            {
                setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
                setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F);
                base.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
            }
            setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        }
Exemple #14
0
        public virtual bool handleMaterialAcceleration(AxisAlignedBB axisalignedbb, Material material, Entity entity)
        {
            int i = MathHelper.floor_double(axisalignedbb.minX);
            int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
            int k = MathHelper.floor_double(axisalignedbb.minY);
            int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
            int i1 = MathHelper.floor_double(axisalignedbb.minZ);
            int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);
            if (!checkChunksExist(i, k, i1, j, l, j1))
            {
                return false;
            }
            bool flag = false;
            Vec3D vec3d = Vec3D.createVector(0.0D, 0.0D, 0.0D);
            for (int k1 = i; k1 < j; k1++)
            {
                for (int l1 = k; l1 < l; l1++)
                {
                    for (int i2 = i1; i2 < j1; i2++)
                    {
                        Block block = Block.blocksList[getBlockId(k1, l1, i2)];
                        if (block == null || block.blockMaterial != material)
                        {
                            continue;
                        }
                        double d1 = (l1 + 1) - BlockFluids.setFluidHeight(getBlockMetadata(k1, l1, i2));
                        if (l >= d1)
                        {
                            flag = true;
                            block.velocityToAddToEntity(this, k1, l1, i2, entity, vec3d);
                        }
                    }
                }
            }

            if (vec3d.lengthVector() > 0.0D)
            {
                vec3d = vec3d.normalize();
                double d = 0.0040000000000000001D;
                entity.motionX += vec3d.xCoord*d;
                entity.motionY += vec3d.yCoord*d;
                entity.motionZ += vec3d.zCoord*d;
            }
            return flag;
        }
Exemple #15
0
        public override void onUpdate()
        {
            base.onUpdate();
            if (field_9177_b > 0)
            {
                field_9177_b--;
            }
            if (damageTaken > 0)
            {
                damageTaken--;
            }
            prevPosX = posX;
            prevPosY = posY;
            prevPosZ = posZ;
            int    i = 5;
            double d = 0.0D;

            for (int j = 0; j < i; j++)
            {
                double d4 = (boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (j + 0)) / i) -
                            0.125D;
                double d8 = (boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (j + 1)) / i) -
                            0.125D;
                AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBoxFromPool(boundingBox.minX, d4,
                                                                                   boundingBox.minZ, boundingBox.maxX,
                                                                                   d8, boundingBox.maxZ);
                if (worldObj.isAABBInMaterial(axisalignedbb, Material.water))
                {
                    d += 1.0D / i;
                }
            }

            if (worldObj.singleplayerWorld)
            {
                if (field_9176_d > 0)
                {
                    double d1 = posX + (field_9174_e - posX) / field_9176_d;
                    double d5 = posY + (field_9172_f - posY) / field_9176_d;
                    double d9 = posZ + (field_9175_aj - posZ) / field_9176_d;
                    double d12;
                    for (d12 = field_9173_ak - rotationYaw; d12 < -180D; d12 += 360D)
                    {
                    }
                    for (; d12 >= 180D; d12 -= 360D)
                    {
                    }
                    rotationYaw   += (float)(d12 / field_9176_d);
                    rotationPitch += (float)((field_9171_al - rotationPitch) / field_9176_d);
                    field_9176_d--;
                    setPosition(d1, d5, d9);
                    setRotation(rotationYaw, rotationPitch);
                }
                else
                {
                    double d2  = posX + motionX;
                    double d6  = posY + motionY;
                    double d10 = posZ + motionZ;
                    setPosition(d2, d6, d10);
                    if (onGround)
                    {
                        motionX *= 0.5D;
                        motionY *= 0.5D;
                        motionZ *= 0.5D;
                    }
                    motionX *= 0.99000000953674316D;
                    motionY *= 0.94999998807907104D;
                    motionZ *= 0.99000000953674316D;
                }
                return;
            }
            double d3 = d * 2D - 1.0D;

            motionY += 0.039999999105930328D * d3;
            if (riddenByEntity != null)
            {
                motionX += riddenByEntity.motionX * 0.20000000000000001D;
                motionZ += riddenByEntity.motionZ * 0.20000000000000001D;
            }
            double d7 = 0.40000000000000002D;

            if (motionX < -d7)
            {
                motionX = -d7;
            }
            if (motionX > d7)
            {
                motionX = d7;
            }
            if (motionZ < -d7)
            {
                motionZ = -d7;
            }
            if (motionZ > d7)
            {
                motionZ = d7;
            }
            if (onGround)
            {
                motionX *= 0.5D;
                motionY *= 0.5D;
                motionZ *= 0.5D;
            }
            moveEntity(motionX, motionY, motionZ);
            double d11 = Math.sqrt(motionX * motionX + motionZ * motionZ);

            if (d11 > 0.14999999999999999D)
            {
                double d13 = Math.cos((rotationYaw * 3.1415926535897931D) / 180D);
                double d15 = Math.sin((rotationYaw * 3.1415926535897931D) / 180D);
                for (int i1 = 0; i1 < 1.0D + d11 * 60D; i1++)
                {
                    double d18 = rand.nextFloat() * 2.0F - 1.0F;
                    double d20 = (rand.nextInt(2) * 2 - 1) * 0.69999999999999996D;
                    if (rand.nextBoolean())
                    {
                        double d21 = (posX - d13 * d18 * 0.80000000000000004D) + d15 * d20;
                        double d23 = posZ - d15 * d18 * 0.80000000000000004D - d13 * d20;
                        worldObj.spawnParticle("splash", d21, posY - 0.125D, d23, motionX, motionY, motionZ);
                    }
                    else
                    {
                        double d22 = posX + d13 + d15 * d18 * 0.69999999999999996D;
                        double d24 = (posZ + d15) - d13 * d18 * 0.69999999999999996D;
                        worldObj.spawnParticle("splash", d22, posY - 0.125D, d24, motionX, motionY, motionZ);
                    }
                }
            }
            if (isCollidedHorizontally && d11 > 0.14999999999999999D)
            {
                if (!worldObj.singleplayerWorld)
                {
                    setEntityDead();
                    for (int k = 0; k < 3; k++)
                    {
                        dropItemWithOffset(Block.planks.blockID, 1, 0.0F);
                    }

                    for (int l = 0; l < 2; l++)
                    {
                        dropItemWithOffset(Item.stick.shiftedIndex, 1, 0.0F);
                    }
                }
            }
            else
            {
                motionX *= 0.99000000953674316D;
                motionY *= 0.94999998807907104D;
                motionZ *= 0.99000000953674316D;
            }
            rotationPitch = 0.0F;
            double d14 = rotationYaw;
            double d16 = prevPosX - posX;
            double d17 = prevPosZ - posZ;

            if (d16 * d16 + d17 * d17 > 0.001D)
            {
                d14 = (float)((Math.atan2(d17, d16) * 180D) / 3.1415926535897931D);
            }
            double d19;

            for (d19 = d14 - rotationYaw; d19 >= 180D; d19 -= 360D)
            {
            }
            for (; d19 < -180D; d19 += 360D)
            {
            }
            if (d19 > 20D)
            {
                d19 = 20D;
            }
            if (d19 < -20D)
            {
                d19 = -20D;
            }
            rotationYaw += (float)(d19);
            setRotation(rotationYaw, rotationPitch);
            List list = worldObj.getEntitiesWithinAABBExcludingEntity(this,
                                                                      boundingBox.expand(0.20000000298023224D, 0.0D,
                                                                                         0.20000000298023224D));

            if (list != null && list.size() > 0)
            {
                for (int j1 = 0; j1 < list.size(); j1++)
                {
                    var entity = (Entity)list.get(j1);
                    if (entity != riddenByEntity && entity.canBePushed() && (entity is EntityBoat))
                    {
                        entity.applyEntityCollision(this);
                    }
                }
            }
            if (riddenByEntity != null && riddenByEntity.isDead)
            {
                riddenByEntity = null;
            }
        }
Exemple #16
0
 public void setBB(AxisAlignedBB axisalignedbb)
 {
     minX = axisalignedbb.minX;
     minY = axisalignedbb.minY;
     minZ = axisalignedbb.minZ;
     maxX = axisalignedbb.maxX;
     maxY = axisalignedbb.maxY;
     maxZ = axisalignedbb.maxZ;
 }
Exemple #17
0
 public override void getEntitiesOfTypeWithinAAAB(Class class1, AxisAlignedBB axisalignedbb, List list)
 {
 }
Exemple #18
0
 public virtual void getEntitiesOfTypeWithinAAAB(Class class1, AxisAlignedBB axisalignedbb, List list)
 {
     int i = MathHelper.floor_double((axisalignedbb.minY - 2D)/16D);
     int j = MathHelper.floor_double((axisalignedbb.maxY + 2D)/16D);
     if (i < 0)
     {
         i = 0;
     }
     if (j >= entities.Length)
     {
         j = entities.Length - 1;
     }
     for (int k = i; k <= j; k++)
     {
         List list1 = entities[k];
         for (int l = 0; l < list1.size(); l++)
         {
             var entity = (Entity) list1.get(l);
             if (class1.isAssignableFrom(entity.GetType()) && entity.boundingBox.intersectsWith(axisalignedbb))
             {
                 list.add(entity);
             }
         }
     }
 }
Exemple #19
0
 public virtual bool isBoundingBoxBurning(AxisAlignedBB axisalignedbb)
 {
     int i = MathHelper.floor_double(axisalignedbb.minX);
     int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
     int k = MathHelper.floor_double(axisalignedbb.minY);
     int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
     int i1 = MathHelper.floor_double(axisalignedbb.minZ);
     int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);
     if (checkChunksExist(i, k, i1, j, l, j1))
     {
         for (int k1 = i; k1 < j; k1++)
         {
             for (int l1 = k; l1 < l; l1++)
             {
                 for (int i2 = i1; i2 < j1; i2++)
                 {
                     int j2 = getBlockId(k1, l1, i2);
                     if (j2 == Block.fire.blockID || j2 == Block.lavaStill.blockID ||
                         j2 == Block.lavaMoving.blockID)
                     {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
Exemple #20
0
        public virtual List getCollidingBoundingBoxes(Entity entity, AxisAlignedBB axisalignedbb)
        {
            field_9207_I.clear();
            int i = MathHelper.floor_double(axisalignedbb.minX);
            int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
            int k = MathHelper.floor_double(axisalignedbb.minY);
            int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
            int i1 = MathHelper.floor_double(axisalignedbb.minZ);
            int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);
            for (int k1 = i; k1 < j; k1++)
            {
                for (int l1 = i1; l1 < j1; l1++)
                {
                    if (!blockExists(k1, 64, l1))
                    {
                        continue;
                    }
                    for (int i2 = k - 1; i2 < l; i2++)
                    {
                        Block block = Block.blocksList[getBlockId(k1, i2, l1)];
                        if (block != null)
                        {
                            block.getCollidingBoundingBoxes(this, k1, i2, l1, axisalignedbb, field_9207_I);
                        }
                    }
                }
            }

            double d = 0.25D;
            List list = getEntitiesWithinAABBExcludingEntity(entity, axisalignedbb.expand(d, d, d));
            for (int j2 = 0; j2 < list.size(); j2++)
            {
                AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).getBoundingBox();
                if (axisalignedbb1 != null && axisalignedbb1.intersectsWith(axisalignedbb))
                {
                    field_9207_I.add(axisalignedbb1);
                }
                axisalignedbb1 = entity.func_89_d((Entity) list.get(j2));
                if (axisalignedbb1 != null && axisalignedbb1.intersectsWith(axisalignedbb))
                {
                    field_9207_I.add(axisalignedbb1);
                }
            }

            return field_9207_I;
        }
Exemple #21
0
        public virtual List getEntitiesWithinAABBExcludingEntity(Entity entity, AxisAlignedBB axisalignedbb)
        {
            field_778_L.clear();
            int i = MathHelper.floor_double((axisalignedbb.minX - 2D)/16D);
            int j = MathHelper.floor_double((axisalignedbb.maxX + 2D)/16D);
            int k = MathHelper.floor_double((axisalignedbb.minZ - 2D)/16D);
            int l = MathHelper.floor_double((axisalignedbb.maxZ + 2D)/16D);
            for (int i1 = i; i1 <= j; i1++)
            {
                for (int j1 = k; j1 <= l; j1++)
                {
                    if (chunkExists(i1, j1))
                    {
                        getChunkFromChunkCoords(i1, j1).getEntitiesWithinAABBForEntity(entity, axisalignedbb,
                                                                                       field_778_L);
                    }
                }
            }

            return field_778_L;
        }
Exemple #22
0
        public virtual float func_494_a(Vec3D vec3d, AxisAlignedBB axisalignedbb)
        {
            double d = 1.0D/((axisalignedbb.maxX - axisalignedbb.minX)*2D + 1.0D);
            double d1 = 1.0D/((axisalignedbb.maxY - axisalignedbb.minY)*2D + 1.0D);
            double d2 = 1.0D/((axisalignedbb.maxZ - axisalignedbb.minZ)*2D + 1.0D);
            int i = 0;
            int j = 0;
            for (float f = 0.0F; f <= 1.0F; f = (float) (f + d))
            {
                for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float) (f1 + d1))
                {
                    for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float) (f2 + d2))
                    {
                        double d3 = axisalignedbb.minX + (axisalignedbb.maxX - axisalignedbb.minX)*f;
                        double d4 = axisalignedbb.minY + (axisalignedbb.maxY - axisalignedbb.minY)*f1;
                        double d5 = axisalignedbb.minZ + (axisalignedbb.maxZ - axisalignedbb.minZ)*f2;
                        if (rayTraceBlocks(Vec3D.createVector(d3, d4, d5), vec3d) == null)
                        {
                            i++;
                        }
                        j++;
                    }
                }
            }

            return i/(float) j;
        }
Exemple #23
0
        public bool checkIfAABBIsClear(AxisAlignedBB axisalignedbb)
        {
            List list = getEntitiesWithinAABBExcludingEntity(null, axisalignedbb);
            for (int i = 0; i < list.size(); i++)
            {
                var entity = (Entity) list.get(i);
                if (!entity.isDead && entity.preventEntitySpawning)
                {
                    return false;
                }
            }

            return true;
        }
Exemple #24
0
        public virtual bool isMaterialInBB(AxisAlignedBB axisalignedbb, Material material)
        {
            int i = MathHelper.floor_double(axisalignedbb.minX);
            int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
            int k = MathHelper.floor_double(axisalignedbb.minY);
            int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
            int i1 = MathHelper.floor_double(axisalignedbb.minZ);
            int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);
            for (int k1 = i; k1 < j; k1++)
            {
                for (int l1 = k; l1 < l; l1++)
                {
                    for (int i2 = i1; i2 < j1; i2++)
                    {
                        Block block = Block.blocksList[getBlockId(k1, l1, i2)];
                        if (block != null && block.blockMaterial == material)
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Exemple #25
0
 public virtual void getEntitiesWithinAABBForEntity(Entity entity, AxisAlignedBB axisalignedbb, List list)
 {
     int i = MathHelper.floor_double((axisalignedbb.minY - 2D)/16D);
     int j = MathHelper.floor_double((axisalignedbb.maxY + 2D)/16D);
     if (i < 0)
     {
         i = 0;
     }
     if (j >= entities.Length)
     {
         j = entities.Length - 1;
     }
     for (int k = i; k <= j; k++)
     {
         List list1 = entities[k];
         for (int l = 0; l < list1.size(); l++)
         {
             var entity1 = (Entity) list1.get(l);
             if (entity1 != entity && entity1.boundingBox.intersectsWith(axisalignedbb))
             {
                 list.add(entity1);
             }
         }
     }
 }
        private void setStateIfMobInteractsWithPlate(World world, int i, int j, int k)
        {
            bool  flag  = world.getBlockMetadata(i, j, k) == 1;
            bool  flag1 = false;
            float f     = 0.125F;
            List  list  = null;

            if (triggerMobType == EnumMobType.everything)
            {
                list = world.getEntitiesWithinAABBExcludingEntity(null,
                                                                  AxisAlignedBB.getBoundingBoxFromPool(i + f, j,
                                                                                                       k + f,
                                                                                                       (i + 1) -
                                                                                                       f,
                                                                                                       j +
                                                                                                       0.25D,
                                                                                                       (k + 1) -
                                                                                                       f));
            }
            if (triggerMobType == EnumMobType.mobs)
            {
                list = world.getEntitiesWithinAABB(typeof(EntityLiving),
                                                   AxisAlignedBB.getBoundingBoxFromPool(i + f, j, k + f,
                                                                                        (i + 1) - f,
                                                                                        j + 0.25D,
                                                                                        (k + 1) - f));
            }
            if (triggerMobType == EnumMobType.players)
            {
                list = world.getEntitiesWithinAABB(typeof(EntityPlayer),
                                                   AxisAlignedBB.getBoundingBoxFromPool(i + f, j, k + f,
                                                                                        (i + 1) - f,
                                                                                        j + 0.25D,
                                                                                        (k + 1) - f));
            }
            if (list.size() > 0)
            {
                flag1 = true;
            }
            if (flag1 && !flag)
            {
                world.setBlockMetadataWithNotify(i, j, k, 1);
                world.notifyBlocksOfNeighborChange(i, j, k, blockID);
                world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
                world.markBlocksDirty(i, j, k, i, j, k);
                world.playSoundEffect(i + 0.5D, j + 0.10000000000000001D, k + 0.5D,
                                      "random.click", 0.3F, 0.6F);
            }
            if (!flag1 && flag)
            {
                world.setBlockMetadataWithNotify(i, j, k, 0);
                world.notifyBlocksOfNeighborChange(i, j, k, blockID);
                world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
                world.markBlocksDirty(i, j, k, i, j, k);
                world.playSoundEffect(i + 0.5D, j + 0.10000000000000001D, k + 0.5D,
                                      "random.click", 0.3F, 0.5F);
            }
            if (flag1)
            {
                world.func_22074_c(i, j, k, blockID, tickRate());
            }
        }
Exemple #27
0
        public override void onUpdate()
        {
            base.onUpdate();
            if (field_6149_an > 0)
            {
                double d  = posX + (field_6148_ao - posX) / field_6149_an;
                double d1 = posY + (field_6147_ap - posY) / field_6149_an;
                double d2 = posZ + (field_6146_aq - posZ) / field_6149_an;
                double d4;
                for (d4 = field_6145_ar - rotationYaw; d4 < -180D; d4 += 360D)
                {
                }
                for (; d4 >= 180D; d4 -= 360D)
                {
                }
                rotationYaw   += (float)(d4 / field_6149_an);
                rotationPitch += (float)((field_6144_as - rotationPitch) / field_6149_an);
                field_6149_an--;
                setPosition(d, d1, d2);
                setRotation(rotationYaw, rotationPitch);
                return;
            }
            if (!worldObj.singleplayerWorld)
            {
                ItemStack itemstack = angler.getCurrentEquippedItem();
                if (angler.isDead || !angler.isEntityAlive() || itemstack == null ||
                    itemstack.getItem() != Item.fishingRod || getDistanceSqToEntity(angler) > 1024D)
                {
                    setEntityDead();
                    angler.fishEntity = null;
                    return;
                }
                if (bobber != null)
                {
                    if (bobber.isDead)
                    {
                        bobber = null;
                    }
                    else
                    {
                        posX = bobber.posX;
                        posY = bobber.boundingBox.minY + bobber.height * 0.80000000000000004D;
                        posZ = bobber.posZ;
                        return;
                    }
                }
            }
            if (shake > 0)
            {
                shake--;
            }
            if (inGround)
            {
                int i = worldObj.getBlockId(xTile, yTile, zTile);
                if (i != inTile)
                {
                    inGround      = false;
                    motionX      *= rand.nextFloat() * 0.2F;
                    motionY      *= rand.nextFloat() * 0.2F;
                    motionZ      *= rand.nextFloat() * 0.2F;
                    ticksInGround = 0;
                    ticksInAir    = 0;
                }
                else
                {
                    ticksInGround++;
                    if (ticksInGround == 1200)
                    {
                        setEntityDead();
                    }
                    return;
                }
            }
            else
            {
                ticksInAir++;
            }
            Vec3D vec3d  = Vec3D.createVector(posX, posY, posZ);
            Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.createVector(posX, posY, posZ);
            vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord,
                                            movingobjectposition.hitVec.zCoord);
            }
            Entity entity = null;
            List   list   = worldObj.getEntitiesWithinAABBExcludingEntity(this,
                                                                          boundingBox.addCoord(motionX, motionY, motionZ).
                                                                          expand(1.0D, 1.0D, 1.0D));
            double d3 = 0.0D;

            for (int j = 0; j < list.size(); j++)
            {
                var entity1 = (Entity)list.get(j);
                if (!entity1.canBeCollidedWith() || entity1 == angler && ticksInAir < 5)
                {
                    continue;
                }
                float                f2                    = 0.3F;
                AxisAlignedBB        axisalignedbb         = entity1.boundingBox.expand(f2, f2, f2);
                MovingObjectPosition movingobjectposition1 = axisalignedbb.func_706_a(vec3d, vec3d1);
                if (movingobjectposition1 == null)
                {
                    continue;
                }
                double d6 = vec3d.distanceTo(movingobjectposition1.hitVec);
                if (d6 < d3 || d3 == 0.0D)
                {
                    entity = entity1;
                    d3     = d6;
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }
            if (movingobjectposition != null)
            {
                if (movingobjectposition.entityHit != null)
                {
                    if (movingobjectposition.entityHit.attackEntityFrom(angler, 0))
                    {
                        bobber = movingobjectposition.entityHit;
                    }
                }
                else
                {
                    inGround = true;
                }
            }
            if (inGround)
            {
                return;
            }
            moveEntity(motionX, motionY, motionZ);
            float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);

            rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
            for (rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
                 rotationPitch - prevRotationPitch < -180F;
                 prevRotationPitch -= 360F)
            {
            }
            for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
            {
            }
            rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
            rotationYaw   = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
            float f1 = 0.92F;

            if (onGround || isCollidedHorizontally)
            {
                f1 = 0.5F;
            }
            int    k  = 5;
            double d5 = 0.0D;

            for (int l = 0; l < k; l++)
            {
                double d8 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (l + 0)) / k) -
                             0.125D) + 0.125D;
                double d9 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (l + 1)) / k) -
                             0.125D) + 0.125D;
                AxisAlignedBB axisalignedbb1 = AxisAlignedBB.getBoundingBoxFromPool(boundingBox.minX, d8,
                                                                                    boundingBox.minZ, boundingBox.maxX,
                                                                                    d9, boundingBox.maxZ);
                if (worldObj.isAABBInMaterial(axisalignedbb1, Material.water))
                {
                    d5 += 1.0D / k;
                }
            }

            if (d5 > 0.0D)
            {
                if (ticksCatchable > 0)
                {
                    ticksCatchable--;
                }
                else if (rand.nextInt(500) == 0)
                {
                    ticksCatchable = rand.nextInt(30) + 10;
                    motionY       -= 0.20000000298023224D;
                    worldObj.playSoundAtEntity(this, "random.splash", 0.25F,
                                               1.0F + (rand.nextFloat() - rand.nextFloat()) * 0.4F);
                    float f3 = MathHelper.floor_double(boundingBox.minY);
                    for (int i1 = 0; i1 < 1.0F + width * 20F; i1++)
                    {
                        float f4 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                        float f6 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                        worldObj.spawnParticle("bubble", posX + f4, f3 + 1.0F, posZ + f6, motionX,
                                               motionY - (rand.nextFloat() * 0.2F), motionZ);
                    }

                    for (int j1 = 0; j1 < 1.0F + width * 20F; j1++)
                    {
                        float f5 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                        float f7 = (rand.nextFloat() * 2.0F - 1.0F) * width;
                        worldObj.spawnParticle("splash", posX + f5, f3 + 1.0F, posZ + f7, motionX,
                                               motionY, motionZ);
                    }
                }
            }
            if (ticksCatchable > 0)
            {
                motionY -= (rand.nextFloat() * rand.nextFloat() * rand.nextFloat()) * 0.20000000000000001D;
            }
            double d7 = d5 * 2D - 1.0D;

            motionY += 0.039999999105930328D * d7;
            if (d5 > 0.0D)
            {
                f1       = (float)(f1 * 0.90000000000000002D);
                motionY *= 0.80000000000000004D;
            }
            motionX *= f1;
            motionY *= f1;
            motionZ *= f1;
            setPosition(posX, posY, posZ);
        }
Exemple #28
0
        public virtual bool isAABBInMaterial(AxisAlignedBB axisalignedbb, Material material)
        {
            int i = MathHelper.floor_double(axisalignedbb.minX);
            int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
            int k = MathHelper.floor_double(axisalignedbb.minY);
            int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
            int i1 = MathHelper.floor_double(axisalignedbb.minZ);
            int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);
            for (int k1 = i; k1 < j; k1++)
            {
                for (int l1 = k; l1 < l; l1++)
                {
                    for (int i2 = i1; i2 < j1; i2++)
                    {
                        Block block = Block.blocksList[getBlockId(k1, l1, i2)];
                        if (block == null || block.blockMaterial != material)
                        {
                            continue;
                        }
                        int j2 = getBlockMetadata(k1, l1, i2);
                        double d = l1 + 1;
                        if (j2 < 8)
                        {
                            d = (l1 + 1) - j2/8D;
                        }
                        if (d >= axisalignedbb.minY)
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Exemple #29
0
 public virtual AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
 {
     return(AxisAlignedBB.getBoundingBoxFromPool(i + minX, j + minY, k + minZ,
                                                 i + maxX, j + maxY, k + maxZ));
 }
Exemple #30
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;
            }
        }
Exemple #31
0
 public bool intersectsWith(AxisAlignedBB axisalignedbb)
 {
     if (axisalignedbb.maxX <= minX || axisalignedbb.minX >= maxX)
     {
         return false;
     }
     if (axisalignedbb.maxY <= minY || axisalignedbb.minY >= maxY)
     {
         return false;
     }
     return axisalignedbb.maxZ > minZ && axisalignedbb.minZ < maxZ;
 }
Exemple #32
0
        public virtual List getEntitiesWithinAABB(Class class1, AxisAlignedBB axisalignedbb)
        {
            int i = MathHelper.floor_double((axisalignedbb.minX - 2D)/16D);
            int j = MathHelper.floor_double((axisalignedbb.maxX + 2D)/16D);
            int k = MathHelper.floor_double((axisalignedbb.minZ - 2D)/16D);
            int l = MathHelper.floor_double((axisalignedbb.maxZ + 2D)/16D);
            var arraylist = new ArrayList();
            for (int i1 = i; i1 <= j; i1++)
            {
                for (int j1 = k; j1 <= l; j1++)
                {
                    if (chunkExists(i1, j1))
                    {
                        getChunkFromChunkCoords(i1, j1).getEntitiesOfTypeWithinAAAB(class1, axisalignedbb, arraylist);
                    }
                }
            }

            return arraylist;
        }
Exemple #33
0
 public double calculateXOffset(AxisAlignedBB axisalignedbb, double d)
 {
     if (axisalignedbb.maxY <= minY || axisalignedbb.minY >= maxY)
     {
         return d;
     }
     if (axisalignedbb.maxZ <= minZ || axisalignedbb.minZ >= maxZ)
     {
         return d;
     }
     if (d > 0.0D && axisalignedbb.maxX <= minX)
     {
         double d1 = minX - axisalignedbb.maxX;
         if (d1 < d)
         {
             d = d1;
         }
     }
     if (d < 0.0D && axisalignedbb.minX >= maxX)
     {
         double d2 = maxX - axisalignedbb.minX;
         if (d2 > d)
         {
             d = d2;
         }
     }
     return d;
 }
Exemple #34
0
 public override void getEntitiesOfTypeWithinAAAB(Class class1, AxisAlignedBB axisalignedbb, List list)
 {
 }
Exemple #35
0
 public override void getEntitiesWithinAABBForEntity(Entity entity, AxisAlignedBB axisalignedbb, List list)
 {
 }
Exemple #36
0
        public virtual bool getIsAnyLiquid(AxisAlignedBB axisalignedbb)
        {
            int i = MathHelper.floor_double(axisalignedbb.minX);
            int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
            int k = MathHelper.floor_double(axisalignedbb.minY);
            int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
            int i1 = MathHelper.floor_double(axisalignedbb.minZ);
            int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);
            if (axisalignedbb.minX < 0.0D)
            {
                i--;
            }
            if (axisalignedbb.minY < 0.0D)
            {
                k--;
            }
            if (axisalignedbb.minZ < 0.0D)
            {
                i1--;
            }
            for (int k1 = i; k1 < j; k1++)
            {
                for (int l1 = k; l1 < l; l1++)
                {
                    for (int i2 = i1; i2 < j1; i2++)
                    {
                        Block block = Block.blocksList[getBlockId(k1, l1, i2)];
                        if (block != null && block.blockMaterial.getIsLiquid())
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Exemple #37
0
        public override void onUpdate()
        {
            base.onUpdate();
            if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
            {
                float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
                prevRotationYaw   = rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
                prevRotationPitch = rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
            }
            if (arrowShake > 0)
            {
                arrowShake--;
            }
            if (inGround)
            {
                int i = worldObj.getBlockId(xTile, yTile, zTile);
                if (i != inTile)
                {
                    inGround      = false;
                    motionX      *= rand.nextFloat() * 0.2F;
                    motionY      *= rand.nextFloat() * 0.2F;
                    motionZ      *= rand.nextFloat() * 0.2F;
                    ticksInGround = 0;
                    ticksInAir    = 0;
                }
                else
                {
                    ticksInGround++;
                    if (ticksInGround == 1200)
                    {
                        setEntityDead();
                    }
                    return;
                }
            }
            else
            {
                ticksInAir++;
            }
            Vec3D vec3d  = Vec3D.createVector(posX, posY, posZ);
            Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.createVector(posX, posY, posZ);
            vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord,
                                            movingobjectposition.hitVec.zCoord);
            }
            Entity entity = null;
            List   list   = worldObj.getEntitiesWithinAABBExcludingEntity(this,
                                                                          boundingBox.addCoord(motionX, motionY, motionZ).
                                                                          expand(1.0D, 1.0D, 1.0D));
            double d = 0.0D;

            for (int j = 0; j < list.size(); j++)
            {
                var entity1 = (Entity)list.get(j);
                if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5)
                {
                    continue;
                }
                float                f4                    = 0.3F;
                AxisAlignedBB        axisalignedbb         = entity1.boundingBox.expand(f4, f4, f4);
                MovingObjectPosition movingobjectposition1 = axisalignedbb.func_706_a(vec3d, vec3d1);
                if (movingobjectposition1 == null)
                {
                    continue;
                }
                double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
                if (d1 < d || d == 0.0D)
                {
                    entity = entity1;
                    d      = d1;
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }
            if (movingobjectposition != null)
            {
                if (movingobjectposition.entityHit != null)
                {
                    if (movingobjectposition.entityHit.attackEntityFrom(owner, 4))
                    {
                        worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
                        setEntityDead();
                    }
                    else
                    {
                        motionX         *= -0.10000000149011612D;
                        motionY         *= -0.10000000149011612D;
                        motionZ         *= -0.10000000149011612D;
                        rotationYaw     += 180F;
                        prevRotationYaw += 180F;
                        ticksInAir       = 0;
                    }
                }
                else
                {
                    xTile   = movingobjectposition.blockX;
                    yTile   = movingobjectposition.blockY;
                    zTile   = movingobjectposition.blockZ;
                    inTile  = worldObj.getBlockId(xTile, yTile, zTile);
                    motionX = (float)(movingobjectposition.hitVec.xCoord - posX);
                    motionY = (float)(movingobjectposition.hitVec.yCoord - posY);
                    motionZ = (float)(movingobjectposition.hitVec.zCoord - posZ);
                    float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
                    posX -= (motionX / f1) * 0.05000000074505806D;
                    posY -= (motionY / f1) * 0.05000000074505806D;
                    posZ -= (motionZ / f1) * 0.05000000074505806D;
                    worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
                    inGround   = true;
                    arrowShake = 7;
                }
            }
            posX += motionX;
            posY += motionY;
            posZ += motionZ;
            float f2 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);

            rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
            for (rotationPitch = (float)((Math.atan2(motionY, f2) * 180D) / 3.1415927410125732D);
                 rotationPitch - prevRotationPitch < -180F;
                 prevRotationPitch -= 360F)
            {
            }
            for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
            {
            }
            rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
            rotationYaw   = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
            float f3 = 0.99F;
            float f5 = 0.03F;

            if (handleWaterMovement())
            {
                for (int k = 0; k < 4; k++)
                {
                    float f6 = 0.25F;
                    worldObj.spawnParticle("bubble", posX - motionX * f6, posY - motionY * f6,
                                           posZ - motionZ * f6, motionX, motionY, motionZ);
                }

                f3 = 0.8F;
            }
            motionX *= f3;
            motionY *= f3;
            motionZ *= f3;
            motionY -= f5;
            setPosition(posX, posY, posZ);
        }
Exemple #38
0
        public 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  = (j / (i - 1.0F)) * 2.0F - 1.0F;
                        double d1 = (l / (i - 1.0F)) * 2.0F - 1.0F;
                        double d2 = (j1 / (i - 1.0F)) * 2.0F - 1.0F;
                        double d3 = 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;
                            }
                            int j4 = MathHelper.floor_double(d5);
                            int k4 = MathHelper.floor_double(d7);
                            int l4 = MathHelper.floor_double(d9);
                            int i5 = worldObj.getBlockId(j4, k4, l4);
                            if (i5 > 0)
                            {
                                f1 -= (Block.blocksList[i5].getExplosionResistance(exploder) + 0.3F) * f2;
                            }
                            if (f1 > 0.0F)
                            {
                                destroyedBlockPositions.add(new ChunkPosition(j4, k4, l4));
                            }
                            d5 += d * f2;
                            d7 += d1 * f2;
                            d9 += d2 * f2;
                            f1 -= f2 * 0.75F;
                        } while (true);

label0:
                        ;
                    }
                }
            }

            explosionSize *= 2.0F;
            int  k    = MathHelper.floor_double(explosionX - explosionSize - 1.0D);
            int  i1   = MathHelper.floor_double(explosionX + explosionSize + 1.0D);
            int  k1   = MathHelper.floor_double(explosionY - explosionSize - 1.0D);
            int  l1   = MathHelper.floor_double(explosionY + explosionSize + 1.0D);
            int  i2   = MathHelper.floor_double(explosionZ - explosionSize - 1.0D);
            int  j2   = MathHelper.floor_double(explosionZ + explosionSize + 1.0D);
            List list = worldObj.getEntitiesWithinAABBExcludingEntity(exploder,
                                                                      AxisAlignedBB.getBoundingBoxFromPool(k, k1, i2, i1,
                                                                                                           l1, j2));
            Vec3D vec3d = Vec3D.createVector(explosionX, explosionY, explosionZ);

            for (int k2 = 0; k2 < list.size(); k2++)
            {
                var    entity = (Entity)list.get(k2);
                double d4     = entity.getDistance(explosionX, explosionY, explosionZ) / explosionSize;
                if (d4 <= 1.0D)
                {
                    double d6  = entity.posX - explosionX;
                    double d8  = entity.posY - explosionY;
                    double d10 = entity.posZ - explosionZ;
                    double d11 = 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 * explosionSize + 1.0D));
                    double d14 = d13;
                    entity.motionX += d6 * d14;
                    entity.motionY += d8 * d14;
                    entity.motionZ += d10 * d14;
                }
            }

            explosionSize = f;
            var arraylist = new ArrayList();

            arraylist.addAll(destroyedBlockPositions);
            if (isFlaming)
            {
                for (int l2 = arraylist.size() - 1; l2 >= 0; l2--)
                {
                    var chunkposition = (ChunkPosition)arraylist.get(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 && Block.opaqueCubeLookup[i4] && ExplosionRNG.nextInt(3) == 0)
                    {
                        worldObj.setBlockWithNotify(i3, j3, k3, Block.fire.blockID);
                    }
                }
            }
        }
Exemple #39
0
 public virtual void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb,
     ArrayList arraylist)
 {
     AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(world, i, j, k);
     if (axisalignedbb1 != null && axisalignedbb.intersectsWith(axisalignedbb1))
     {
         arraylist.add(axisalignedbb1);
     }
 }
Exemple #40
0
 public override void getEntitiesWithinAABBForEntity(Entity entity, AxisAlignedBB axisalignedbb, List list)
 {
 }
Exemple #41
0
 public override AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
 {
     return(AxisAlignedBB.getBoundingBoxFromPool(i + 0, j + 0, k + 0, i + 1, j + 1, k + 1));
 }
Exemple #42
0
        public override void onUpdate()
        {
            base.onUpdate();
            fire = 10;
            if (shake > 0)
            {
                shake--;
            }
            if (inGround)
            {
                int i = worldObj.getBlockId(xTile, yTile, zTile);
                if (i != inTile)
                {
                    inGround      = false;
                    motionX      *= rand.nextFloat() * 0.2F;
                    motionY      *= rand.nextFloat() * 0.2F;
                    motionZ      *= rand.nextFloat() * 0.2F;
                    field_9190_an = 0;
                    ticksInAir    = 0;
                }
                else
                {
                    field_9190_an++;
                    if (field_9190_an == 1200)
                    {
                        setEntityDead();
                    }
                    return;
                }
            }
            else
            {
                ticksInAir++;
            }
            Vec3D vec3d  = Vec3D.createVector(posX, posY, posZ);
            Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.createVector(posX, posY, posZ);
            vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord,
                                            movingobjectposition.hitVec.zCoord);
            }
            Entity entity = null;
            List   list   = worldObj.getEntitiesWithinAABBExcludingEntity(this,
                                                                          boundingBox.addCoord(motionX, motionY, motionZ).
                                                                          expand(1.0D, 1.0D, 1.0D));
            double d = 0.0D;

            for (int j = 0; j < list.size(); j++)
            {
                var entity1 = (Entity)list.get(j);
                if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 25)
                {
                    continue;
                }
                float                f2                    = 0.3F;
                AxisAlignedBB        axisalignedbb         = entity1.boundingBox.expand(f2, f2, f2);
                MovingObjectPosition movingobjectposition1 = axisalignedbb.func_706_a(vec3d, vec3d1);
                if (movingobjectposition1 == null)
                {
                    continue;
                }
                double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
                if (d1 < d || d == 0.0D)
                {
                    entity = entity1;
                    d      = d1;
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }
            if (movingobjectposition != null)
            {
                if (movingobjectposition.entityHit != null)
                {
                    if (!movingobjectposition.entityHit.attackEntityFrom(owner, 0))
                    {
                        ;
                    }
                }
                worldObj.newExplosion(null, posX, posY, posZ, 1.0F, true);
                setEntityDead();
            }
            posX += motionX;
            posY += motionY;
            posZ += motionZ;
            float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);

            rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
            for (rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
                 rotationPitch - prevRotationPitch < -180F;
                 prevRotationPitch -= 360F)
            {
            }
            for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
            {
            }
            for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
            {
            }
            rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
            rotationYaw   = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
            float f1 = 0.95F;

            if (handleWaterMovement())
            {
                for (int k = 0; k < 4; k++)
                {
                    float f3 = 0.25F;
                    worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3,
                                           posZ - motionZ * f3, motionX, motionY, motionZ);
                }

                f1 = 0.8F;
            }
            motionX += field_9199_b;
            motionY += field_9198_c;
            motionZ += field_9196_d;
            motionX *= f1;
            motionY *= f1;
            motionZ *= f1;
            worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
            setPosition(posX, posY, posZ);
        }