sergbot 0 Share Posted December 17, 2020 if (!Inventory.contains("Logs") && (GameObjects.closest("Fire") == null || GameObjects.closest("Fire").distance() > 10)) { So basically, i would check if a fire exists using "fire" == However, sometimes the client glitches out, and it says that the fire isnt null and that the distance is like 50. However if i just use .distance is less than 12, then it throws an npe if the fire object is actually null. So i need to check if its null, or if it's not null and the distance is less than 50. Link to comment Share on other sites More sharing options...
sergbot 0 Author Share Posted December 17, 2020 damn, im retarded, i can just do if (!Inventory.contains("Logs") && (GameObjects.closest("Fire") == null || (GameObjects.closest("Fire") != null && GameObjects.closest("Fire").distance() > 10))) { Link to comment Share on other sites More sharing options...
crazykid080 14 Share Posted December 17, 2020 I would recommend using a filter. For example: GameObjects.closest(object -> object.getName.equals("Fire") && fire != null && fire.distance > 10); Simplifies your code significantly Link to comment Share on other sites More sharing options...
CodeNinja 32 Share Posted December 18, 2020 5 hours ago, crazykid080 said: I would recommend using a filter. For example: GameObjects.closest(object -> object.getName.equals("Fire") && fire != null && fire.distance > 10); Simplifies your code significantly this wouldnt work in his case, and the syntax is wrong. he wants to check if it is null or if it is further than 10 if(!Inventory.contains("Logs") && GameObjects.closest(gameObject -> gameObject.getName().equals("Fire") && gameObject.distance() < 10) == null) { do stuff } Link to comment Share on other sites More sharing options...
crazykid080 14 Share Posted December 18, 2020 It was a very rough idea as I was just waking up, thanks for improving it, hopefully that helps OP Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.