Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Confused about "getWorld()" method


    Falcon

    Recommended Posts

    World world = new World().getWorld()

    Is it intentional that this returns me an integer of 300 regardless of the world I am in?

    Link to comment
    Share on other sites

    Didn't figgure out why it gave me 300 but found a static method getCurrentWorld() which did what I needed.

    Link to comment
    Share on other sites

    22 minutes ago, DarkFalcon said:

    Didn't figgure out why it gave me 300 but found a static method getCurrentWorld() which did what I needed.

    I believe it is due to the fact that when a new "World" object is instantiated, it has, by default, an ID of "0". This ID is then appended to the number "300" to get the world's ID. This does not return the ID of your currently world, just the ID of the World object.

    For example, if the World were to have an ID of "10", doing World.getWorld() would return "310".

    Happy to hear that you found a method for getting your current world that works for you. I personally use the same method.

     

    Link to comment
    Share on other sites

    Just like with many of the API's classes, you don't want to create new instances of them yourself. You're supposed to use API methods such as Worlds.getMyWorld(), Worlds.getRandomWorld() or Worlds.getWorld(World::isF2P).

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.