Hybris Posted April 27, 2020 Share Posted April 27, 2020 Hey, For some reason when I use mouse.getEntitiesOnCursor it only gives me one, even though the count says 2. The second entity is an NPC & I'm sure the mouse is placed right on the entity. Any ideas? Thanks in advance, Hybris P.S.: How would I accurately spam click an NPC? npc.interact() seems to move the mouse every time it clicks and mouse.click() can easily fail. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted April 27, 2020 Share Posted April 27, 2020 (edited) How are you looping through the list to print the entitys? For spam clicking an npc you can grab their bounding box and check if the mouse is within that than, just use mouse.click() else move the mouse to the npc. Or you can try the hover() method instead of grabbing the bounding box. It might move the mouse though even if its already hovering, kinda like the interact() method. Haven't tested. This wont work well with moving npcs. NPC npc = getNpcs().closest("Banker"); boolean isMouseOverNPC = (npc != null) && npc.getModel().getBoundingBox( npc.getGridX(), npc.getGridY(), npc.getZ()).contains(getMouse().getPosition()); if (isMouseOverNPC) getMouse().click(false); else if (npc != null) npc.hover(); Edited April 27, 2020 by BravoTaco Quote Link to comment Share on other sites More sharing options...
memelord123 Posted April 27, 2020 Share Posted April 27, 2020 if (getMouse().isOnCursor(yourNpcHere)) { getMouse().click(false); } As long as your mouse is on the npc, the mouse will left click and not move. Quote Link to comment Share on other sites More sharing options...
Hybris Posted April 27, 2020 Author Share Posted April 27, 2020 25 minutes ago, BravoTaco said: How are you looping through the list to print the entitys? For spam clicking an npc you can grab their bounding box and check if the mouse is within that than, just use mouse.click() else move the mouse to the npc. Or you can try the hover() method instead of grabbing the bounding box. It might move the mouse though even if its already hovering, kinda like the interact() method. Haven't tested. This wont work well with moving npcs. NPC npc = getNpcs().closest("Banker"); boolean isMouseOverNPC = (npc != null) && npc.getModel().getBoundingBox( npc.getGridX(), npc.getGridY(), npc.getZ()).contains(getMouse().getPosition()); if (isMouseOverNPC) getMouse().click(false); else if (npc != null) npc.hover(); I'm not looping through the list, just printing the list object. As for the spam clicking, I'm currently using the hover method which works, but sometimes the NPC is behind a door & it will click the door instead. 19 minutes ago, memelord123 said: if (getMouse().isOnCursor(yourNpcHere)) { getMouse().click(false); } As long as your mouse is on the npc, the mouse will left click and not move. I tried that but for some reason the "isOnCursor(npc)" method returns false even though the cursor is on my entity. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted April 27, 2020 Share Posted April 27, 2020 (edited) 14 minutes ago, Hybris said: I'm not looping through the list, just printing the list object. As for the spam clicking, I'm currently using the hover method which works, but sometimes the NPC is behind a door & it will click the door instead. Aaaah to see each item inside the list you will have to loop through it and print each element. You might have to check if there is more than one entity in the list, if their is than use the interact() method to interact, if not than you can just left click normally. You can also move the camera instead if an entity in the list is not the same position as the NPC, as this would imply that the only reason the other entity is in the list is because of camera position and not because two entitys are stacked. Edited April 27, 2020 by BravoTaco 1 Quote Link to comment Share on other sites More sharing options...
Hybris Posted April 27, 2020 Author Share Posted April 27, 2020 17 minutes ago, BravoTaco said: Aaaah to see each item inside the list you will have to loop through it and print each element. You might have to check if there is more than one entity in the list, if their is than use the interact() method to interact, if not than you can just left click normally. You can also move the camera instead if an entity in the list is not the same position as the NPC, as this would imply that the only reason the other entity is in the list is because of camera position and not because two entitys are stacked. I'm pretty sure you can print a list & see all the elements But I tried it with looping through each of them and it still gives me the same, it will only show the Player entity even when the "mouse.getOnCursorCount()" shows 2... Quote Link to comment Share on other sites More sharing options...
memelord123 Posted April 27, 2020 Share Posted April 27, 2020 43 minutes ago, Hybris said: I tried that but for some reason the "isOnCursor(npc)" method returns false even though the cursor is on my entity. I'm assuming that's happening when 2 entities are on the same tile? If so, this would work to spam click in the same spot unless another entity appears on the same tile in which case the mouse would interact with your npc by left clicking (where possible) otherwise right clicking. if (getMouse().isOnCursor(yourNpcHere)) { if (getMouse().getOnCursorCount() < 2) { getMouse().click(false); } else { yourNpcHere.interact(); } } Quote Link to comment Share on other sites More sharing options...
ExtraBotz Posted April 27, 2020 Share Posted April 27, 2020 If your problem is with NPC.interact() failing then don’t you think the Mouse API might fail too? NPC npc = getNpcs.closest(“name”); if(npc != null) { If(npc.interact(“Bank”)) { // sleep until the bank interface is open } else { // handle the failure } Wouldnt it be easier with interacting with the specific NPC option like above? Code might not be exact, I wrote that off the top of my head. Quote Link to comment Share on other sites More sharing options...