PrismarineJS / mineflayer

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

no support for compass on bungeecoord #844

Open antiaim opened 5 years ago

antiaim commented 5 years ago

Versions

mineflayer@2.9.0 minecraft-data@2.37.5 minecraft-protocol@1.9.0 server: bungeecord, not sure exactly but think its a 1.14 snapshot

Detailed description of a problem

I'm currently trying to make the bot use a server selector. Selecting the compass item and clicking it seems to work, logging the window shows a normal ContainerWindow with the item i need to click. However, I cannot click on the slot. Using bot.equip on a ContainerWindow (9 slots) does nothing. Attempting to use bot.clickWindow on the same window does nothing too, and callback is undefined.

Current code

bot.on('login', () => {
    console.log("Spawned in")      
    setInterval(resetMessageLimit, 1000)
    sleep(2000)
    console.log("Activating item")
    bot.activateItem()
    sleep(2000)       
    setInterval(update, 1000)
})           
bot.on("windowOpen", window => {
    setTimeout(function() {
        console.log("Clicking window slot")  //doing console.log(window) prints a normal ContainerWindow     
        var axe = window.slots[2] //get Item instance from the window slot
        bot.equip(axe, "hand") //however, this does nothing            
    }, 2000)               
})                    

Expected behavior

For the bot to click the 3rd slot in the window.

Additional context

rom1504 commented 5 years ago

how did you try to click on the slot ?

antiaim commented 5 years ago

how did you try to click on the slot ?

I tried bot.equip(axe, "hand") with axe being an Item instance from the window, and bot.clickWindow(2, 0, 0, function(cb) {console.log(cb)}), but neither do anything, and the callback for clickWindow is undefined.

rom1504 commented 5 years ago

A callback takes two argument. The first is the error, the second is the result. Check the second argument value.

Are you sure that 2 is the correct value for your slot ?

On Sun, Aug 4, 2019, 14:48 antiaim notifications@github.com wrote:

how did you try to click on the slot ?

I tried bot.equip(axe, "hand") with axe being an Item instance from the window, and bot.clickWindow(2, 0, 0, function(cb) {console.log(cb)}), but neither do anything, and the callback for clickWindow is undefined.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/844?email_source=notifications&email_token=AAR437QEFLGKHXAGT2GNJ3DQC3FYVA5CNFSM4IJD7B72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QBD4Q#issuecomment-518001138, or mute the thread https://github.com/notifications/unsubscribe-auth/AAR437RKJP2C24SAUNDPZGLQC3FYVANCNFSM4IJD7B7Q .

antiaim commented 5 years ago

I'm trying to click the 3rd slot in the window. function(error, result) returns undefined for both.

I've also tried bot.clickWindow(3, 0, 0).

rom1504 commented 5 years ago

Try to check the difference between what's sent by vanilla client and what's sent with mineflayer (use node-minecraft-protocol proxy and debug mode for this)

antiaim commented 5 years ago

minecraft-protocol read packet play.set_slot +0ms minecraft-protocol { minecraft-protocol "windowId": 1, minecraft-protocol "slot": 2, minecraft-protocol "item": { minecraft-protocol "blockId": 279, minecraft-protocol "itemCount": 1, minecraft-protocol "itemDamage": 0, minecraft-protocol "nbtData": { minecraft-protocol "type": "compound", minecraft-protocol "name": "", minecraft-protocol "value": { minecraft-protocol "display": { minecraft-protocol "type": "compound", minecraft-protocol "value": { minecraft-protocol "Lore": { minecraft-protocol "type": "list", minecraft-protocol "value": { minecraft-protocol "type": "string", minecraft-protocol "value": [ minecraft-protocol "§7Click to enter §aCreative§7 server" minecraft-protocol ] minecraft-protocol } minecraft-protocol }, minecraft-protocol "Name": { minecraft-protocol "type": "string", minecraft-protocol "value": "§a§lCreative Plots§f(516x516)" minecraft-protocol } minecraft-protocol } minecraft-protocol } minecraft-protocol } minecraft-protocol } minecraft-protocol } minecraft-protocol } +0ms

read packet play.close_window +0ms minecraft-protocol { minecraft-protocol "windowId": 1 minecraft-protocol } +0ms

Clicking window slot minecraft-protocol writing packet play.window_click +37ms minecraft-protocol { windowId: 0, minecraft-protocol slot: 2, minecraft-protocol mouseButton: 0, minecraft-protocol action: 0, minecraft-protocol mode: 0, minecraft-protocol item: { blockId: -1 } } +0ms

^using debug mode considering these are in order(and even if they are not) it seems like the mineflayer client is closing the opened window before attempting to click it.

I will update for vanilla client in a moment

rom1504 commented 5 years ago

well you can already see the issue, the window was closed...

antiaim commented 5 years ago

Update, I fixed the closed window issue by removing the timeout - however, the click on the window still doesn't seem to register