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

itemDrop event firing twice for each item drop #3491

Closed
1 task done
reecelikesramen opened this issue Oct 29, 2024 · 1 comment
Closed
1 task done

itemDrop event firing twice for each item drop #3491

reecelikesramen opened this issue Oct 29, 2024 · 1 comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@reecelikesramen
Copy link

reecelikesramen commented Oct 29, 2024

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

Versions

  • mineflayer: 4.23.0
  • server: vanilla (LAN) 1.20.4
  • node: v20.18.0

Detailed description of a problem

I am working on a project extending MineDojo/Voyager. Tried using the itemDrop event to keep track of what items the bot collected after a mob kill. The events are double counting the drops. For instance if a chicken dies and drops 1 chicken, the itemDrop event will fire twice. It double counts each itemdrop entity.

Your current code

    /* entity is defined above as the entity that died */

    function onItemDrop(item) {
      if (entity.position.distanceTo(item.position) <= 1) {
        bot.chat("Item dropped!")
      }
    }

    bot.on("itemDrop", onItemDrop)

Expected behavior

  • itemDrop should fire once for each itemstack entity dropped upon an entity's death
@reecelikesramen reecelikesramen 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 Oct 29, 2024
@reecelikesramen
Copy link
Author

itemDrop AND playerCollect also fire when experience is dropped/collected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

1 participant