#Double Effect Duration

3 messages · Page 1 of 1 (latest)

humble storm
#

I want to double the duration of mining fatigue normally it lasts 5 minutes but I want it to last 10 minutes, the main problem is that I have other means (potions, mobs, enchants etc) to get mining fatigue and I want this to be applied globally so basically all instances of mining fatigue last 2 times more

errant stirrupBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

humble storm
#

solved with this code:

/**@param {Internal.MobEffectEvent$Applicable} event*/
global.miningDoubled = event => {
    const $MobEffects = Java.loadClass("net.minecraft.world.effect.MobEffects")
    const $EffectInstance = Java.loadClass("net.minecraft.world.effect.MobEffectInstance")
    const {entity, effectInstance:{effect, amplifier, duration, ambient, visible}} = event
    if(effect.equals($MobEffects.DIG_SLOWDOWN) && !entity.persistentData.isDoubled) {
        event.setResult("deny")
        entity.persistentData.putBoolean('isDoubled', true)
        Utils.server.scheduleInTicks(20, () => {
        entity.persistentData.remove('isDoubled')
        })
        entity.addEffect(new $EffectInstance(effect, duration * 2, amplifier, ambient, visible))
    }
}```