BrainDeadGenius Posted February 18, 2017 Share Posted February 18, 2017 (edited) I have the code, shown below, to exit the rune essence mine. It works 9/10 times, but in some instances, I am too far away from the portal. By 9/10 times, I mean it could happen once in 15 minutes, or once in 2-4 hours. For some reason, it ends up grabbing another portal that's either too far away, or doesn't actually exist (at least, that's what it seemed like whilst debugging). Be it noted that the log for "Could not find the exit portal" is not being displayed while trying to exit through this portal, until I get closer. Stream.concat(getNpcs().getAll().stream(), getObjects().getAll().stream()) .filter(entity -> entity.getName().contains("Portal")) .min((portal1, portal2) -> Integer.compare(myPosition().distance(portal1.getPosition()), myPosition().distance(portal2.getPosition()))) .ifPresent(portal -> { if (portal.interact("Exit", "Use", "Enter")) { new ConditionalSleep(10000) { @Override public boolean condition() throws InterruptedException { return teleportArea.contains(myPosition()); } }.sleep(); } else { log("Could not find the exit portal."); } }); Edited February 26, 2017 by BrainDeadGenius Quote Link to comment Share on other sites More sharing options...
Manner Posted February 18, 2017 Share Posted February 18, 2017 Never personally dealt with this, but for an idea you could make a loop to test all the different types until it is not null. Quote Link to comment Share on other sites More sharing options...
House Posted February 18, 2017 Share Posted February 18, 2017 (edited) Name is blue -> NPC npc.getDefinition().getId() The name has some formatting to make it blue, usually NPCs are yellow so that is the reason there is formatting. Edited February 18, 2017 by House Quote Link to comment Share on other sites More sharing options...
BrainDeadGenius Posted February 18, 2017 Author Share Posted February 18, 2017 1 minute ago, House said: Name is blue -> NPC npc.getDefinition().getModelIds()[0] It's showing up as an NPC right now, and getting it by nps.closest("Portal") or getNpcs.closest("Portal") both return null. Quote Link to comment Share on other sites More sharing options...
Manner Posted February 18, 2017 Share Posted February 18, 2017 2 minutes ago, House said: Name is blue -> NPC npc.getDefinition().getId() He said that it is not always a NPC, is that not the case? Quote Link to comment Share on other sites More sharing options...
BrainDeadGenius Posted February 18, 2017 Author Share Posted February 18, 2017 Just now, Manner said: He said that it is not always a NPC, is that not the case? No, it's not always an NPC. But it is right now, and it's returning null anyways. Quote Link to comment Share on other sites More sharing options...
House Posted February 18, 2017 Share Posted February 18, 2017 Just now, BrainDeadGenius said: It's showing up as an NPC right now, and getting it by nps.closest("Portal") or getNpcs.closest("Portal") both return null. Just now, Manner said: He said that it is not always a NPC, is that not the case? Just.. i edited my post with more details xD read Quote Link to comment Share on other sites More sharing options...
BrainDeadGenius Posted February 18, 2017 Author Share Posted February 18, 2017 1 minute ago, House said: Just.. i edited my post with more details xD read The others used .closest("Portal") and it would work. Same setup with the name, just a different color. But I get that. Best method is to use exitPortalPlayer = getPlayers().closest(o -> o.getName().contains("Portal")); exitPortalNPC = getNpcs().closest(o -> o.getName().contains("Portal")); exitPortalEntity = getObjects().closest(o -> o.getName().contains("Portal")); Quote Link to comment Share on other sites More sharing options...
House Posted February 18, 2017 Share Posted February 18, 2017 1 minute ago, BrainDeadGenius said: The others used .closest("Portal") and it would work. Same setup with the name, just a different color. But I get that. Best method is to use exitPortalPlayer = getPlayers().closest(o -> o.getName().contains("Portal")); exitPortalNPC = getNpcs().closest(o -> o.getName().contains("Portal")); exitPortalEntity = getObjects().closest(o -> o.getName().contains("Portal")); The reason it doesn't work is because of the unique color essentially yeah :p Quote Link to comment Share on other sites More sharing options...
BrainDeadGenius Posted February 18, 2017 Author Share Posted February 18, 2017 7 minutes ago, House said: The reason it doesn't work is because of the unique color essentially yeah :p Well the thing is, it would work by grabbing closest portal, sometimes. I think this was only happening when it was an object though. Just damn weird. Quote Link to comment Share on other sites More sharing options...
Explv Posted February 18, 2017 Share Posted February 18, 2017 43 minutes ago, BrainDeadGenius said: So, I've been trying to work out a rune essence miner. And I'm able to get everything to work of course, except for one thing. The portal to leave. It looks like the portal changes ID's and names (The color is included in the name) randomly every 1-3 trips to the mine. That's no problem when you grab it by name. However, it also appears that the type of object you're trying to grab changes as well. Sometimes, the portal will be an NPC. Sometimes, it will be any form of object. And at other times, it might even be a player (haven't confirmed this yet). But, there's apparently another form of object that it can take that I have not accounted for. So, the portal returns null. View the GIF below. Suggestions are welcome. https://gyazo.com/ede7dc8104e62b6ffd6ed4fcdea57c4d This is what I used: Stream.concat(getObjects().getAll().stream(), getNpcs().getAll().stream()) .filter(entity -> entity.getName().contains("Portal")) .findAny() .ifPresent(portal -> { if (portal.interact("Use", "Exit")) { Sleep.sleepUntil(() -> !portal.isVisible(), 10_000); } }); 3 Quote Link to comment Share on other sites More sharing options...
BrainDeadGenius Posted February 18, 2017 Author Share Posted February 18, 2017 6 minutes ago, Explv said: This is what I used: Stream.concat(getObjects().getAll().stream(), getNpcs().getAll().stream()) .filter(entity -> entity.getName().contains("Portal")) .findAny() .ifPresent(portal -> { if (portal.interact("Use", "Exit")) { Sleep.sleepUntil(() -> !portal.isVisible(), 10_000); } }); The portal variable contains the correct information, but it's refusing to interact with it (I changed your sleep class to my own method). Quote Link to comment Share on other sites More sharing options...
House Posted February 18, 2017 Share Posted February 18, 2017 1 minute ago, BrainDeadGenius said: The portal variable contains the correct information, but it's refusing to interact with it (I changed your sleep class to my own method). Maybe the interact is "Enter" ? Quote Link to comment Share on other sites More sharing options...
BrainDeadGenius Posted February 18, 2017 Author Share Posted February 18, 2017 (edited) 15 minutes ago, House said: Maybe the interact is "Enter" ? No, it's "Use", but I did add that to the list for future reference. https://gyazo.com/c28af0887dddf60da0336e4a53ecf85d That was a new occurrence, and it's worked so far since I've taken manual control for that one instance. Edited February 18, 2017 by BrainDeadGenius Quote Link to comment Share on other sites More sharing options...
BrainDeadGenius Posted February 26, 2017 Author Share Posted February 26, 2017 I'm going to reply to this instead of making a new thread. I've updated the original post and title to indicate the issue. Only happens every so often (could be 15 minutes, or once every 2-4 hours. It depends). Quote Link to comment Share on other sites More sharing options...