Class SailingService


  • public class SailingService
    extends java.lang.Object
    • Constructor Detail

      • SailingService

        public SailingService()
    • Method Detail

      • setDirection

        public boolean setDirection​(SailingService.Direction direction)
        Sets the sailing direction of the boat in the game.

        This method first ensures that the necessary game packets are loaded. If not, it immediately returns false. If packets are loaded, a mouse click packet is queued, followed by a request to update the boat direction using the provided SailingService.Direction value.

        The direction is set by passing the direction's code to the sailing packet system. Directions are represented using predefined constants in the SailingService.Direction enumeration.

        Parameters:
        direction - The desired SailingService.Direction to set the boat's heading. Directions are enumerated values ranging from SOUTH(0) to SOUTH_SOUTH_EAST(15).
        Returns:
        true if the direction was successfully set; false if the necessary game packets were not loaded.
      • increaseSpeed

        public void increaseSpeed()
        Increases the speed of the boat in the game.

        This method interacts with the in-game sailing controls to increment the boat's speed by one level, provided it is not already at the maximum speed setting.

      • decreaseSpeed

        public void decreaseSpeed()
        Decreases the speed of the boat in the game.

        This method interacts with the in-game sailing controls to reduce the boat's speed by one level, unless the current speed is already at the lowest setting. The speed is determined by querying the value of a specific varbit used to represent the boat's speed state.

        If the boat's speed is set to the minimum value (3 in the current configuration), the method exits immediately without issuing any further actions.

      • getDirection

        public SailingService.Direction getDirection()
        Retrieves the current direction of the boat based on its angle in the game.

        This method utilizes the SailingService.Direction.fromAngle(int) method to derive the boat's direction from the angle value provided by the VarbitID.SAILING_BOAT_SPAWNED_ANGLE varbit. The angle is divided into predefined directional constants representing the boat's heading.

        Returns:
        The SailingService.Direction the boat is currently facing. If no valid direction can be derived, null is returned.
      • unsetSails

        public void unsetSails()
        Disables the boat's sails to bring the vessel to a halt.

        This method initiates the in-game action to unset the boat's sails, effectively stopping the boat's movement. It checks the current movement status of the boat by invoking isMoving(). If the boat is stationary, the method exits immediately without issuing any commands. This safeguards against unnecessary actions when the boat is not in motion.

      • setSails

        public void setSails()
        Deploys the boat's sails to enable sailing control.

        This method triggers the in-game action to set the boat's sails, allowing the player to control the vessel. If the boat is currently in motion, the method exits immediately without performing any action to avoid conflicting states.

      • isNavigating

        public boolean isNavigating()
        Determines whether the player is at the helm of the boat and navigating

        This method checks the value of a specific varbit to identify if the navigation system is active. A non-zero value indicates that the boat is navigating, while a value of zero suggests it is not.

        Returns:
        true if the boat's navigation system is active; false otherwise.
      • isMoving

        public boolean isMoving()
        Checks if the boat is currently moving based on the speed state.

        This method determines the movement state by examining the value of a specific varbit linked to the boat's speed. A non-zero value indicates that the boat is in motion, while a zero value means it is stationary.

        Returns:
        true if the boat is moving; false otherwise.