PrismarineJS / prismarine-block

Represent a minecraft block with its associated data
29 stars 31 forks source link

digTime wrong since 1.20.5 #102

Open tabbry opened 3 weeks ago

tabbry commented 3 weeks ago

Problem first discovered in mineflayer-tool when playing MC 1.20.6 as it was no longer able to determine the best tool, due to wrong digTime calculation. It seemed like it made the calculation for digTime = 900 for dirt no matter the tool.

Using following test by appending /test/basic.test.js revealed that the problem seems to have been introduced with 1.20.5 as 1.20.4 seems to just work fine.

describe('Dig time', () => {
  describe('1.20.5', () => {
    const registry = require('prismarine-registry')('1.20.5')
    const Block = require('prismarine-block')(registry)
    it('dig dirt (shovel faster than hand)', () => {
      const dirt = Block.fromStateId(registry.blocksByName.dirt.defaultState, 0)
      const shovel = registry.itemsByName.iron_shovel
      const handTime = dirt.digTime(null, false, false, false)
      const shovelTime = dirt.digTime(shovel.id, false, false, false)
      expect(shovelTime < handTime).toBeTruthy()
    })
  })
  ...
})
rom1504 commented 3 weeks ago

that's probably due to incorrect data. Can you take a look @GroobleDierne ?

@tabbry can you open a PR with that test?

tabbry commented 3 weeks ago

Thank you @rom1504 for checking my comment. I created a PR: https://github.com/PrismarineJS/prismarine-block/pull/103. Please note, that this is my first PR in a public repo, in case I missed something...