Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some items are not appearing in the slots - (Possibly resolved) #3354

Open
1 task done
XaviscoB opened this issue Apr 20, 2024 · 3 comments
Open
1 task done

Some items are not appearing in the slots - (Possibly resolved) #3354

XaviscoB opened this issue Apr 20, 2024 · 3 comments

Comments

@XaviscoB
Copy link

XaviscoB commented Apr 20, 2024

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.20.1
  • server: spigot 1.8.9
  • node: 20.11.1

Detailed description of a problem

Whenever the compass is right-clicked, it opens a custom window, similar to opening a chest. However, the slots in the window returned by the Event are only those of the inventories and not of the chest itself.

What did you try yet?

Did you try any method from the API?

Yes

Did you try any example? Any error from those?

No

Your current code

bot.on('respawn', async () => {

    console.log(`Player Position (ReSpawn): ${bot.entity.position}`)

    if (bot.heldItem !== null) {
        if (bot.heldItem.name == 'compass') {

            await bot.waitForChunksToLoad()
            bot.activateItem(offHand=false)

        }
    }
})

bot.on('windowOpen', (window) => {

    console.log(window.slots)

})

Expected behavior

Expected Output =>

[
  Item {...},
  null,
  Item {...},
  null,
  Item {...},
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  Item {
    type: 345,
    count: 1,
    metadata: 0,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'compass',
    displayName: 'Compass',
    stackSize: 64,
    maxDurability: undefined,
    slot: 54
  },
  null,
  Item {
    type: 397,
    count: 1,
    metadata: 3,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'skull',
    displayName: 'Head',
    stackSize: 64,
    maxDurability: undefined,
    slot: 56
  },
  null,
  Item {
    type: 377,
    count: 1,
    metadata: 0,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'blaze_powder',
    displayName: 'Blaze Powder',
    stackSize: 64,
    maxDurability: undefined,
    slot: 58
  },
  null,
  Item {
    type: 399,
    count: 1,
    metadata: 0,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'nether_star',
    displayName: 'Nether Star',
    stackSize: 64,
    maxDurability: undefined,
    slot: 60
  },
  null,
  Item {
    type: 351,
    count: 1,
    metadata: 8,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'dye',
    displayName: 'Gray Dye',
    stackSize: 64,
    maxDurability: undefined,
    slot: 62
  }
]

Output provided by the event =>

[
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  Item {
    type: 345,
    count: 1,
    metadata: 0,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'compass',
    displayName: 'Compass',
    stackSize: 64,
    maxDurability: undefined,
    slot: 54
  },
  null,
  Item {
    type: 397,
    count: 1,
    metadata: 3,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'skull',
    displayName: 'Head',
    stackSize: 64,
    maxDurability: undefined,
    slot: 56
  },
  null,
  Item {
    type: 377,
    count: 1,
    metadata: 0,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'blaze_powder',
    displayName: 'Blaze Powder',
    stackSize: 64,
    maxDurability: undefined,
    slot: 58
  },
  null,
  Item {
    type: 399,
    count: 1,
    metadata: 0,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'nether_star',
    displayName: 'Nether Star',
    stackSize: 64,
    maxDurability: undefined,
    slot: 60
  },
  null,
  Item {
    type: 351,
    count: 1,
    metadata: 8,
    nbt: { type: 'compound', name: '', value: [Object] },
    stackId: null,
    name: 'dye',
    displayName: 'Gray Dye',
    stackSize: 64,
    maxDurability: undefined,
    slot: 62
  }
]
@XaviscoB XaviscoB added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Apr 20, 2024
@XaviscoB XaviscoB changed the title Some items are not appearing in the slots Some items are not appearing in the slots - Windows Apr 20, 2024
@XaviscoB
Copy link
Author

So, I did a little tinkering here and there, and I was analyzing the packets being sent directly and I ended up realizing that the server is sending as expected, so much so that when I pull it directly using this method:

bot._client.on('window_items', (window) => {
   console.log(window)
})

it is possible to see the items that when pulled by the "Window" return of event "WindowOpen", appear only as null

image

@XaviscoB XaviscoB changed the title Some items are not appearing in the slots - Windows Some items are not appearing in the slots - (Possibly resolved) Apr 21, 2024
@extremeheat
Copy link
Member

extremeheat commented Apr 26, 2024

This is not valid javascript:

            bot.activateItem(offHand=false)

What this is doing is declaring an offHand variable in the global scope, as it's not pre-defined with var or let within the current scope, and then that's being passed to the function. Also, activateItem returns a promise that you must await.

I don't understand what you mean here: "However, the slots in the window returned by the Event are only those of the inventories and not of the chest itself."

Where is the expected output coming from? Are you saying it's returning the bot inventory or one half of the chest?

You can log a full object without truncation by using console.dir(obj, { depth: null })

@extremeheat extremeheat added waiting info from op question and removed possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Apr 26, 2024
@XaviscoB
Copy link
Author

This is not valid javascript:

            bot.activateItem(offHand=false)

What this is doing is declaring an offHand variable in the global scope, as it's not pre-defined with var or let within the current scope, and then that's being passed to the function. Also, activateItem returns a promise that you must await.

I don't understand what you mean here: "However, the slots in the window returned by the Event are only those of the inventories and not of the chest itself."

Where is the expected output coming from? Are you saying it's returning the bot inventory or one half of the chest?

You can log a full object without truncation by using console.dir(obj, { depth: null })

As can be seen in the previous messages and prints, whenever the bot interacts with the "Compass" item, it opens a Windows, as if it were a Chest, but, when I receive the event using the WindowOpen, it only shows the items that are present in the inventory and not those that should be in the "Chest"

image

But if I receive it directly, using the "window_items" event from minecraft-protocol, it already shows these items as can be seen below

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants