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

effectLevel is not working #16

Closed
Sklinay opened this issue Aug 29, 2020 · 1 comment
Closed

effectLevel is not working #16

Sklinay opened this issue Aug 29, 2020 · 1 comment

Comments

@Sklinay
Copy link

Sklinay commented Aug 29, 2020

const e = effects[effectsByName[effect]]

Hello,

I think that the effectLevel function is not working properly (at least in 1.16.1)

 function effectLevel (effect, effects) {
    const e = effects[effectsByName[effect]]
    return e ? e.amplifier : -1
  }

Content of effects (in my case) from
https://github.com/PrismarineJS/mineflayer/blob/8f729c2f00620b3277dcebd510e5c4b278413d32/lib/plugins/digging.js#L104 :

{
  '3': { id: 3, amplifier: 1, duration: 340 },
  '10': { id: 10, amplifier: 0, duration: 340 },
  '11': { id: 11, amplifier: 0, duration: 340 }
}

Content of effectsByName

{
  Speed: { id: 1, name: 'Speed', displayName: 'Speed', type: 'good' },
  Slowness: { id: 2, name: 'Slowness', displayName: 'Slowness', type: 'bad' },
  Haste: { id: 3, name: 'Haste', displayName: 'Haste', type: 'good' },
  MiningFatigue: {
    id: 4,
    name: 'MiningFatigue',
    displayName: 'Mining Fatigue',
    type: 'bad'
  },
  Strength: { id: 5, name: 'Strength', displayName: 'Strength', type: 'good' },
  InstantHealth: {
    id: 6,
    name: 'InstantHealth',
    displayName: 'Instant Health',
    type: 'good'
  },
......

effects[effectsByName[effect]] is equal to null. It needs the id of the effect.
The fix would be effects[effectsByName[effect].id]

function effectLevel (effect, effects) {
  const e = effects[effectsByName[effect].id]	
  return e ? e.amplifier : -1
}

Bye

Naomi-alt added a commit to Naomi-alt/prismarine-block that referenced this issue Dec 18, 2020
@rom1504
Copy link
Member

rom1504 commented Jan 1, 2021

fixed now

@rom1504 rom1504 closed this as completed Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants