mineflayer icon indicating copy to clipboard operation
mineflayer copied to clipboard

villager trade() improvement request

Open Hiradpi opened this issue 2 months ago • 0 comments

Is your feature request related to a problem?

This issue is related to the villager trade() function and putSelectedItemRange()

Describe the solution you'd like

work on it and try to make it better

Describe alternatives you've considered

Additional context

Server villagers and trade automation issues

This server uses villagers with infinite trades instead of shops. Unfortunately, the deposit() and putRequirements() functions don't support loops. This creates problems when my bot's inventory is full of carrots.

Looping these functions requires manually setting trade quantities instead of automatic retrieval. For example, if the bot has 8 extra carrots and the carrot price is 10, using these functions with a loop can crash .

Additionally, the transfer() function, which calls putSelectedItemRange, can glitch randomly. insted of joining the items together it just tosses them

Main Issue:

When trading with a villager example: (10 carrots for 4 emeralds) and the bot has 60 carrots, the script in villager.js on line 160 needs to run 6 times (count argument) trading 10 carrots each. However, sending too many trade packets quickly can lead to a kick on strict servers. and somehow when used in loops it can cause crashes and desyncs and please insted of getting the item from the trade's inputItem1 add an argument to the trade() that gets the item (the whole slot item value for example, (bot.inventory.items[9] ) )

please consider improving this function ❤️

Hiradpi avatar Apr 26 '24 15:04 Hiradpi