Skip to content

Commit

Permalink
Fix 1.17 & 1.18 effect names (#101)
Browse files Browse the repository at this point in the history
* Fix 1.17 & 1.18 effect names

* Remove unused variable
  • Loading branch information
killbinvlog committed Jul 16, 2023
1 parent 73f6bed commit cc7ae73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
36 changes: 6 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,33 +646,10 @@ function getEnchantmentLevel (mcData, enchantmentName, enchantments) {
return 0
}

function getStatusEffectNamesForVersion (supportFeature) {
if (supportFeature('effectNamesAreRegistryNames')) {
return {
jumpBoostEffectName: 'jump_boost',
speedEffectName: 'speed',
slownessEffectName: 'slowness',
dolphinsGraceEffectName: 'dolphins_grace',
slowFallingEffectName: 'slow_falling',
levitationEffectName: 'levitation'
}
} else {
return {
jumpBoostEffectName: 'JumpBoost',
speedEffectName: 'Speed',
slownessEffectName: 'Slowness',
dolphinsGraceEffectName: 'DolphinsGrace',
slowFallingEffectName: 'SlowFalling',
levitationEffectName: 'Levitation'
}
}
}

class PlayerState {
constructor (bot, control) {
const mcData = require('minecraft-data')(bot.version)
const nbt = require('prismarine-nbt')
const supportFeature = makeSupportFeature(mcData)

// Input / Outputs
this.pos = bot.entity.position.clone()
Expand All @@ -694,15 +671,14 @@ class PlayerState {

// effects
const effects = bot.entity.effects
const statusEffectNames = getStatusEffectNamesForVersion(supportFeature)

this.jumpBoost = getEffectLevel(mcData, statusEffectNames.jumpBoostEffectName, effects)
this.speed = getEffectLevel(mcData, statusEffectNames.speedEffectName, effects)
this.slowness = getEffectLevel(mcData, statusEffectNames.slownessEffectName, effects)
this.jumpBoost = getEffectLevel(mcData, 'JumpBoost', effects)
this.speed = getEffectLevel(mcData, 'Speed', effects)
this.slowness = getEffectLevel(mcData, 'Slowness', effects)

this.dolphinsGrace = getEffectLevel(mcData, statusEffectNames.dolphinsGraceEffectName, effects)
this.slowFalling = getEffectLevel(mcData, statusEffectNames.slowFallingEffectName, effects)
this.levitation = getEffectLevel(mcData, statusEffectNames.levitationEffectName, effects)
this.dolphinsGrace = getEffectLevel(mcData, 'DolphinsGrace', effects)
this.slowFalling = getEffectLevel(mcData, 'SlowFalling', effects)
this.levitation = getEffectLevel(mcData, 'Levitation', effects)

// armour enchantments
const boots = bot.inventory.slots[8]
Expand Down
5 changes: 0 additions & 5 deletions lib/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,5 @@
"name": "climbUsingJump",
"description": "Entity can climb ladders and vines by pressing jump",
"versions": ["1.14", "1.15", "1.17", "1.18"]
},
{
"name": "effectNamesAreRegistryNames",
"description": "Status effect names equal to their registry names",
"versions": ["1.17", "1.18"]
}
]

0 comments on commit cc7ae73

Please sign in to comment.