PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.96k stars 904 forks source link

Go to Specific coordinates, and click to an Block. #1133

Closed noxomix closed 4 years ago

noxomix commented 4 years ago

Versions

Detailed description of a question

Hello, I have a Problem:

I want to build a Minecraft Bot with Mineflayer, wich operates on a big Minecraft Network.

The Problem: After Joining the "Bungeecord Hub", the Bot have to click to a Skin (Plugin Generated (Armor-stand-like?)-skin).. So my Question is: How to go to specific coordinates, watch to a Specific Block an right/left click it. Is this any possible? Pls :) Thanks.

Edit: Other Users have the Same Question Here , but never solved...

noxomix commented 4 years ago

Sry I have seen that 4 other people has opened the Same. But does Somebody of them have found a solution??

rom1504 commented 4 years ago

https://github.com/Karang/mineflayer-pathfinder + activateBlock

noxomix commented 4 years ago

https://github.com/Karang/mineflayer-pathfinder + activateBlock

Yes Thanks. But the Issue was the same as the Issues about the NPC wich one have to click on Bausucht.net ... and If I can read, I think that nobody has find a solution. activateBlock doesnt work in this case.

mh...

This: #939 And #826 has the same problem.

rom1504 commented 4 years ago

can you use https://github.com/PrismarineJS/node-minecraft-protocol/tree/master/examples/proxy to find the packet sent by the client to do that kind of "click" ?

noxomix commented 4 years ago

Okay tahnk you I'll test it soon. ;)

noxomix commented 4 years ago

Hey, sry If I ask again, but the Proxy.js doesnt work for me. I dont know but there Isnt a Output + error.

I have cloned it from Github, run NPM I an basicly started in Powershell, (node proxy.js bausucht.net 1.15.2) -> then I startet my Minecraft Client in Vanilla 1.15.2 , and connect to localhost:25566, but then come up a "error" or "end" in Minecraft.

Other whise I have understand proxy.js false :/

rom1504 commented 4 years ago

Did you also start a vanilla server ?

On Sat, Jul 11, 2020, 21:06 hallofcode notifications@github.com wrote:

Hey, sry If I ask again, but the Proxy.js doesnt work for me. I dont know but there Isnt a Output + error.

I have cloned it from Github, run NPM I an basicly started in Powershell, (node proxy.js bausucht.net 1.15.2) -> then I startet my Minecraft Client in Vanilla 1.15.2 , and connect to localhost:25566, but then come up a "error" or "end" in Minecraft.

Other whise I have understand proxy.js false :/

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/1133#issuecomment-657113256, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437UIV7E7QBDMFVKENPLR3CZ45ANCNFSM4OXJJMWA .

noxomix commented 4 years ago

How did you mean?

1. Clone Minecraft Protcol Repo

  1. npm i

  2. cd examles/Proxy

  3. Npm i

  4. node proxy.js --dump-all bausucht.net 1.15.2

  5. Open Minecraft Client 1.15.2 Join localhost:25566

Error: Ingame Shows Up "End" oder "Error" , in CMD IT Shows "Server End Connection" + "Client End Connection".

rom1504 commented 4 years ago

This is a proxy, it works between a server and a client. You need to start the server the client and the proxy

On Sat, Jul 11, 2020, 21:37 hallofcode notifications@github.com wrote:

How did you mean?

1.

Clone Minecraft Protcol Repo

1.

npm i 2.

cd examles/Proxy 3.

Npm i 4.

node proxy.js --dump-all bausucht.net 1.15.2 5.

Open Minecraft Client 1.15.2 Join localhost:25566

Error: Ingame Shows Up "End" oder "Error" , in CMD IT Shows "Server End Connection" + "Client End Connection".

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/1133#issuecomment-657117764, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437QUGSTU5ISR3GWYF4LR3C5OVANCNFSM4OXJJMWA .

noxomix commented 4 years ago

Okay,

But I can Connect over the Proxy to Bausucht.net?

Or could I have to reacreate the NPC - Bukkit Plugin to Get the "Click"-Packet??

So Like that: Client -> LocalServer -> Proxy -> Bausucht.net

No what my brain is going to sleep...

Sry today im rly Lost :D

Karang commented 4 years ago

The proxy connect in offline mode: that's probably your issue. You can try to modify the proxy.js file to add a password to connect to your server in online mode: https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/examples/proxy/proxy.js#L97

noxomix commented 4 years ago

Ou okay yes thats my Problem thanks.

I'll try it tommorow thx.

noxomix commented 4 years ago

So, now I think I've get the Protocol Code for that click.

client->server: play use_entity : {"target":19,"mouse":2,"x":0.19320209324359894,"y":1.119981288909912,"z":-0.30000001192092896,"hand":0}
client->server: play use_entity : {"target":19,"mouse":0,"hand":0}
client->server: play use_entity : {"target":19,"mouse":2,"x":0.19320209324359894,"y":1.119981288909912,"z":-0.30000001192092896,"hand":1}
client->server: play use_entity : {"target":19,"mouse":0,"hand":1}

So how do I implement this into my mineflayer scrip :) ?

Karang commented 4 years ago

You can tweak this function : https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/inventory.js#L223 It seems to be sending the 2 types of use_entity packet (interact: mouse=0 and interactAt: mouse=2) mineflayer support only the interact version, but you could add the interactAt version (and make a PR) https://wiki.vg/Protocol#Interact_Entity

In the interactAt version, you need to specify the position of your click

noxomix commented 4 years ago

Thanks for your Help.

It works for now. Hopfully Stable.

I've used bot._client.write(...) Directly in the Bot Script.

Thx ;)

Karang commented 4 years ago

Could you make a PR to mineflayer to improve the activateEntity function ?

noxomix commented 4 years ago

Yes of course! I do ist tomorrow.

One other Question: Has the Pathfinder any function that goes to Specific coordinates by Running IT Once?

Because the Near-function goes every execution +1, so If I want to go from 0,0,0 to 0,0,10 I have to run this 10 Times.

TheDudeFromCI commented 4 years ago

@hall-of-code You mean new GoalNear(x, y, z, 10)?

noxomix commented 4 years ago

Yes.

Ou I think the Last Param ist the "steps"-paramter ? GoalNear(10, 25, 198, 7); //Is the "7" the Param wich defines the "steps"-lenght?

Sry my brain 😅

Karang commented 4 years ago

No the last parameter is the radius of the goal. The x, y, z can be 1000s of blocks away, it will go to any block that is within a circle of given radius around x, y, z.

noxomix commented 4 years ago

Ah okay. Thx

I have editet the inventory.js -- but I forgot to click "pull Request". I hope thats okay?