OpenOSRS

repository·master·Indexed 43 days ago

https://github.com/open-osrs/runelite

An open-source, unrestricted client based on a special branch of RuneLite that uses a bytecode weaver injector to allow code injection into the obfuscated gamepack. It includes modules for cache management, deobfuscation, a wiki-scraper, and a comprehensive API for interacting with the RuneScape client, including player data, NPC information, and game widgets.

Tokens
9.5K
Snippets
36
Records
59
Agent score
56%

What's inside OpenOSRS

  1. Understand the OpenOSRS project layout

    master

    The repository is organized into several modules that handle different aspects of the client and game interaction:

    • cache: Libraries for reading/writing cache files and managing cache data.
    • deobfuscator: Tools to decompile/cleanup gamepacks and map updates to newer revisions.
    • http-api: API for RuneLite and OpenOSRS communication.
    • injector: A bytecode weaver used to inject code into the obfuscated gamepack.
    • runelite-api: The RuneLite API containing interfaces for accessing the client.
    • runelite-mixins: Classes containing objects to be injected via the injector-plugin.
    • runescape-api: Full mappings for game interfaces; runelite-api is a subset of this.
    • runelite-client: The core game client and plugin system.
    • wiki-scraper: Scrapes https://oldschool.runescape.wiki for the latest NPC data.
  2. Build and run OpenOSRS from source

    master

    To build the project and launch the client from the root module, use the following Gradle command:

    ./gradlew clean build run

    Note: This branch uses upstream components like PlayerManager and OverlayManager. If you are porting a plugin, ensure compatibility with these upstream managers.

    clean build run
  3. Configure Graphics3D rendering settings

    master

    The Graphics3D class provides several public and package-private fields to control the 3D rasterization process. You can adjust the following parameters:

    • rasterGouraudLowRes (boolean): Enables low-resolution Gouraud shading. Defaults to true.
    • rasterAlpha (int): Sets the transparency/alpha level for rendering.
    • Rasterizer3D_zoom (int): Controls the 3D zoom level. Defaults to 512.
    • colorPalette (int[]): An array of colors used for rendering, typically set via setBrightness(double brightness).
  4. Execute the main client loop with doCycle()

    master

    The doCycle() method is the core execution loop of the client. It increments the cycle counter and triggers doCycleJs5() to handle network/cache operations. It also manages:

    • Music player status and PCM stream volume.
    • KeyHandler updates (processing pressed/released keys).
    • MouseHandler updates (syncing mouse position and button states).
    • Game state transitions (handling login screens, logged-out states, and logged-in states).
    @Export("doCycle")
    protected final void doCycle() {
        ++cycle;
        this.doCycleJs5();
        // ... handles music, KeyHandler, MouseHandler, and gameState transitions
    }
  5. Align a widget with alignWidget()

    master

    The alignWidget(Widget var1) method aligns a specific Widget relative to its parent. If the widget has no parent, it aligns relative to the canvas width and height. Otherwise, it aligns relative to the parent's dimensions using Decimator.alignWidgetSize and class240.alignWidgetPosition.

    @Export("alignWidget")
    void alignWidget(Widget var1)
  6. Access Client state and game data via Client class

    master

    The Client class is the primary entry point for accessing the game engine's state. It provides a wide range of static fields that expose real-time game data, including player information, world settings, UI/widget states, and network status.

    Note that many fields are obfuscated in the underlying bytecode but are exposed via @Export names for developer use. Use these exported names when interacting with the client via reflection or external tools.

  7. Execute menu actions via menu()

    master

    The menu() method handles the logic for processing mouse interactions with the game's context menu. It manages menu option sorting, detects if a click should open a menu, handles item dragging (inventory interaction), and dispatches menu actions to the FriendsList.menuAction handler.

    Key behaviors:

    • Sorting: Reorders menu options based on opcodes.
    • Dragging: If a valid item drag is detected (based on specific opcodes like 39-43, 33-38, or 1005), it sets Interpreter.dragInventoryWidget and updates drag coordinates.
    • Action Dispatch: When a menu option is selected, it calls FriendsList.menuAction with the corresponding arguments, opcodes, identifiers, actions, and targets.
    // Note: menu() is a final void method with no parameters.
    // It is triggered by internal input handling.
    @Export("menu")
    final void menu() {
        // ... internal logic for handling menu clicks and drags
    }
  8. Configure camera and input settings

    master

    The Client allows programmatic control over camera behavior and input inversion.

    Camera Controls:

    • setCameraPitchRelaxerEnabled(boolean enabled): Enables/disables the ability for camera pitch to exceed normal limits.
    • setInvertYaw(boolean invertYaw): Inverts horizontal camera movement.
    • setInvertPitch(boolean invertPitch): Inverts vertical camera movement.

    Input/Mouse Controls:

    • setMinimapReceivesClicks(boolean minimapReceivesClicks): Determines if the minimap accepts mouse clicks.
    • setShowMouseCross(boolean show): Toggles the visibility of the mouse crosshair.