Esempio n. 1
0
        /// <summary>
        /// Decompose a single move from a block to another into several steps
        /// </summary>
        /// <remarks>
        /// Allows moving by little steps instead or directly moving between blocks,
        /// which would be rejected by anti-cheat plugins anyway.
        /// </remarks>
        /// <param name="start">Start location</param>
        /// <param name="goal">Destination location</param>
        /// <param name="stepsByBlock">Amount of steps by block</param>
        /// <returns>A list of locations corresponding to the requested steps</returns>
        public static Queue <Location> Move2Steps(Location start, Location goal, int stepsByBlock = 8)
        {
            if (stepsByBlock <= 0)
            {
                stepsByBlock = 1;
            }

            double   totalStepsDouble = start.Distance(goal) * stepsByBlock;
            int      totalSteps       = (int)Math.Ceiling(totalStepsDouble);
            Location step             = (goal - start) / totalSteps;

            if (totalStepsDouble >= 1)
            {
                Queue <Location> movementSteps = new Queue <Location>();
                for (int i = 1; i <= totalSteps; i++)
                {
                    movementSteps.Enqueue(start + step * i);
                }
                return(movementSteps);
            }
            else
            {
                return(new Queue <Location>(new[] { goal }));
            }
        }
        /// <summary>
        /// Decompose a single move from a block to another into several steps
        /// </summary>
        /// <remarks>
        /// Allows moving by little steps instead or directly moving between blocks,
        /// which would be rejected by anti-cheat plugins anyway.
        /// </remarks>
        /// <param name="start">Start location</param>
        /// <param name="goal">Destination location</param>
        /// <param name="motionY">Current vertical motion speed</param>
        /// <param name="falling">Specify if performing falling steps</param>
        /// <param name="stepsByBlock">Amount of steps by block</param>
        /// <returns>A list of locations corresponding to the requested steps</returns>
        public static Queue <Location> Move2Steps(Location start, Location goal, ref double motionY, bool falling = false, int stepsByBlock = 8)
        {
            if (stepsByBlock <= 0)
            {
                stepsByBlock = 1;
            }

            //Regular MCC moving algorithm
            motionY = 0; //Reset motion speed
            double   totalStepsDouble = start.Distance(goal) * stepsByBlock;
            int      totalSteps       = (int)Math.Ceiling(totalStepsDouble);
            Location step             = (goal - start) / totalSteps;

            if (totalStepsDouble >= 1)
            {
                Queue <Location> movementSteps = new Queue <Location>();
                for (int i = 1; i <= totalSteps; i++)
                {
                    movementSteps.Enqueue(start + step * i);
                }
                return(movementSteps);
            }
            else
            {
                return(new Queue <Location>(new[] { goal }));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Decompose a single move from a block to another into several steps
        /// </summary>
        /// <remarks>
        /// Allows moving by little steps instead or directly moving between blocks,
        /// which would be rejected by anti-cheat plugins anyway.
        /// </remarks>
        /// <param name="start">Start location</param>
        /// <param name="goal">Destination location</param>
        /// <param name="motionY">Current vertical motion speed</param>
        /// <param name="falling">Specify if performing falling steps</param>
        /// <param name="stepsByBlock">Amount of steps by block</param>
        /// <returns>A list of locations corresponding to the requested steps</returns>
        public static Queue <Location> Move2Steps(Location start, Location goal, ref double motionY, bool falling = false, int stepsByBlock = 8)
        {
            if (stepsByBlock <= 0)
            {
                stepsByBlock = 1;
            }

            if (falling)
            {
                //Use MC-Like falling algorithm
                double           Y         = start.Y;
                Queue <Location> fallSteps = new Queue <Location>();
                fallSteps.Enqueue(start);
                double motionPrev = motionY;
                motionY -= 0.08D;
                motionY *= 0.9800000190734863D;
                Y       += motionY;
                if (Y < goal.Y)
                {
                    return(new Queue <Location>(new[] { goal }));
                }
                else
                {
                    return(new Queue <Location>(new[] { new Location(start.X, Y, start.Z) }));
                }
            }
            else
            {
                //Regular MCC moving algorithm
                motionY = 0; //Reset motion speed
                double   totalStepsDouble = start.Distance(goal) * stepsByBlock;
                int      totalSteps       = (int)Math.Ceiling(totalStepsDouble);
                Location step             = (goal - start) / totalSteps;

                if (totalStepsDouble >= 1)
                {
                    Queue <Location> movementSteps = new Queue <Location>();
                    for (int i = 1; i <= totalSteps; i++)
                    {
                        movementSteps.Enqueue(start + step * i);
                    }
                    return(movementSteps);
                }
                else
                {
                    return(new Queue <Location>(new[] { goal }));
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Decompose a single move from a block to another into several steps
        /// </summary>
        /// <remarks>
        /// Allows moving by little steps instead or directly moving between blocks,
        /// which would be rejected by anti-cheat plugins anyway.
        /// </remarks>
        /// <param name="start">Start location</param>
        /// <param name="goal">Destination location</param>
        /// <param name="stepsByBlock">Amount of steps by block</param>
        /// <returns>A list of locations corresponding to the requested steps</returns>
        public static Queue<Location> Move2Steps(Location start, Location goal, int stepsByBlock = 8)
        {
            if (stepsByBlock <= 0)
                stepsByBlock = 1;

            double totalStepsDouble = start.Distance(goal) * stepsByBlock;
            int totalSteps = (int)Math.Ceiling(totalStepsDouble);
            Location step = (goal - start) / totalSteps;

            if (totalStepsDouble >= 1)
            {
                Queue<Location> movementSteps = new Queue<Location>();
                for (int i = 1; i <= totalSteps; i++)
                    movementSteps.Enqueue(start + step * i);
                return movementSteps;
            }
            else return new Queue<Location>(new[] { goal });
        }