1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question Ground Item Null pointer

Discussion in 'Developer Support' started by Firehawk1, May 28, 2019.

  1. Firehawk1

    Joined:
    Jan 7, 2019
    Messages:
    4
    Likes Received:
    0
    GroundItem fish = GroundItems.newQuery().names("Tuna").actions("Take").results().nearest();

    fish.click();

    When ever I run this code it returns with a null pointer even if there is tuna on the ground? What am I missing?


    update: i took away the action() and it worked?
     
    #1 Firehawk1, May 28, 2019
    Last edited: May 28, 2019
  2. Drupz

    Joined:
    May 30, 2019
    Messages:
    34
    Likes Received:
    11
    Code (Text):
    1. GroundItem fish = GroundItems.newQuery().names("Tuna").results().nearest();
    2. if(fish != null){
    3.     fish.interact("Take");
    4. }
    Would be a cleaner solution
     
    #2 Drupz, Jun 2, 2019
    Last edited: Jun 2, 2019
    Snufalufugus likes this.

Share This Page

Loading...