jawa 4 Share Posted March 12, 2020 So I'm trying to identify a gameObject by getModelColors(). GameObject xx = getGameObjects().closest(o -> o.getModelColors()[0] == 2555); However, this throws me a nullpointer exception. I've also tried passing it through a filter, no luck. Link to comment Share on other sites More sharing options...
Neffarion 486 Share Posted March 13, 2020 35 minutes ago, jawa said: So I'm trying to identify a gameObject by getModelColors(). GameObject xx = getGameObjects().closest(o -> o.getModelColors()[0] == 2555); However, this throws me a nullpointer exception. I've also tried passing it through a filter, no luck. The gameObject can be null as well as the modelcolors array, you need to null check them beforehand: GameObject xx = getGameObjects().closest(o -> o != null && o.getModelColors() != null && o.getModelColors().length > 0 && o.getModelColors()[0] == 2555); Link to comment Share on other sites More sharing options...
jawa 4 Author Share Posted March 13, 2020 Thanks for your help. However it still throws me a nullpointer.. Link to comment Share on other sites More sharing options...
jawa 4 Author Share Posted March 13, 2020 Ah silly me... I never checked if the modelColors array was null, only the object itself. It works now, thank you once again! Link to comment Share on other sites More sharing options...
ATwerkinHobo 0 Share Posted March 16, 2020 I found that when setting up the script for mining, it was faster and had better results when searching for the ID numbers of the rocks opposed to the color. Also had far less trouble with the null pointer exception issue which was happening when trying to check the color of an empty rock. Just be careful when using ID numbers - I've found that each type of ore has at least two different ID numbers. It's an easy way to get detected if you're only mining the one ID. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.