Ejemplo n.º 1
0
 public override void VelocityToAddToEntity(net.minecraft.src.World world, int i,
                                            int j, int k, net.minecraft.src.Entity entity, net.minecraft.src.Vec3D vec3d)
 {
     net.minecraft.src.Vec3D vec3d1 = Func_298_c(world, i, j, k);
     vec3d.xCoord += vec3d1.xCoord;
     vec3d.yCoord += vec3d1.yCoord;
     vec3d.zCoord += vec3d1.zCoord;
 }
Ejemplo n.º 2
0
        public virtual double SquareDistanceTo(net.minecraft.src.Vec3D vec3d)
        {
            double d  = vec3d.xCoord - xCoord;
            double d1 = vec3d.yCoord - yCoord;
            double d2 = vec3d.zCoord - zCoord;

            return(d * d + d1 * d1 + d2 * d2);
        }
Ejemplo n.º 3
0
        public virtual double DistanceTo(net.minecraft.src.Vec3D vec3d)
        {
            double d  = vec3d.xCoord - xCoord;
            double d1 = vec3d.yCoord - yCoord;
            double d2 = vec3d.zCoord - zCoord;

            return((double)net.minecraft.src.MathHelper.Sqrt_double(d * d + d1 * d1 + d2 * d2
                                                                    ));
        }
Ejemplo n.º 4
0
 private bool IsVecInXZ(net.minecraft.src.Vec3D vec3d)
 {
     if (vec3d == null)
     {
         return(false);
     }
     else
     {
         return(vec3d.xCoord >= minX && vec3d.xCoord <= maxX && vec3d.zCoord >= minZ && vec3d
                .zCoord <= maxZ);
     }
 }
Ejemplo n.º 5
0
 public virtual bool IsVecInXYZ(net.minecraft.src.Vec3D vec3d)
 {
     if (vec3d.xCoord <= minX || vec3d.xCoord >= maxX)
     {
         return(false);
     }
     if (vec3d.yCoord <= minY || vec3d.yCoord >= maxY)
     {
         return(false);
     }
     return(vec3d.zCoord > minZ && vec3d.zCoord < maxZ);
 }
Ejemplo n.º 6
0
 private bool IsVecInsideYZBounds(net.minecraft.src.Vec3D vec3d)
 {
     if (vec3d == null)
     {
         return(false);
     }
     else
     {
         return(vec3d.yCoord >= minY && vec3d.yCoord <= maxY && vec3d.zCoord >= minZ && vec3d
                .zCoord <= maxZ);
     }
 }
Ejemplo n.º 7
0
 private bool IsVecInsideXYBounds(net.minecraft.src.Vec3D vec3d)
 {
     if (vec3d == null)
     {
         return(false);
     }
     else
     {
         return(vec3d.xCoord >= minX && vec3d.xCoord <= maxX && vec3d.yCoord >= minY && vec3d
                .yCoord <= maxY);
     }
 }
Ejemplo n.º 8
0
        public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                                     itemstack, net.minecraft.src.World world, net.minecraft.src.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) *
                       (double)f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)
                         * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;
            double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) *
                        (double)f;

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(d, d1, d2);
            float  f3 = net.minecraft.src.MathHelper.Cos(-f2 * 0.01745329F - 3.141593F);
            float  f4 = net.minecraft.src.MathHelper.Sin(-f2 * 0.01745329F - 3.141593F);
            float  f5 = -net.minecraft.src.MathHelper.Cos(-f1 * 0.01745329F);
            float  f6 = net.minecraft.src.MathHelper.Sin(-f1 * 0.01745329F);
            float  f7 = f4 * f5;
            float  f8 = f6;
            float  f9 = f3 * f5;
            double d3 = 5D;

            net.minecraft.src.Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3
                                                             , (double)f9 * d3);
            net.minecraft.src.MovingObjectPosition movingobjectposition = world.RayTraceBlocks_do
                                                                              (vec3d, vec3d1, true);
            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == net.minecraft.src.EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.blockX;
                int j = movingobjectposition.blockY;
                int k = movingobjectposition.blockZ;
                if (!world.singleplayerWorld)
                {
                    if (world.GetBlockId(i, j, k) == net.minecraft.src.Block.SNOW.ID)
                    {
                        j--;
                    }
                    world.AddEntity(new net.minecraft.src.EntityBoat(world, (float)i + 0.5F,
                                                                     (float)j + 1.0F, (float)k + 0.5F));
                }
                itemstack.stackSize--;
            }
            return(itemstack);
        }
Ejemplo n.º 9
0
 public MovingObjectPosition(int i, int j, int k, int l, net.minecraft.src.Vec3D vec3d
                             )
 {
     // Referenced classes of package net.minecraft.src:
     //            EnumMovingObjectType, Vec3D, Entity
     typeOfHit = net.minecraft.src.EnumMovingObjectType.TILE;
     blockX    = i;
     blockY    = j;
     blockZ    = k;
     sideHit   = l;
     hitVec    = net.minecraft.src.Vec3D.CreateVector(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord
                                                      );
 }
Ejemplo n.º 10
0
 public override bool AttackEntityFrom(net.minecraft.src.Entity entity, int i)
 {
     SetBeenAttacked();
     if (entity != null)
     {
         net.minecraft.src.Vec3D vec3d = entity.GetLookVec();
         if (vec3d != null)
         {
             motionX      = vec3d.xCoord;
             motionY      = vec3d.yCoord;
             motionZ      = vec3d.zCoord;
             field_9199_b = motionX * 0.10000000000000001D;
             field_9198_c = motionY * 0.10000000000000001D;
             field_9196_d = motionZ * 0.10000000000000001D;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 11
0
        public virtual net.minecraft.src.Vec3D GetIntermediateWithZValue(net.minecraft.src.Vec3D
                                                                         vec3d, double d)
        {
            double d1 = vec3d.xCoord - xCoord;
            double d2 = vec3d.yCoord - yCoord;
            double d3 = vec3d.zCoord - zCoord;

            if (d3 * d3 < 1.0000000116860974E-007D)
            {
                return(null);
            }
            double d4 = (d - zCoord) / d3;

            if (d4 < 0.0D || d4 > 1.0D)
            {
                return(null);
            }
            else
            {
                return(CreateVector(xCoord + d1 * d4, yCoord + d2 * d4, zCoord + d3 * d4));
            }
        }
Ejemplo n.º 12
0
        protected internal override void UpdatePlayerActionState()
        {
            if (!worldObj.singleplayerWorld && worldObj.difficultySetting == 0)
            {
                SetEntityDead();
            }
            Func_27013_Q();
            prevAttackCounter = attackCounter;
            double d  = waypointX - posX;
            double d1 = waypointY - posY;
            double d2 = waypointZ - posZ;
            double d3 = net.minecraft.src.MathHelper.Sqrt_double(d * d + d1 * d1 + d2 * d2);

            if (d3 < 1.0D || d3 > 60D)
            {
                waypointX = posX + (double)((rand.NextFloat() * 2.0F - 1.0F) * 16F);
                waypointY = posY + (double)((rand.NextFloat() * 2.0F - 1.0F) * 16F);
                waypointZ = posZ + (double)((rand.NextFloat() * 2.0F - 1.0F) * 16F);
            }
            if (courseChangeCooldown-- <= 0)
            {
                courseChangeCooldown += rand.Next(5) + 2;
                if (IsCourseTraversable(waypointX, waypointY, waypointZ, d3))
                {
                    motionX += (d / d3) * 0.10000000000000001D;
                    motionY += (d1 / d3) * 0.10000000000000001D;
                    motionZ += (d2 / d3) * 0.10000000000000001D;
                }
                else
                {
                    waypointX = posX;
                    waypointY = posY;
                    waypointZ = posZ;
                }
            }
            if (targetedEntity != null && targetedEntity.isDead)
            {
                targetedEntity = null;
            }
            if (targetedEntity == null || aggroCooldown-- <= 0)
            {
                targetedEntity = worldObj.GetClosestPlayerToEntity(this, 100D);
                if (targetedEntity != null)
                {
                    aggroCooldown = 20;
                }
            }
            double d4 = 64D;

            if (targetedEntity != null && targetedEntity.GetDistanceSqToEntity(this) < d4 * d4)
            {
                double d5 = targetedEntity.posX - posX;
                double d6 = (targetedEntity.boundingBox.minY + (double)(targetedEntity.height / 2.0F
                                                                        )) - (posY + (double)(height / 2.0F));
                double d7 = targetedEntity.posZ - posZ;
                renderYawOffset = rotationYaw = (-(float)System.Math.Atan2(d5, d7) * 180F) / 3.141593F;
                if (CanEntityBeSeen(targetedEntity))
                {
                    if (attackCounter == 10)
                    {
                        worldObj.PlaySoundAtEntity(this, "mob.ghast.charge", GetSoundVolume(), (rand.NextFloat
                                                                                                    () - rand.NextFloat()) * 0.2F + 1.0F);
                    }
                    attackCounter++;
                    if (attackCounter == 20)
                    {
                        worldObj.PlaySoundAtEntity(this, "mob.ghast.fireball", GetSoundVolume(), (rand.NextFloat
                                                                                                      () - rand.NextFloat()) * 0.2F + 1.0F);
                        net.minecraft.src.EntityFireball entityfireball = new net.minecraft.src.EntityFireball
                                                                              (worldObj, this, d5, d6, d7);
                        double d8 = 4D;
                        net.minecraft.src.Vec3D vec3d = GetLook(1.0F);
                        entityfireball.posX = posX + vec3d.xCoord * d8;
                        entityfireball.posY = posY + (double)(height / 2.0F) + 0.5D;
                        entityfireball.posZ = posZ + vec3d.zCoord * d8;
                        worldObj.AddEntity(entityfireball);
                        attackCounter = -40;
                    }
                }
                else
                {
                    if (attackCounter > 0)
                    {
                        attackCounter--;
                    }
                }
            }
            else
            {
                renderYawOffset = rotationYaw = (-(float)System.Math.Atan2(motionX, motionZ) * 180F
                                                 ) / 3.141593F;
                if (attackCounter > 0)
                {
                    attackCounter--;
                }
            }
            if (!worldObj.singleplayerWorld)
            {
                byte byte0 = dataWatcher.GetWatchableObjectByte(16);
                byte byte1 = unchecked ((byte)(attackCounter <= 10 ? 0 : 1));
                if (byte0 != byte1)
                {
                    dataWatcher.UpdateObject(16, byte1);
                }
            }
        }
Ejemplo n.º 13
0
        public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                                     itemstack, net.minecraft.src.World world, net.minecraft.src.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) *
                       (double)f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)
                         * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;
            double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) *
                        (double)f;

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(d, d1, d2);
            float  f3 = net.minecraft.src.MathHelper.Cos(-f2 * 0.01745329F - 3.141593F);
            float  f4 = net.minecraft.src.MathHelper.Sin(-f2 * 0.01745329F - 3.141593F);
            float  f5 = -net.minecraft.src.MathHelper.Cos(-f1 * 0.01745329F);
            float  f6 = net.minecraft.src.MathHelper.Sin(-f1 * 0.01745329F);
            float  f7 = f4 * f5;
            float  f8 = f6;
            float  f9 = f3 * f5;
            double d3 = 5D;

            net.minecraft.src.Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3
                                                             , (double)f9 * d3);
            net.minecraft.src.MovingObjectPosition movingobjectposition = world.RayTraceBlocks_do
                                                                              (vec3d, vec3d1, isFull == 0);
            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == net.minecraft.src.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) == net.minecraft.src.Material.water && world.
                        GetBlockMetadata(i, j, k) == 0)
                    {
                        world.SetBlockWithNotify(i, j, k, 0);
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.WATER_BUCKET));
                    }
                    if (world.GetBlockMaterial(i, j, k) == net.minecraft.src.Material.lava && world.GetBlockMetadata
                            (i, j, k) == 0)
                    {
                        world.SetBlockWithNotify(i, j, k, 0);
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.LAVA_BUCKET));
                    }
                }
                else
                {
                    if (isFull < 0)
                    {
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.BUCKET));
                    }
                    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 == net.minecraft.src.Block.WATER
                            .ID)
                        {
                            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", (double)i + SharpRandom.NextDouble(), (double)j + SharpRandom.NextDouble(), (double)k + SharpRandom.NextDouble(), 0.0D, 0.0D, 0.0D);
                            }
                        }
                        else
                        {
                            world.SetBlockAndMetadataWithNotify(i, j, k, isFull, 0);
                        }
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.BUCKET));
                    }
                }
            }
            else
            {
                if (isFull == 0 && (movingobjectposition.entityHit is net.minecraft.src.EntityCow
                                    ))
                {
                    return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.MILK_BUCKET));
                }
            }
            return(itemstack);
        }
Ejemplo n.º 14
0
        public virtual net.minecraft.src.MovingObjectPosition CollisionRayTrace(net.minecraft.src.World
                                                                                world, int i, int j, int k, net.minecraft.src.Vec3D vec3d, net.minecraft.src.Vec3D
                                                                                vec3d1)
        {
            SetBlockBoundsBasedOnState(world, i, j, k);
            vec3d  = vec3d.AddVector(-i, -j, -k);
            vec3d1 = vec3d1.AddVector(-i, -j, -k);
            net.minecraft.src.Vec3D vec3d2 = vec3d.GetIntermediateWithXValue(vec3d1, minX);
            net.minecraft.src.Vec3D vec3d3 = vec3d.GetIntermediateWithXValue(vec3d1, maxX);
            net.minecraft.src.Vec3D vec3d4 = vec3d.GetIntermediateWithYValue(vec3d1, minY);
            net.minecraft.src.Vec3D vec3d5 = vec3d.GetIntermediateWithYValue(vec3d1, maxY);
            net.minecraft.src.Vec3D vec3d6 = vec3d.GetIntermediateWithZValue(vec3d1, minZ);
            net.minecraft.src.Vec3D vec3d7 = vec3d.GetIntermediateWithZValue(vec3d1, maxZ);
            if (!IsVecInsideYZBounds(vec3d2))
            {
                vec3d2 = null;
            }
            if (!IsVecInsideYZBounds(vec3d3))
            {
                vec3d3 = null;
            }
            if (!IsVecInsideXZBounds(vec3d4))
            {
                vec3d4 = null;
            }
            if (!IsVecInsideXZBounds(vec3d5))
            {
                vec3d5 = null;
            }
            if (!IsVecInsideXYBounds(vec3d6))
            {
                vec3d6 = null;
            }
            if (!IsVecInsideXYBounds(vec3d7))
            {
                vec3d7 = null;
            }
            net.minecraft.src.Vec3D vec3d8 = null;
            if (vec3d2 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d2) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d2;
            }
            if (vec3d3 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d3) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d3;
            }
            if (vec3d4 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d4) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d4;
            }
            if (vec3d5 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d5) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d5;
            }
            if (vec3d6 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d6) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d6;
            }
            if (vec3d7 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d7) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d7;
            }
            if (vec3d8 == null)
            {
                return(null);
            }
            byte byte0 = unchecked ((byte)(-1));

            if (vec3d8 == vec3d2)
            {
                byte0 = 4;
            }
            if (vec3d8 == vec3d3)
            {
                byte0 = 5;
            }
            if (vec3d8 == vec3d4)
            {
                byte0 = 0;
            }
            if (vec3d8 == vec3d5)
            {
                byte0 = 1;
            }
            if (vec3d8 == vec3d6)
            {
                byte0 = 2;
            }
            if (vec3d8 == vec3d7)
            {
                byte0 = 3;
            }
            return(new net.minecraft.src.MovingObjectPosition(i, j, k, byte0, vec3d8.AddVector
                                                                  (i, j, k)));
        }
Ejemplo n.º 15
0
        public override void OnUpdate()
        {
            if (field_9167_b > 0)
            {
                field_9167_b--;
            }
            if (damageTaken > 0)
            {
                damageTaken--;
            }
            if (worldObj.singleplayerWorld && field_9163_an > 0)
            {
                if (field_9163_an > 0)
                {
                    double d  = posX + (field_9162_ao - posX) / (double)field_9163_an;
                    double d1 = posY + (field_9161_ap - posY) / (double)field_9163_an;
                    double d3 = posZ + (field_9160_aq - posZ) / (double)field_9163_an;
                    double d4;
                    for (d4 = field_9159_ar - (double)rotationYaw; d4 < -180D; d4 += 360D)
                    {
                    }
                    for (; d4 >= 180D; d4 -= 360D)
                    {
                    }
                    rotationYaw   += (float)(d4 / (double)field_9163_an);
                    rotationPitch += (float)((field_9158_as - (double)rotationPitch) / (double)field_9163_an);
                    field_9163_an--;
                    SetPosition(d, d1, d3);
                    SetRotation(rotationYaw, rotationPitch);
                }
                else
                {
                    SetPosition(posX, posY, posZ);
                    SetRotation(rotationYaw, rotationPitch);
                }
                return;
            }
            prevPosX = posX;
            prevPosY = posY;
            prevPosZ = posZ;
            motionY -= 0.039999999105930328D;
            int i = net.minecraft.src.MathHelper.Floor_double(posX);
            int j = net.minecraft.src.MathHelper.Floor_double(posY);
            int k = net.minecraft.src.MathHelper.Floor_double(posZ);

            if (net.minecraft.src.BlockRail.Func_27029_g(worldObj, i, j - 1, k))
            {
                j--;
            }
            double d2   = 0.40000000000000002D;
            bool   flag = false;
            double d5   = 0.0078125D;
            int    l    = worldObj.GetBlockId(i, j, k);

            if (net.minecraft.src.BlockRail.Func_27030_c(l))
            {
                net.minecraft.src.Vec3D vec3d = Func_182_g(posX, posY, posZ);
                int i1 = worldObj.GetBlockMetadata(i, j, k);
                posY = j;
                bool flag1 = false;
                bool flag2 = false;
                if (l == net.minecraft.src.Block.GOLDEN_RAIL.ID)
                {
                    flag1 = (i1 & 8) != 0;
                    flag2 = !flag1;
                }
                if (((net.minecraft.src.BlockRail)net.minecraft.src.Block.blocksList[l]).Func_27028_d
                        ())
                {
                    i1 &= 7;
                }
                if (i1 >= 2 && i1 <= 5)
                {
                    posY = j + 1;
                }
                if (i1 == 2)
                {
                    motionX -= d5;
                }
                if (i1 == 3)
                {
                    motionX += d5;
                }
                if (i1 == 4)
                {
                    motionZ += d5;
                }
                if (i1 == 5)
                {
                    motionZ -= d5;
                }
                int[][] ai  = field_468_ak[i1];
                double  d9  = ai[1][0] - ai[0][0];
                double  d10 = ai[1][2] - ai[0][2];
                double  d11 = System.Math.Sqrt(d9 * d9 + d10 * d10);
                double  d12 = motionX * d9 + motionZ * d10;
                if (d12 < 0.0D)
                {
                    d9  = -d9;
                    d10 = -d10;
                }
                double d13 = System.Math.Sqrt(motionX * motionX + motionZ * motionZ);
                motionX = (d13 * d9) / d11;
                motionZ = (d13 * d10) / d11;
                if (flag2)
                {
                    double d16 = System.Math.Sqrt(motionX * motionX + motionZ * motionZ);
                    if (d16 < 0.029999999999999999D)
                    {
                        motionX *= 0.0D;
                        motionY *= 0.0D;
                        motionZ *= 0.0D;
                    }
                    else
                    {
                        motionX *= 0.5D;
                        motionY *= 0.0D;
                        motionZ *= 0.5D;
                    }
                }
                double d17 = 0.0D;
                double d18 = (double)i + 0.5D + (double)ai[0][0] * 0.5D;
                double d19 = (double)k + 0.5D + (double)ai[0][2] * 0.5D;
                double d20 = (double)i + 0.5D + (double)ai[1][0] * 0.5D;
                double d21 = (double)k + 0.5D + (double)ai[1][2] * 0.5D;
                d9  = d20 - d18;
                d10 = d21 - d19;
                if (d9 == 0.0D)
                {
                    posX = (double)i + 0.5D;
                    d17  = posZ - (double)k;
                }
                else
                {
                    if (d10 == 0.0D)
                    {
                        posZ = (double)k + 0.5D;
                        d17  = posX - (double)i;
                    }
                    else
                    {
                        double d22 = posX - d18;
                        double d24 = posZ - d19;
                        double d26 = (d22 * d9 + d24 * d10) * 2D;
                        d17 = d26;
                    }
                }
                posX = d18 + d9 * d17;
                posZ = d19 + d10 * d17;
                SetPosition(posX, posY + (double)yOffset, posZ);
                double d23 = motionX;
                double d25 = motionZ;
                if (riddenByEntity != null)
                {
                    d23 *= 0.75D;
                    d25 *= 0.75D;
                }
                if (d23 < -d2)
                {
                    d23 = -d2;
                }
                if (d23 > d2)
                {
                    d23 = d2;
                }
                if (d25 < -d2)
                {
                    d25 = -d2;
                }
                if (d25 > d2)
                {
                    d25 = d2;
                }
                MoveEntity(d23, 0.0D, d25);
                if (ai[0][1] != 0 && net.minecraft.src.MathHelper.Floor_double(posX) - i == ai[0]
                    [0] && net.minecraft.src.MathHelper.Floor_double(posZ) - k == ai[0][2])
                {
                    SetPosition(posX, posY + (double)ai[0][1], posZ);
                }
                else
                {
                    if (ai[1][1] != 0 && net.minecraft.src.MathHelper.Floor_double(posX) - i == ai[1]
                        [0] && net.minecraft.src.MathHelper.Floor_double(posZ) - k == ai[1][2])
                    {
                        SetPosition(posX, posY + (double)ai[1][1], posZ);
                    }
                }
                if (riddenByEntity != null)
                {
                    motionX *= 0.99699997901916504D;
                    motionY *= 0.0D;
                    motionZ *= 0.99699997901916504D;
                }
                else
                {
                    if (minecartType == 2)
                    {
                        double d27 = net.minecraft.src.MathHelper.Sqrt_double(pushX * pushX + pushZ * pushZ
                                                                              );
                        if (d27 > 0.01D)
                        {
                            flag   = true;
                            pushX /= d27;
                            pushZ /= d27;
                            double d29 = 0.040000000000000001D;
                            motionX *= 0.80000001192092896D;
                            motionY *= 0.0D;
                            motionZ *= 0.80000001192092896D;
                            motionX += pushX * d29;
                            motionZ += pushZ * d29;
                        }
                        else
                        {
                            motionX *= 0.89999997615814209D;
                            motionY *= 0.0D;
                            motionZ *= 0.89999997615814209D;
                        }
                    }
                    motionX *= 0.95999997854232788D;
                    motionY *= 0.0D;
                    motionZ *= 0.95999997854232788D;
                }
                net.minecraft.src.Vec3D vec3d1 = Func_182_g(posX, posY, posZ);
                if (vec3d1 != null && vec3d != null)
                {
                    double d28 = (vec3d.yCoord - vec3d1.yCoord) * 0.050000000000000003D;
                    double d14 = System.Math.Sqrt(motionX * motionX + motionZ * motionZ);
                    if (d14 > 0.0D)
                    {
                        motionX = (motionX / d14) * (d14 + d28);
                        motionZ = (motionZ / d14) * (d14 + d28);
                    }
                    SetPosition(posX, vec3d1.yCoord, posZ);
                }
                int k1 = net.minecraft.src.MathHelper.Floor_double(posX);
                int l1 = net.minecraft.src.MathHelper.Floor_double(posZ);
                if (k1 != i || l1 != k)
                {
                    double d15 = System.Math.Sqrt(motionX * motionX + motionZ * motionZ);
                    motionX = d15 * (double)(k1 - i);
                    motionZ = d15 * (double)(l1 - k);
                }
                if (minecartType == 2)
                {
                    double d30 = net.minecraft.src.MathHelper.Sqrt_double(pushX * pushX + pushZ * pushZ
                                                                          );
                    if (d30 > 0.01D && motionX * motionX + motionZ * motionZ > 0.001D)
                    {
                        pushX /= d30;
                        pushZ /= d30;
                        if (pushX * motionX + pushZ * motionZ < 0.0D)
                        {
                            pushX = 0.0D;
                            pushZ = 0.0D;
                        }
                        else
                        {
                            pushX = motionX;
                            pushZ = motionZ;
                        }
                    }
                }
                if (flag1)
                {
                    double d31 = System.Math.Sqrt(motionX * motionX + motionZ * motionZ);
                    if (d31 > 0.01D)
                    {
                        double d32 = 0.059999999999999998D;
                        motionX += (motionX / d31) * d32;
                        motionZ += (motionZ / d31) * d32;
                    }
                    else
                    {
                        if (i1 == 1)
                        {
                            if (worldObj.IsBlockNormalCube(i - 1, j, k))
                            {
                                motionX = 0.02D;
                            }
                            else
                            {
                                if (worldObj.IsBlockNormalCube(i + 1, j, k))
                                {
                                    motionX = -0.02D;
                                }
                            }
                        }
                        else
                        {
                            if (i1 == 0)
                            {
                                if (worldObj.IsBlockNormalCube(i, j, k - 1))
                                {
                                    motionZ = 0.02D;
                                }
                                else
                                {
                                    if (worldObj.IsBlockNormalCube(i, j, k + 1))
                                    {
                                        motionZ = -0.02D;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (motionX < -d2)
                {
                    motionX = -d2;
                }
                if (motionX > d2)
                {
                    motionX = d2;
                }
                if (motionZ < -d2)
                {
                    motionZ = -d2;
                }
                if (motionZ > d2)
                {
                    motionZ = d2;
                }
                if (onGround)
                {
                    motionX *= 0.5D;
                    motionY *= 0.5D;
                    motionZ *= 0.5D;
                }
                MoveEntity(motionX, motionY, motionZ);
                if (!onGround)
                {
                    motionX *= 0.94999998807907104D;
                    motionY *= 0.94999998807907104D;
                    motionZ *= 0.94999998807907104D;
                }
            }
            rotationPitch = 0.0F;
            double d6 = prevPosX - posX;
            double d7 = prevPosZ - posZ;

            if (d6 * d6 + d7 * d7 > 0.001D)
            {
                rotationYaw = (float)((System.Math.Atan2(d7, d6) * 180D) / 3.1415926535897931D);
                if (field_469_aj)
                {
                    rotationYaw += 180F;
                }
            }
            double d8;

            for (d8 = rotationYaw - prevRotationYaw; d8 >= 180D; d8 -= 360D)
            {
            }
            for (; d8 < -180D; d8 += 360D)
            {
            }
            if (d8 < -170D || d8 >= 170D)
            {
                rotationYaw += 180F;
                field_469_aj = !field_469_aj;
            }
            SetRotation(rotationYaw, rotationPitch);
            System.Collections.Generic.List <Entity> list = worldObj.GetEntitiesWithinAABBExcludingEntity(this
                                                                                                          , boundingBox.Expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
            if (list != null && list.Count > 0)
            {
                for (int j1 = 0; j1 < list.Count; j1++)
                {
                    net.minecraft.src.Entity entity = (net.minecraft.src.Entity)list[j1];
                    if (entity != riddenByEntity && entity.CanBePushed() && (entity is net.minecraft.src.EntityMinecart
                                                                             ))
                    {
                        entity.ApplyEntityCollision(this);
                    }
                }
            }
            if (riddenByEntity != null && riddenByEntity.isDead)
            {
                riddenByEntity = null;
            }
            if (flag && rand.Next(4) == 0)
            {
                fuel--;
                if (fuel < 0)
                {
                    pushX = pushZ = 0.0D;
                }
                worldObj.SpawnParticle("largesmoke", posX, posY + 0.80000000000000004D, posZ, 0.0D
                                       , 0.0D, 0.0D);
            }
        }
Ejemplo n.º 16
0
        protected internal override void UpdatePlayerActionState()
        {
            hasAttacked = Func_25026_u();
            float f = 16F;

            if (playerToAttack == null)
            {
                playerToAttack = FindPlayerToAttack();
                if (playerToAttack != null)
                {
                    pathToEntity = worldObj.GetPathToEntity(this, playerToAttack, f);
                }
            }
            else
            {
                if (!playerToAttack.IsEntityAlive())
                {
                    playerToAttack = null;
                }
                else
                {
                    float f1 = playerToAttack.GetDistanceToEntity(this);
                    if (CanEntityBeSeen(playerToAttack))
                    {
                        AttackEntity(playerToAttack, f1);
                    }
                    else
                    {
                        Func_28013_b(playerToAttack, f1);
                    }
                }
            }
            if (!hasAttacked && playerToAttack != null && (pathToEntity == null || rand.NextInt
                                                               (20) == 0))
            {
                pathToEntity = worldObj.GetPathToEntity(this, playerToAttack, f);
            }
            else
            {
                if (!hasAttacked && (pathToEntity == null && rand.Next(80) == 0 || rand.NextInt
                                         (80) == 0))
                {
                    Func_31021_B();
                }
            }
            int  i     = net.minecraft.src.MathHelper.Floor_double(boundingBox.minY + 0.5D);
            bool flag  = IsInWater();
            bool flag1 = HandleLavaMovement();

            rotationPitch = 0.0F;
            if (pathToEntity == null || rand.Next(100) == 0)
            {
                base.UpdatePlayerActionState();
                pathToEntity = null;
                return;
            }
            net.minecraft.src.Vec3D vec3d = pathToEntity.GetPosition(this);
            for (double d = width * 2.0F; vec3d != null && vec3d.SquareDistanceTo(posX, vec3d
                                                                                  .yCoord, posZ) < d * d;)
            {
                pathToEntity.IncrementPathIndex();
                if (pathToEntity.IsFinished())
                {
                    vec3d        = null;
                    pathToEntity = null;
                }
                else
                {
                    vec3d = pathToEntity.GetPosition(this);
                }
            }
            isJumping = false;
            if (vec3d != null)
            {
                double d1 = vec3d.xCoord - posX;
                double d2 = vec3d.zCoord - posZ;
                double d3 = vec3d.yCoord - (double)i;
                float  f2 = (float)((System.Math.Atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F;
                float  f3 = f2 - rotationYaw;
                moveForward = moveSpeed;
                for (; f3 < -180F; f3 += 360F)
                {
                }
                for (; f3 >= 180F; f3 -= 360F)
                {
                }
                if (f3 > 30F)
                {
                    f3 = 30F;
                }
                if (f3 < -30F)
                {
                    f3 = -30F;
                }
                rotationYaw += f3;
                if (hasAttacked && playerToAttack != null)
                {
                    double d4 = playerToAttack.posX - posX;
                    double d5 = playerToAttack.posZ - posZ;
                    float  f5 = rotationYaw;
                    rotationYaw = (float)((System.Math.Atan2(d5, d4) * 180D) / 3.1415927410125732D) -
                                  90F;
                    float f4 = (((f5 - rotationYaw) + 90F) * 3.141593F) / 180F;
                    moveStrafing = -net.minecraft.src.MathHelper.Sin(f4) * moveForward * 1.0F;
                    moveForward  = net.minecraft.src.MathHelper.Cos(f4) * moveForward * 1.0F;
                }
                if (d3 > 0.0D)
                {
                    isJumping = true;
                }
            }
            if (playerToAttack != null)
            {
                FaceEntity(playerToAttack, 30F, 30F);
            }
            if (isCollidedHorizontally && !GetGotPath())
            {
                isJumping = true;
            }
            if (rand.NextFloat() < 0.8F && (flag || flag1))
            {
                isJumping = true;
            }
        }
Ejemplo n.º 17
0
        public override net.minecraft.src.MovingObjectPosition CollisionRayTrace(net.minecraft.src.World
                                                                                 world, int i, int j, int k, net.minecraft.src.Vec3D vec3d, net.minecraft.src.Vec3D
                                                                                 vec3d1)
        {
            int   l = world.GetBlockMetadata(i, j, k) & 7;
            float f = 0.15F;

            if (l == 1)
            {
                SetBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
            }
            else
            {
                if (l == 2)
                {
                    SetBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
                }
                else
                {
                    if (l == 3)
                    {
                        SetBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
                    }
                    else
                    {
                        if (l == 4)
                        {
                            SetBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
                        }
                        else
                        {
                            float f1 = 0.1F;
                            SetBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
                        }
                    }
                }
            }
            return(base.CollisionRayTrace(world, i, j, k, vec3d, vec3d1));
        }
Ejemplo n.º 18
0
        public virtual net.minecraft.src.MovingObjectPosition Func_706_a(net.minecraft.src.Vec3D
                                                                         vec3d, net.minecraft.src.Vec3D vec3d1)
        {
            net.minecraft.src.Vec3D vec3d2 = vec3d.GetIntermediateWithXValue(vec3d1, minX);
            net.minecraft.src.Vec3D vec3d3 = vec3d.GetIntermediateWithXValue(vec3d1, maxX);
            net.minecraft.src.Vec3D vec3d4 = vec3d.GetIntermediateWithYValue(vec3d1, minY);
            net.minecraft.src.Vec3D vec3d5 = vec3d.GetIntermediateWithYValue(vec3d1, maxY);
            net.minecraft.src.Vec3D vec3d6 = vec3d.GetIntermediateWithZValue(vec3d1, minZ);
            net.minecraft.src.Vec3D vec3d7 = vec3d.GetIntermediateWithZValue(vec3d1, maxZ);
            if (!IsVecInYZ(vec3d2))
            {
                vec3d2 = null;
            }
            if (!IsVecInYZ(vec3d3))
            {
                vec3d3 = null;
            }
            if (!IsVecInXZ(vec3d4))
            {
                vec3d4 = null;
            }
            if (!IsVecInXZ(vec3d5))
            {
                vec3d5 = null;
            }
            if (!IsVecInXY(vec3d6))
            {
                vec3d6 = null;
            }
            if (!IsVecInXY(vec3d7))
            {
                vec3d7 = null;
            }
            net.minecraft.src.Vec3D vec3d8 = null;
            if (vec3d2 != null && (vec3d8 == null || vec3d.SquareDistanceTo(vec3d2) < vec3d.SquareDistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d2;
            }
            if (vec3d3 != null && (vec3d8 == null || vec3d.SquareDistanceTo(vec3d3) < vec3d.SquareDistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d3;
            }
            if (vec3d4 != null && (vec3d8 == null || vec3d.SquareDistanceTo(vec3d4) < vec3d.SquareDistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d4;
            }
            if (vec3d5 != null && (vec3d8 == null || vec3d.SquareDistanceTo(vec3d5) < vec3d.SquareDistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d5;
            }
            if (vec3d6 != null && (vec3d8 == null || vec3d.SquareDistanceTo(vec3d6) < vec3d.SquareDistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d6;
            }
            if (vec3d7 != null && (vec3d8 == null || vec3d.SquareDistanceTo(vec3d7) < vec3d.SquareDistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d7;
            }
            if (vec3d8 == null)
            {
                return(null);
            }
            byte byte0 = unchecked ((byte)(-1));

            if (vec3d8 == vec3d2)
            {
                byte0 = 4;
            }
            if (vec3d8 == vec3d3)
            {
                byte0 = 5;
            }
            if (vec3d8 == vec3d4)
            {
                byte0 = 0;
            }
            if (vec3d8 == vec3d5)
            {
                byte0 = 1;
            }
            if (vec3d8 == vec3d6)
            {
                byte0 = 2;
            }
            if (vec3d8 == vec3d7)
            {
                byte0 = 3;
            }
            return(new net.minecraft.src.MovingObjectPosition(0, 0, 0, byte0, vec3d8));
        }
Ejemplo n.º 19
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++;
            }
            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY,
                                                                                 posZ);
            net.minecraft.src.Vec3D vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX
                                                                                  , posY + motionY, posZ + motionZ);
            net.minecraft.src.MovingObjectPosition movingobjectposition = worldObj.RayTraceBlocks
                                                                              (vec3d, vec3d1);
            vec3d  = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ);
            vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX, posY + motionY, posZ
                                                          + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = net.minecraft.src.Vec3D.CreateVector(movingobjectposition.hitVec.xCoord,
                                                              movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
            }
            if (!worldObj.singleplayerWorld)
            {
                net.minecraft.src.Entity entity = null;
                System.Collections.Generic.List <Entity> 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.Count; l++)
                {
                    net.minecraft.src.Entity entity1 = (net.minecraft.src.Entity)list[l];
                    if (!entity1.CanBeCollidedWith() || entity1 == owner && ticksInAir < 5)
                    {
                        continue;
                    }
                    float f4 = 0.3F;
                    net.minecraft.src.AxisAlignedBB axisalignedbb = entity1.boundingBox.Expand(f4, f4
                                                                                               , f4);
                    net.minecraft.src.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 net.minecraft.src.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 = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ *
                                                               motionZ);

            rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D) / 3.1415927410125732D
                                  );
            for (rotationPitch = (float)((System.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 (IsInWater())
            {
                for (int k = 0; k < 4; k++)
                {
                    float f3 = 0.25F;
                    worldObj.SpawnParticle("bubble", posX - motionX * (double)f3, posY - motionY * (double
                                                                                                    )f3, posZ - motionZ * (double)f3, motionX, motionY, motionZ);
                }
                f1 = 0.8F;
            }
            motionX *= f1;
            motionY *= f1;
            motionZ *= f1;
            motionY -= f2;
            SetPosition(posX, posY, posZ);
        }
Ejemplo n.º 20
0
        private net.minecraft.src.Vec3D Func_298_c(net.minecraft.src.IBlockAccess iblockaccess
                                                   , int i, int j, int k)
        {
            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(0.0D, 0.0D,
                                                                                 0.0D);
            int l = Func_303_b(iblockaccess, i, j, k);

            for (int i1 = 0; i1 < 4; i1++)
            {
                int j1 = i;
                int k1 = j;
                int l1 = k;
                if (i1 == 0)
                {
                    j1--;
                }
                if (i1 == 1)
                {
                    l1--;
                }
                if (i1 == 2)
                {
                    j1++;
                }
                if (i1 == 3)
                {
                    l1++;
                }
                int i2 = Func_303_b(iblockaccess, j1, k1, l1);
                if (i2 < 0)
                {
                    if (iblockaccess.GetBlockMaterial(j1, k1, l1).GetIsSolid())
                    {
                        continue;
                    }
                    i2 = Func_303_b(iblockaccess, j1, k1 - 1, l1);
                    if (i2 >= 0)
                    {
                        int j2 = i2 - (l - 8);
                        vec3d = vec3d.AddVector((j1 - i) * j2, (k1 - j) * j2, (l1 - k) * j2);
                    }
                    continue;
                }
                if (i2 >= 0)
                {
                    int k2 = i2 - l;
                    vec3d = vec3d.AddVector((j1 - i) * k2, (k1 - j) * k2, (l1 - k) * k2);
                }
            }
            if (iblockaccess.GetBlockMetadata(i, j, k) >= 8)
            {
                bool flag = false;
                if (flag || ShouldSideBeRendered(iblockaccess, i, j, k - 1, 2))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i, j, k + 1, 3))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i - 1, j, k, 4))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i + 1, j, k, 5))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i, j + 1, k - 1, 2))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i, j + 1, k + 1, 3))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i - 1, j + 1, k, 4))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i + 1, j + 1, k, 5))
                {
                    flag = true;
                }
                if (flag)
                {
                    vec3d = vec3d.Normalize().AddVector(0.0D, -6D, 0.0D);
                }
            }
            vec3d = vec3d.Normalize();
            return(vec3d);
        }
Ejemplo n.º 21
0
 public virtual void VelocityToAddToEntity(net.minecraft.src.World world, int i, int
                                           j, int k, net.minecraft.src.Entity entity, net.minecraft.src.Vec3D vec3d)
 {
 }
Ejemplo n.º 22
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
            {
                float f = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ *
                                                                   motionZ);
                prevRotationYaw = rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D
                                                         ) / 3.1415927410125732D);
                prevRotationPitch = rotationPitch = (float)((System.Math.Atan2(motionY, f) * 180D
                                                             ) / 3.1415927410125732D);
            }
            int i = worldObj.GetBlockId(xTile, yTile, zTile);

            if (i > 0)
            {
                net.minecraft.src.Block.blocksList[i].SetBlockBoundsBasedOnState(worldObj, xTile,
                                                                                 yTile, zTile);
                net.minecraft.src.AxisAlignedBB axisalignedbb = net.minecraft.src.Block.blocksList
                                                                [i].GetCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
                if (axisalignedbb != null && axisalignedbb.IsVecInXYZ(net.minecraft.src.Vec3D.CreateVector
                                                                          (posX, posY, posZ)))
                {
                    inGround = true;
                }
            }
            if (arrowShake > 0)
            {
                arrowShake--;
            }
            if (inGround)
            {
                int j = worldObj.GetBlockId(xTile, yTile, zTile);
                int k = worldObj.GetBlockMetadata(xTile, yTile, zTile);
                if (j != inTile || k != field_28011_h)
                {
                    inGround      = false;
                    motionX      *= rand.NextFloat() * 0.2F;
                    motionY      *= rand.NextFloat() * 0.2F;
                    motionZ      *= rand.NextFloat() * 0.2F;
                    ticksInGround = 0;
                    ticksInAir    = 0;
                    return;
                }
                ticksInGround++;
                if (ticksInGround == 1200)
                {
                    SetEntityDead();
                }
                return;
            }
            ticksInAir++;
            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY,
                                                                                 posZ);
            net.minecraft.src.Vec3D vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX
                                                                                  , posY + motionY, posZ + motionZ);
            net.minecraft.src.MovingObjectPosition movingobjectposition = worldObj.Func_28099_a
                                                                              (vec3d, vec3d1, false, true);
            vec3d  = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ);
            vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX, posY + motionY, posZ
                                                          + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = net.minecraft.src.Vec3D.CreateVector(movingobjectposition.hitVec.xCoord,
                                                              movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
            }
            net.minecraft.src.Entity entity = null;
            List <Entity>            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.Count; l++)
            {
                net.minecraft.src.Entity entity1 = (net.minecraft.src.Entity)list[l];
                if (!entity1.CanBeCollidedWith() || entity1 == owner && ticksInAir < 5)
                {
                    continue;
                }
                float f4 = 0.3F;
                net.minecraft.src.AxisAlignedBB axisalignedbb1 = entity1.boundingBox.Expand(f4, f4
                                                                                            , f4);
                net.minecraft.src.MovingObjectPosition movingobjectposition1 = axisalignedbb1.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 net.minecraft.src.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);
                    field_28011_h = worldObj.GetBlockMetadata(xTile, yTile, zTile);
                    motionX       = (float)(movingobjectposition.hitVec.xCoord - posX);
                    motionY       = (float)(movingobjectposition.hitVec.yCoord - posY);
                    motionZ       = (float)(movingobjectposition.hitVec.zCoord - posZ);
                    float f1 = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionY *
                                                                        motionY + motionZ * motionZ);
                    posX -= (motionX / (double)f1) * 0.05000000074505806D;
                    posY -= (motionY / (double)f1) * 0.05000000074505806D;
                    posZ -= (motionZ / (double)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 = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ *
                                                                motionZ);

            rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D) / 3.1415927410125732D
                                  );
            for (rotationPitch = (float)((System.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 (IsInWater())
            {
                for (int i1 = 0; i1 < 4; i1++)
                {
                    float f6 = 0.25F;
                    worldObj.SpawnParticle("bubble", posX - motionX * (double)f6, posY - motionY * (double
                                                                                                    )f6, posZ - motionZ * (double)f6, motionX, motionY, motionZ);
                }
                f3 = 0.8F;
            }
            motionX *= f3;
            motionY *= f3;
            motionZ *= f3;
            motionY -= f5;
            SetPosition(posX, posY, posZ);
        }
Ejemplo n.º 23
0
        public virtual void DoExplosion()
        {
            float f = explosionSize;
            int   i = 16;

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

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

            arraylist.AddRange(destroyedBlockPositions);
            if (isFlaming)
            {
                for (int l2 = arraylist.Count - 1; l2 >= 0; l2--)
                {
                    net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                                    arraylist[l2];
                    int i3 = chunkposition.x;
                    int j3 = chunkposition.y;
                    int k3 = chunkposition.z;
                    int l3 = worldObj.GetBlockId(i3, j3, k3);
                    int i4 = worldObj.GetBlockId(i3, j3 - 1, k3);
                    if (l3 == 0 && net.minecraft.src.Block.opaqueCubeLookup[i4] && ExplosionRNG.NextInt
                            (3) == 0)
                    {
                        worldObj.SetBlockWithNotify(i3, j3, k3, net.minecraft.src.Block.FIRE.ID);
                    }
                }
            }
        }
Ejemplo n.º 24
0
 public override void VelocityToAddToEntity(net.minecraft.src.World world, int i,
                                            int j, int k, net.minecraft.src.Entity entity, net.minecraft.src.Vec3D vec3d)
 {
     modelBlock.VelocityToAddToEntity(world, i, j, k, entity, vec3d);
 }
Ejemplo n.º 25
0
 public override net.minecraft.src.MovingObjectPosition CollisionRayTrace(net.minecraft.src.World
                                                                          world, int i, int j, int k, net.minecraft.src.Vec3D vec3d, net.minecraft.src.Vec3D
                                                                          vec3d1)
 {
     SetBlockBoundsBasedOnState(world, i, j, k);
     return(base.CollisionRayTrace(world, i, j, k, vec3d, vec3d1));
 }
Ejemplo n.º 26
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (field_6149_an > 0)
            {
                double d  = posX + (field_6148_ao - posX) / (double)field_6149_an;
                double d1 = posY + (field_6147_ap - posY) / (double)field_6149_an;
                double d2 = posZ + (field_6146_aq - posZ) / (double)field_6149_an;
                double d4;
                for (d4 = field_6145_ar - (double)rotationYaw; d4 < -180D; d4 += 360D)
                {
                }
                for (; d4 >= 180D; d4 -= 360D)
                {
                }
                rotationYaw   += (float)(d4 / (double)field_6149_an);
                rotationPitch += (float)((field_6144_as - (double)rotationPitch) / (double)field_6149_an);
                field_6149_an--;
                SetPosition(d, d1, d2);
                SetRotation(rotationYaw, rotationPitch);
                return;
            }
            if (!worldObj.singleplayerWorld)
            {
                net.minecraft.src.ItemStack itemstack = angler.GetCurrentEquippedItem();
                if (angler.isDead || !angler.IsEntityAlive() || itemstack == null || itemstack.GetItem
                        () != net.minecraft.src.Item.FISHING_ROD || GetDistanceSqToEntity(angler) > 1024D)
                {
                    SetEntityDead();
                    angler.fishEntity = null;
                    return;
                }
                if (bobber != null)
                {
                    if (bobber.isDead)
                    {
                        bobber = null;
                    }
                    else
                    {
                        posX = bobber.posX;
                        posY = bobber.boundingBox.minY + (double)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++;
            }
            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(posX, posY,
                                                                                 posZ);
            net.minecraft.src.Vec3D vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX
                                                                                  , posY + motionY, posZ + motionZ);
            net.minecraft.src.MovingObjectPosition movingobjectposition = worldObj.RayTraceBlocks
                                                                              (vec3d, vec3d1);
            vec3d  = net.minecraft.src.Vec3D.CreateVector(posX, posY, posZ);
            vec3d1 = net.minecraft.src.Vec3D.CreateVector(posX + motionX, posY + motionY, posZ
                                                          + motionZ);
            if (movingobjectposition != null)
            {
                vec3d1 = net.minecraft.src.Vec3D.CreateVector(movingobjectposition.hitVec.xCoord,
                                                              movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
            }
            net.minecraft.src.Entity entity = null;
            System.Collections.Generic.List <Entity> 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.Count; j++)
            {
                net.minecraft.src.Entity entity1 = (net.minecraft.src.Entity)list[j];
                if (!entity1.CanBeCollidedWith() || entity1 == angler && ticksInAir < 5)
                {
                    continue;
                }
                float f2 = 0.3F;
                net.minecraft.src.AxisAlignedBB axisalignedbb = entity1.boundingBox.Expand(f2, f2
                                                                                           , f2);
                net.minecraft.src.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 net.minecraft.src.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 = net.minecraft.src.MathHelper.Sqrt_double(motionX * motionX + motionZ *
                                                               motionZ);

            rotationYaw = (float)((System.Math.Atan2(motionX, motionZ) * 180D) / 3.1415927410125732D
                                  );
            for (rotationPitch = (float)((System.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) * (double
                                                                                           )(l + 0)) / (double)k) - 0.125D) + 0.125D;
                double d9 = ((boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double
                                                                                           )(l + 1)) / (double)k) - 0.125D) + 0.125D;
                net.minecraft.src.AxisAlignedBB axisalignedbb1 = net.minecraft.src.AxisAlignedBB.
                                                                 GetBoundingBoxFromPool(boundingBox.minX, d8, boundingBox.minZ, boundingBox.maxX,
                                                                                        d9, boundingBox.maxZ);
                if (worldObj.IsAABBInMaterial(axisalignedbb1, net.minecraft.src.Material.water))
                {
                    d5 += 1.0D / (double)k;
                }
            }
            if (d5 > 0.0D)
            {
                if (ticksCatchable > 0)
                {
                    ticksCatchable--;
                }
                else
                {
                    char c = '\u01F4';
                    if (worldObj.CanLightningStrikeAt(net.minecraft.src.MathHelper.Floor_double(posX)
                                                      , net.minecraft.src.MathHelper.Floor_double(posY) + 1, net.minecraft.src.MathHelper
                                                      .Floor_double(posZ)))
                    {
                        c = '\u012C';
                    }
                    if (rand.Next(c) == 0)
                    {
                        ticksCatchable = rand.Next(30) + 10;
                        motionY       -= 0.20000000298023224D;
                        worldObj.PlaySoundAtEntity(this, "random.splash", 0.25F, 1.0F + (rand.NextFloat()
                                                                                         - rand.NextFloat()) * 0.4F);
                        float f3 = net.minecraft.src.MathHelper.Floor_double(boundingBox.minY);
                        for (int i1 = 0; (float)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 + (double)f4, f3 + 1.0F, posZ + (double)f6,
                                                   motionX, motionY - (double)(rand.NextFloat() * 0.2F), motionZ);
                        }
                        for (int j1 = 0; (float)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 + (double)f5, f3 + 1.0F, posZ + (double)f7,
                                                   motionX, motionY, motionZ);
                        }
                    }
                }
            }
            if (ticksCatchable > 0)
            {
                motionY -= (double)(rand.NextFloat() * rand.NextFloat() * rand.NextFloat()) * 0.20000000000000001D;
            }
            double d7 = d5 * 2D - 1.0D;

            motionY += 0.039999999105930328D * d7;
            if (d5 > 0.0D)
            {
                f1       = (float)((double)f1 * 0.90000000000000002D);
                motionY *= 0.80000000000000004D;
            }
            motionX *= f1;
            motionY *= f1;
            motionZ *= f1;
            SetPosition(posX, posY, posZ);
        }