Auxilor / EcoEnchants

Custom Enchantments Plugin for the latest minecraft version
GNU General Public License v3.0
253 stars 148 forks source link

Effect elytra_boost_save_chance chance not working #359

Closed WobbyChip closed 1 year ago

WobbyChip commented 1 year ago

Describe the bug Effect elytra_boost_save_chance chance only works with 100%, otherwise, fireworks will be consumed always.

To Reproduce

  1. Enchant elytra to "Rocket Saver"
  2. Try flying and using fireworks. (fireworks will always be consumed)
  3. Change chance inside rocket_saver.yml to 100.
  4. Now fireworks will not be consumed.

Expected behavior Fireworks should not be consumed always when the percentage is below 100%.

Server Information (please complete the following information):

WobbyChip commented 1 year ago

I think I found the issue, I am not sure, but I assume if modifier.multiplier is the chance passed in the yml, then this makes sense, since chance *= (100 - 99) will still be 100, when chance *= (100 - 100) will be 0. And in this case, a chance for a rocket to not be consumed must be below 100: NumberUtils.randFloat(0.0, 100.0) > chance.

EffectElytraBoostSaveChance.kt

fun handle(event: PlayerElytraBoostEvent) {
    if (McmmoManager.isFake(event)) {
        return
    }

    val player = event.player

    var chance = 100.0

    for (modifier in (modifiers[player.uniqueId] ?: emptyList())) {
        chance *= (100 - modifier.multiplier)
    }

    if (NumberUtils.randFloat(0.0, 100.0) > chance) {
        event.setShouldConsume(false)
    }
}
WobbyChip commented 1 year ago

fixed in EffectElytraBoostSaveChance.kt