#giving player potion effects from eating foods using server_scripts script
23 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
(ignore the file name) this is what i got so far and nothing...
Paste version of greg_edible_server.js from @silver vine
you dont have player defined anywhere in your code
uh okay... that would be a good start
xD
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
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)
})
any real difference?
also... what does the " 100, 1, false, true" define at the end of the potion effect?
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
god send, thank you
ItemEvents.foodEaten("minecraft:bread", event => {
event.player.potionEffects.add("minecraft:poison", 100, 1)
})

amazing, thank you so much, this is exactly what i needed, after spending too long trying to figure it out
no worries :)
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.
if i wanna stack multiple effects, do i whats in the {}?
yeah just add another line