mineflayer icon indicating copy to clipboard operation
mineflayer copied to clipboard

Fixed the enchantment table "ready" event, which has been broken for years.

Open zisis912 opened this issue 2 years ago • 10 comments

What used to happen was that the "ready" event would get emitted when all the level values were above 0, however 0 means that a packet hasnt been sent yet

image image

zisis912 avatar Jul 26 '23 14:07 zisis912

very cool yeah getting enchantment name by string is just way more convenient also nice fix :p

pokahs avatar Jul 26 '23 14:07 pokahs

Please seperate this pr into two seperate prs, since it has two distinctly different changes.

u9g avatar Jul 26 '23 14:07 u9g

One thing I am worried about is that the packets for level could be sent before the packets for expected.enchant, resulting in something like

[
  { level: 5, expected: { enchant: 'unbreaking', level: -1 } },
  { level: 11, expected: { enchant: null, level: -1 } },
  { level: 30, expected: { enchant: null, level: -1 } }
]

Does anyone know the order with which the packets get sent? Maybe it would be smarter to make the "ready" event reliant on expected.level, depending on the order of the packets

zisis912 avatar Jul 26 '23 14:07 zisis912

Please seperate this pr into two seperate prs, since it has two distinctly different changes.

i dont know how to do that 😭 I made a commit to my fork and it got auto-added to the pull request

I think it's okay if we keep this as a 2 in 1, just a general enchanting library fix and overhaul to modernise it.

zisis912 avatar Jul 26 '23 14:07 zisis912

After some stress testing I saw that its possible for the level to update without the expected.level updating, so I made sure to change the condition to check for the latter.

image

zisis912 avatar Jul 26 '23 14:07 zisis912

Please seperate this pr into two seperate prs, since it has two distinctly different changes.

i dont know how to do that 😭 I made a commit to my fork and it got auto-added to the pull request

I think it's okay if we keep this as a 2 in 1, just a general enchanting library fix and overhaul to modernise it.

That's exactly the problem, the "overhaul" is a breaking change to anyone who uses this now.

u9g avatar Jul 26 '23 17:07 u9g

Please seperate this pr into two seperate prs, since it has two distinctly different changes.

i dont know how to do that 😭 I made a commit to my fork and it got auto-added to the pull request

I think it's okay if we keep this as a 2 in 1, just a general enchanting library fix and overhaul to modernise it.

That's exactly the problem, the "overhaul" is a breaking change to anyone who uses this now.

JavaScript is a language that requires one to actively update their code to the newest documentation, atleast as far as web development goes. I don't think this would go against that principle.

Also I would like to mention that there is not a single person that used the enchanting library, since it was broken this whole time. Think of this as a new feature getting added, instead of an old one being modified. Enchanting did not really exist in a usable form up to this point.

And the few people that did use it are certainly smart and involved enough to know where the issue lies

zisis912 avatar Jul 26 '23 20:07 zisis912

1.8.8 enchanting test is failing can you please fix it ?

rom1504 avatar Jul 29 '23 08:07 rom1504