#giving player potion effects from eating foods using server_scripts script

23 messages · Page 1 of 1 (latest)

silver vine
#

I'm trying to use server scripts since its more flexible and i've been having a hard time with startup scripts.

slender siloBOT
#

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

silver vine
warped cryptBOT
#

Paste version of greg_edible_server.js from @silver vine

languid igloo
#

you dont have player defined anywhere in your code

silver vine
#

uh okay... that would be a good start

languid igloo
#

xD

silver vine
#

what would be best way to define player in this script

#

i am... trying so hard to learn kubeJS and have almost no js knowledge

languid igloo
#

choose between:

ItemEvents.foodEaten("minecraft:bread", event => { 
    event.player.potionEffects.add("minecraft:poison", 100, 1, false, true)
})
ItemEvents.foodEaten("minecraft:bread", event => {
    let { player } = event
    player.potionEffects.add("minecraft:poison", 100, 1, false, true)
})
silver vine
#

any real difference?

#

also... what does the " 100, 1, false, true" define at the end of the potion effect?

languid igloo
#
    public void add(Holder<MobEffect> mobEffect, int duration, int amplifier, boolean ambient, boolean showParticles) {
        entity.addEffect(new MobEffectInstance(mobEffect, duration, amplifier, ambient, showParticles));
    }
#

you can get rid of the booleans, false and true are the default values

silver vine
#

god send, thank you

languid igloo
#
ItemEvents.foodEaten("minecraft:bread", event => { 
    event.player.potionEffects.add("minecraft:poison", 100, 1)
})
silver vine
#

amazing, thank you so much, this is exactly what i needed, after spending too long trying to figure it out

languid igloo
#

no worries :)

warped cryptBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue!
This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You should create a new post for unrelated issues.

silver vine
#

if i wanna stack multiple effects, do i whats in the {}?

languid igloo
#

yeah just add another line