Esempio n. 1
0
        public override void onUpdate()
        {
            lastTickPosX = posX;
            lastTickPosY = posY;
            lastTickPosZ = posZ;
            base.onUpdate();
            if (shakeSnowball > 0)
            {
                shakeSnowball--;
            }
            if (inGroundSnowball)
            {
                int i = worldObj.getBlockId(xTileSnowball, yTileSnowball, zTileSnowball);
                if (i != inTileSnowball)
                {
                    inGroundSnowball = false;
                    motionX *= rand.nextFloat()*0.2F;
                    motionY *= rand.nextFloat()*0.2F;
                    motionZ *= rand.nextFloat()*0.2F;
                    ticksOnGround = 0;
                    ticksInAir = 0;
                }
                else
                {
                    ticksOnGround++;
                    if (ticksOnGround == 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);
            }
            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 l = 0; l < list.size(); l++)
                {
                    var entity1 = (Entity) list.get(l);
                    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, 0)) ;
                }
                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 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 *= f1;
            motionY *= f1;
            motionZ *= f1;
            motionY -= f2;
            setPosition(posX, posY, posZ);
        }
Esempio n. 2
0
        public override ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
        {
            float  f  = 1.0F;
            float  f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f;
            float  f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f;
            double d  = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * f +
                         1.6200000000000001D) - entityplayer.yOffset;
            double d2     = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * f;
            Vec3D  vec3d  = Vec3D.createVector(d, d1, d2);
            float  f3     = MathHelper.cos(-f2 * 0.01745329F - 3.141593F);
            float  f4     = MathHelper.sin(-f2 * 0.01745329F - 3.141593F);
            float  f5     = -MathHelper.cos(-f1 * 0.01745329F);
            float  f6     = MathHelper.sin(-f1 * 0.01745329F);
            float  f7     = f4 * f5;
            float  f8     = f6;
            float  f9     = f3 * f5;
            double d3     = 5D;
            Vec3D  vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3);
            MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do(vec3d, vec3d1, isFull == 0);

            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.blockX;
                int j = movingobjectposition.blockY;
                int k = movingobjectposition.blockZ;
                if (!world.canMineBlock(entityplayer, i, j, k))
                {
                    return(itemstack);
                }
                if (isFull == 0)
                {
                    if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0)
                    {
                        world.setBlockWithNotify(i, j, k, 0);
                        return(new ItemStack(bucketWater));
                    }
                    if (world.getBlockMaterial(i, j, k) == Material.lava && world.getBlockMetadata(i, j, k) == 0)
                    {
                        world.setBlockWithNotify(i, j, k, 0);
                        return(new ItemStack(bucketLava));
                    }
                }
                else
                {
                    if (isFull < 0)
                    {
                        return(new ItemStack(bucketEmpty));
                    }
                    if (movingobjectposition.sideHit == 0)
                    {
                        j--;
                    }
                    if (movingobjectposition.sideHit == 1)
                    {
                        j++;
                    }
                    if (movingobjectposition.sideHit == 2)
                    {
                        k--;
                    }
                    if (movingobjectposition.sideHit == 3)
                    {
                        k++;
                    }
                    if (movingobjectposition.sideHit == 4)
                    {
                        i--;
                    }
                    if (movingobjectposition.sideHit == 5)
                    {
                        i++;
                    }
                    if (world.isAirBlock(i, j, k) || !world.getBlockMaterial(i, j, k).isSolid())
                    {
                        if (world.worldProvider.isHellWorld && isFull == Block.waterStill.blockID)
                        {
                            world.playSoundEffect(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F,
                                                  2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
                            for (int l = 0; l < 8; l++)
                            {
                                world.spawnParticle("largesmoke", i + Math.random(), j + Math.random(),
                                                    k + Math.random(), 0.0D, 0.0D, 0.0D);
                            }
                        }
                        else
                        {
                            world.setBlockAndMetadataWithNotify(i, j, k, isFull, 0);
                        }
                        return(new ItemStack(bucketEmpty));
                    }
                }
            }
            else if (isFull == 0 && (movingobjectposition.entityHit is EntityCow))
            {
                return(new ItemStack(bucketMilk));
            }
            return(itemstack);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }