Package dev.twilite.game
Class Game
java.lang.Object
dev.twilite.game.Game
Static entry point for client state and top-level game queries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intAdvances and returns the client-owned server tick counter.static intcycle()Returns the current main cycle, or-1when unavailable.static EffectVieweffects()Returns active spot effects from the root world and local world when different.static HintArrowViewReturns active hint arrows from the root world and local world when different.static voidHops to the specified world.static InteractionScopeReturns interaction helpers scoped to the root world.static InteractionScopeinteractionScope(Optional<World> world) Returns interaction helpers scoped to a loaded world.static booleanloading()Returns true if the game is loadingReturns the transmitted child world containing the local player.static Optional<WorldEntity> Returns the transmitted world entity containing the local player.static booleanloggedIn()Returns true if logged instatic voidlogout()Logs out using the interfacestatic NpcViewnpcs()Returns loaded NPCs from the root world and local world when different.static SceneObjectViewobjects()Returns scene objects from the root world and local world when different.static SceneObjectViewobjects(int layer) Returns scene objects matching a layer mask from the root world and local world when different.static voidplayer()Returns the local player.static intReturns the local player index, or-1when unavailable.static PlayerViewplayers()Returns loaded players from the root world and local world when different.static Optional<ScreenPoint> project(int fineX, int fineY, int floor, int zOffset) Projects fine coordinate components to the screen.static Optional<ScreenPoint> project(Coord.Fine fine) Projects a fine coordinate to the screen.static Optional<ScreenPoint> project(Coord.Fine fine, int zOffset) Projects a fine coordinate to the screen with a vertical offset.static ProjectileViewReturns active projectiles from the root world and local world when different.Returns the root world when the client is available.static voidscript(int... args) Executes a client script using a fast path taking integer-only arguments.static voidscriptAffined(int id, Object... args) Executes a client script using mixed integer, string, and long arguments.server()Returns the current server from the public server list when available.static ServerViewservers()Returns a lazy view of the public server list.static voidsetFps(int fps, int spoofedFps) Sets foreground and background FPS device options.static booleanstatic intstate()Returns the current main state, or-1when unavailable.static View<SubInterface> Returns open sub-interfaces.static inttick()Returns the current server tick, or-1when unavailable.static TileItemViewReturns tile items from the root world and local world when different.static TileItemViewtileItems(int floor) Returns tile items on a floor from the root world and local world when different.static intvar(int index) Returns a varp value.static intvarbit(int index) Returns a varbit value.static int[]vars()Returns a snapshot of all varp values, or an empty array when unavailable.world(int id) Returns a loaded world by id.
-
Field Details
-
LOADING_REGION
public static final int LOADING_REGION- See Also:
-
LOGGED_IN
public static final int LOGGED_IN- See Also:
-
SWITCHING_WORLD
public static final int SWITCHING_WORLD- See Also:
-
COMPLETING_WORLD_TRANSFER
public static final int COMPLETING_WORLD_TRANSFER- See Also:
-
-
Constructor Details
-
Game
public Game()
-
-
Method Details
-
rootWorld
Returns the root world when the client is available. -
interactionScope
Returns interaction helpers scoped to the root world. -
interactionScope
Returns interaction helpers scoped to a loaded world.- Parameters:
world- world to query for NPCs, scene objects, and tile items
-
world
Returns a loaded world by id. -
servers
Returns a lazy view of the public server list. -
server
Returns the current server from the public server list when available. -
showingWorldSwitcher
public static boolean showingWorldSwitcher() -
openWorldSwitcher
public static void openWorldSwitcher() -
hopTo
Hops to the specified world. -
cycle
public static int cycle()Returns the current main cycle, or-1when unavailable. -
state
public static int state()Returns the current main state, or-1when 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-1when 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 fromVarpId
-
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
Executes a client script using mixed integer, string, and long arguments.- Parameters:
id- script id to executeargs- script arguments passed after the id
-
varbit
public static int varbit(int index) Returns a varbit value.- Parameters:
index- varbit id, usually fromVarbitId
-
playerIndex
public static int playerIndex()Returns the local player index, or-1when unavailable. -
localWorldEntity
Returns the transmitted world entity containing the local player. -
localWorld
Returns the transmitted child world containing the local player. -
player
Returns the local player. -
players
Returns loaded players from the root world and local world when different. -
npcs
Returns loaded NPCs from the root world and local world when different. -
effects
Returns active spot effects from the root world and local world when different. -
tileItems
Returns tile items from the root world and local world when different. -
tileItems
Returns tile items on a floor from the root world and local world when different. -
objects
Returns scene objects from the root world and local world when different. -
objects
Returns scene objects matching a layer mask from the root world and local world when different. -
projectiles
Returns active projectiles from the root world and local world when different. -
hintArrows
Returns active hint arrows from the root world and local world when different. -
project
Projects a fine coordinate to the screen. -
project
Projects a fine coordinate to the screen with a vertical offset. -
project
Projects fine coordinate components to the screen. -
subInterfaces
Returns open sub-interfaces. -
setFps
public static void setFps(int fps, int spoofedFps) Sets foreground and background FPS device options.spoofedFpsshould be set to -1 to stop spoofing it
-