コード例 #1
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (field_9177_b > 0)
            {
                field_9177_b--;
            }
            if (damageTaken > 0)
            {
                damageTaken--;
            }
            prevPosX = posX;
            prevPosY = posY;
            prevPosZ = posZ;
            int    i = 5;
            double d = 0.0D;

            for (int j = 0; j < i; j++)
            {
                double d5 = (boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double)
                                                 (j + 0)) / (double)i) - 0.125D;
                double d9 = (boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double)
                                                 (j + 1)) / (double)i) - 0.125D;
                net.minecraft.src.AxisAlignedBB axisalignedbb = net.minecraft.src.AxisAlignedBB.GetBoundingBoxFromPool
                                                                    (boundingBox.minX, d5, boundingBox.minZ, boundingBox.maxX, d9, boundingBox.maxZ);
                if (worldObj.IsAABBInMaterial(axisalignedbb, net.minecraft.src.Material.water))
                {
                    d += 1.0D / (double)i;
                }
            }
            if (worldObj.singleplayerWorld)
            {
                if (field_9176_d > 0)
                {
                    double d1  = posX + (field_9174_e - posX) / (double)field_9176_d;
                    double d6  = posY + (field_9172_f - posY) / (double)field_9176_d;
                    double d10 = posZ + (field_9175_aj - posZ) / (double)field_9176_d;
                    double d14;
                    for (d14 = field_9173_ak - (double)rotationYaw; d14 < -180D; d14 += 360D)
                    {
                    }
                    for (; d14 >= 180D; d14 -= 360D)
                    {
                    }
                    rotationYaw   += (float)(d14 / (double)field_9176_d);
                    rotationPitch += (float)((field_9171_al - (double)rotationPitch) / (double)field_9176_d);
                    field_9176_d--;
                    SetPosition(d1, d6, d10);
                    SetRotation(rotationYaw, rotationPitch);
                }
                else
                {
                    double d2  = posX + motionX;
                    double d7  = posY + motionY;
                    double d11 = posZ + motionZ;
                    SetPosition(d2, d7, d11);
                    if (onGround)
                    {
                        motionX *= 0.5D;
                        motionY *= 0.5D;
                        motionZ *= 0.5D;
                    }
                    motionX *= 0.99000000953674316D;
                    motionY *= 0.94999998807907104D;
                    motionZ *= 0.99000000953674316D;
                }
                return;
            }
            if (d < 1.0D)
            {
                double d3 = d * 2D - 1.0D;
                motionY += 0.039999999105930328D * d3;
            }
            else
            {
                if (motionY < 0.0D)
                {
                    motionY /= 2D;
                }
                motionY += 0.0070000002160668373D;
            }
            if (riddenByEntity != null)
            {
                motionX += riddenByEntity.motionX * 0.20000000000000001D;
                motionZ += riddenByEntity.motionZ * 0.20000000000000001D;
            }
            double d4 = 0.40000000000000002D;

            if (motionX < -d4)
            {
                motionX = -d4;
            }
            if (motionX > d4)
            {
                motionX = d4;
            }
            if (motionZ < -d4)
            {
                motionZ = -d4;
            }
            if (motionZ > d4)
            {
                motionZ = d4;
            }
            if (onGround)
            {
                motionX *= 0.5D;
                motionY *= 0.5D;
                motionZ *= 0.5D;
            }
            MoveEntity(motionX, motionY, motionZ);
            double d8 = System.Math.Sqrt(motionX * motionX + motionZ * motionZ);

            if (d8 > 0.14999999999999999D)
            {
                double d12 = System.Math.Cos(((double)rotationYaw * 3.1415926535897931D) / 180D);
                double d15 = System.Math.Sin(((double)rotationYaw * 3.1415926535897931D) / 180D);
                for (int i1 = 0; (double)i1 < 1.0D + d8 * 60D; i1++)
                {
                    double d18 = rand.NextFloat() * 2.0F - 1.0F;
                    double d20 = (double)(rand.Next(2) * 2 - 1) * 0.69999999999999996D;
                    if (rand.NextBoolean())
                    {
                        double d21 = (posX - d12 * d18 * 0.80000000000000004D) + d15 * d20;
                        double d23 = posZ - d15 * d18 * 0.80000000000000004D - d12 * d20;
                        worldObj.SpawnParticle("splash", d21, posY - 0.125D, d23, motionX, motionY, motionZ
                                               );
                    }
                    else
                    {
                        double d22 = posX + d12 + d15 * d18 * 0.69999999999999996D;
                        double d24 = (posZ + d15) - d12 * d18 * 0.69999999999999996D;
                        worldObj.SpawnParticle("splash", d22, posY - 0.125D, d24, motionX, motionY, motionZ
                                               );
                    }
                }
            }
            if (isCollidedHorizontally && d8 > 0.14999999999999999D)
            {
                if (!worldObj.singleplayerWorld)
                {
                    SetEntityDead();
                    for (int k = 0; k < 3; k++)
                    {
                        DropItemWithOffset(net.minecraft.src.Block.WOOD.ID, 1, 0.0F);
                    }
                    for (int l = 0; l < 2; l++)
                    {
                        DropItemWithOffset(net.minecraft.src.Item.STICK.ID, 1, 0.0F);
                    }
                }
            }
            else
            {
                motionX *= 0.99000000953674316D;
                motionY *= 0.94999998807907104D;
                motionZ *= 0.99000000953674316D;
            }
            rotationPitch = 0.0F;
            double d13 = rotationYaw;
            double d16 = prevPosX - posX;
            double d17 = prevPosZ - posZ;

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

            for (d19 = d13 - (double)rotationYaw; d19 >= 180D; d19 -= 360D)
            {
            }
            for (; d19 < -180D; d19 += 360D)
            {
            }
            if (d19 > 20D)
            {
                d19 = 20D;
            }
            if (d19 < -20D)
            {
                d19 = -20D;
            }
            rotationYaw += (float)d19;
            SetRotation(rotationYaw, rotationPitch);
            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.EntityBoat
                                                                             ))
                    {
                        entity.ApplyEntityCollision(this);
                    }
                }
            }
            for (int k1 = 0; k1 < 4; k1++)
            {
                int l1 = net.minecraft.src.MathHelper.Floor_double(posX + ((double)(k1 % 2) - 0.5D
                                                                           ) * 0.80000000000000004D);
                int i2 = net.minecraft.src.MathHelper.Floor_double(posY);
                int j2 = net.minecraft.src.MathHelper.Floor_double(posZ + ((double)(k1 / 2) - 0.5D
                                                                           ) * 0.80000000000000004D);
                if (worldObj.GetBlockId(l1, i2, j2) == net.minecraft.src.Block.SNOW.ID)
                {
                    worldObj.SetBlockWithNotify(l1, i2, j2, 0);
                }
            }
            if (riddenByEntity != null && riddenByEntity.isDead)
            {
                riddenByEntity = null;
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public virtual void OnLivingUpdate()
        {
            if (field_9140_bf > 0)
            {
                double d  = posX + (field_9139_bg - posX) / (double)field_9140_bf;
                double d1 = posY + (field_9138_bh - posY) / (double)field_9140_bf;
                double d2 = posZ + (field_9137_bi - posZ) / (double)field_9140_bf;
                double d3;
                for (d3 = field_9136_bj - (double)rotationYaw; d3 < -180D; d3 += 360D)
                {
                }
                for (; d3 >= 180D; d3 -= 360D)
                {
                }
                rotationYaw   += (float)(d3 / (double)field_9140_bf);
                rotationPitch += (float)((field_9135_bk - (double)rotationPitch) / (double)field_9140_bf);
                field_9140_bf--;
                SetPosition(d, d1, d2);
                SetRotation(rotationYaw, rotationPitch);
                System.Collections.Generic.List <AxisAlignedBB> list1 = worldObj.GetCollidingBoundingBoxes(this, boundingBox
                                                                                                           .GetInsetBoundingBox(0.03125D, 0.0D, 0.03125D));
                if (list1.Count > 0)
                {
                    double d4 = 0.0D;
                    for (int j = 0; j < list1.Count; j++)
                    {
                        net.minecraft.src.AxisAlignedBB axisalignedbb = (net.minecraft.src.AxisAlignedBB)
                                                                        list1[j];
                        if (axisalignedbb.maxY > d4)
                        {
                            d4 = axisalignedbb.maxY;
                        }
                    }
                    d1 += d4 - boundingBox.minY;
                    SetPosition(d, d1, d2);
                }
            }
            if (IsMovementBlocked())
            {
                isJumping         = false;
                moveStrafing      = 0.0F;
                moveForward       = 0.0F;
                randomYawVelocity = 0.0F;
            }
            else
            {
                if (!isMultiplayerEntity)
                {
                    UpdatePlayerActionState();
                }
            }
            bool flag  = IsInWater();
            bool flag1 = HandleLavaMovement();

            if (isJumping)
            {
                if (flag)
                {
                    motionY += 0.039999999105930328D;
                }
                else
                {
                    if (flag1)
                    {
                        motionY += 0.039999999105930328D;
                    }
                    else
                    {
                        if (onGround)
                        {
                            Jump();
                        }
                    }
                }
            }
            moveStrafing      *= 0.98F;
            moveForward       *= 0.98F;
            randomYawVelocity *= 0.9F;
            MoveEntityWithHeading(moveStrafing, moveForward);
            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 i = 0; i < list.Count; i++)
                {
                    net.minecraft.src.Entity entity = (net.minecraft.src.Entity)list[i];

                    // CRAFTBUKKIT start - Only handle mob (non-player) collisions every other tick
                    if (entity is EntityLiving && !(this is EntityPlayer) && (this.ticksExisted & 1) == 1)
                    {
                        continue;
                    }
                    // CRAFTBUKKIT end

                    if (entity.CanBePushed())
                    {
                        entity.ApplyEntityCollision(this);
                    }
                }
            }
        }