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
  • Try asking for help in the chatbox
  • Having trouble interacting with a fountain. smh


    Et43
     Share

    Recommended Posts

    So im in the process of making a Jug filler and currently what i need it to do is to use a jug on the fountain ive tried the following 

    npc = getNpcs().closest(fountain -> fountain != null && fountain.getName().contentEquals("Small fountain"));
    getInventory().interact(jugId, "Use");
    npc.interact();

    Error Code:

    6:20:26 PM: [ERROR] Exception has occurred while running! Please report error to developer if problem persists:
        java.lang.NullPointerException
        at filler.onLoop(filler.java:62)
        at org.dreambot.api.script.AbstractScript.run(AbstractScript.java)
        at java.lang.Thread.run(Unknown Source)
     

    And ive done the same with GameObject, but still get the same error.

    Any idea on how to fix?

     

    Link to comment
    Share on other sites

    Fountain isn't a NPC, it's a GameObject. Also, you should have null checks to avoid getting NullPointerExceptions. The Item class has the method useOn(Entity e), which you should use instead of what you're currently doing to use the item on a fountain.

    Link to comment
    Share on other sites

    2 hours ago, Hashtag said:

    Fountain isn't a NPC, it's a GameObject. Also, you should have null checks to avoid getting NullPointerExceptions. The Item class has the method useOn(Entity e), which you should use instead of what you're currently doing to use the item on a fountain.

    How would you declare what the item is using the Item class.( sorry for the question, new to java but got 2years of python to help me understand just a little ) 

    Link to comment
    Share on other sites

    I'm not sure what you're asking me, but here's what you're after

    Item jugOfWater = Inventory.get("Jug of water");
    if (jugOfWater != null) { // do we have it in our inv?
        GameObject fountain = GameObjects.closest("Fountain");
        if (fountain != null) { // does the fountain exist?
            if (jugOfWater.useOn(fountain)) {
                // interaction successful
            }
        }
    }
    Link to comment
    Share on other sites

    14 hours ago, Hashtag said:

    I'm not sure what you're asking me, but here's what you're after

    Item jugOfWater = Inventory.get("Jug of water");
    if (jugOfWater != null) { // do we have it in our inv?
        GameObject fountain = GameObjects.closest("Fountain");
        if (fountain != null) { // does the fountain exist?
            if (jugOfWater.useOn(fountain)) {
                // interaction successful
            }
        }
    }

     

    Ye thats what i was asking, thx m8.

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.