Class Game

java.lang.Object
dev.twilite.game.Game

public class Game extends Object
Static entry point for client state and top-level game queries.
  • Field Details

  • Constructor Details

    • Game

      public Game()
  • Method Details

    • rootWorld

      public static Optional<World> rootWorld()
      Returns the root world when the client is available.
    • interactionScope

      public static InteractionScope interactionScope()
      Returns interaction helpers scoped to the root world.
    • interactionScope

      public static InteractionScope interactionScope(Optional<World> world)
      Returns interaction helpers scoped to a loaded world.
      Parameters:
      world - world to query for NPCs, scene objects, and tile items
    • world

      public static Optional<World> world(int id)
      Returns a loaded world by id.
    • servers

      public static ServerView servers()
      Returns a lazy view of the public server list.
    • server

      public static Optional<Server> server()
      Returns the current server from the public server list when available.
    • showingWorldSwitcher

      public static boolean showingWorldSwitcher()
    • openWorldSwitcher

      public static void openWorldSwitcher()
    • hopTo

      public static void hopTo(Server server)
      Hops to the specified world.
    • cycle

      public static int cycle()
      Returns the current main cycle, or -1 when unavailable.
    • state

      public static int state()
      Returns the current main state, or -1 when unavailable.
    • loading

      public static boolean loading()
      Returns true if the game is loading
    • loggedIn

      public static boolean loggedIn()
      Returns true if logged in
    • logout

      public static void logout()
      Logs out using the interface
    • tick

      public static int tick()
      Returns the current server tick, or -1 when unavailable.
    • advanceTick

      public static int advanceTick()
      Advances and returns the client-owned server tick counter.
    • var

      public static int var(int index)
      Returns a varp value.
      Parameters:
      index - varp id, usually from VarpId
    • vars

      public static int[] vars()
      Returns a snapshot of all varp values, or an empty array when unavailable.
    • script

      public static void script(int... args)
      Executes a client script using a fast path taking integer-only arguments.
      Parameters:
      args - script id followed by integer script arguments
    • scriptAffined

      public static void scriptAffined(int id, Object... args)
      Executes a client script using mixed integer, string, and long arguments.
      Parameters:
      id - script id to execute
      args - script arguments passed after the id
    • varbit

      public static int varbit(int index)
      Returns a varbit value.
      Parameters:
      index - varbit id, usually from VarbitId
    • playerIndex

      public static int playerIndex()
      Returns the local player index, or -1 when unavailable.
    • localWorldEntity

      public static Optional<WorldEntity> localWorldEntity()
      Returns the transmitted world entity containing the local player.
    • localWorld

      public static Optional<World> localWorld()
      Returns the transmitted child world containing the local player.
    • player

      public static Optional<Player> player()
      Returns the local player.
    • players

      public static PlayerView players()
      Returns loaded players from the root world and local world when different.
    • npcs

      public static NpcView npcs()
      Returns loaded NPCs from the root world and local world when different.
    • effects

      public static EffectView effects()
      Returns active spot effects from the root world and local world when different.
    • tileItems

      public static TileItemView tileItems()
      Returns tile items from the root world and local world when different.
    • tileItems

      public static TileItemView tileItems(int floor)
      Returns tile items on a floor from the root world and local world when different.
    • objects

      public static SceneObjectView objects()
      Returns scene objects from the root world and local world when different.
    • objects

      public static SceneObjectView objects(int layer)
      Returns scene objects matching a layer mask from the root world and local world when different.
    • projectiles

      public static ProjectileView projectiles()
      Returns active projectiles from the root world and local world when different.
    • hintArrows

      public static HintArrowView hintArrows()
      Returns active hint arrows from the root world and local world when different.
    • project

      public static Optional<ScreenPoint> project(Coord.Fine fine)
      Projects a fine coordinate to the screen.
    • project

      public static Optional<ScreenPoint> project(Coord.Fine fine, int zOffset)
      Projects a fine coordinate to the screen with a vertical offset.
    • project

      public static Optional<ScreenPoint> project(int fineX, int fineY, int floor, int zOffset)
      Projects fine coordinate components to the screen.
    • subInterfaces

      public static View<SubInterface> subInterfaces()
      Returns open sub-interfaces.
    • setFps

      public static void setFps(int fps, int spoofedFps)
      Sets foreground and background FPS device options. spoofedFps should be set to -1 to stop spoofing it