#Give item on receiving status effect

16 messages · Page 1 of 1 (latest)

sage salmon
#

Is there a way to give a player an item when they receive a specific status effect? I'd like to give participating players a reward item when they complete a raid, and the best way I can think to do that is to give it to them upon receiving Hero of the Village.

pliant fieldBOT
#

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

snow bolt
#

if you only want to give it once, you could listen for the advancement to be triggered. Another option is to modify the loot table's for the villagers on what their gift is that they give to the hero of the village

sage salmon
#

The goal is to give a single progression item (a netherite ingot for example) each time a raid is completed.

snow bolt
#

there is a forge event when an effect is added to an entity

#

so you could check for it to be a player, and be the correct effect, and then give the item

snow bolt
#

in startup_scripts:

const $MobEffects = Java.loadClass('net.minecraft.world.effect.MobEffects')

ForgeEvents.onEvent('net.minecraftforge.event.entity.living.MobEffectEvent$Added', event => {
    const { entity, effectInstance } = event
    if (entity.isPlayer()) {
        if (effectInstance.effect == $MobEffects.HERO_OF_THE_VILLAGE) {
            entity.give("minecraft:netherite_ingot")
        }
    }
})
sage salmon
#

You're an actual life-saver, thank you! I was trying to muddle through figuring out which forge event it would be (let alone how to reference it) and trying to use kubejs debugging to get info as a relative noob was not helping 😂

This makes a lot of sense, though!

snow bolt
#

I keep a copy of forge code so I can just pop it open in an ide and search for what I'm looking for 😄

#

suppose you could do it with github search as well, but I'm not the biggest fan since it only searches the default branch

sage salmon
#

I've just started dipping my toe into dev through kubeJS this past month and a half for modpack work so I have no idea where anything is or what does what yet 😂

snow bolt
#

you pick up a lot hanging out in here

sage salmon
#

Only thing I've got going for me is a background in HTML/CSS and some computer-science independent study so I can read code snippets and usually go "ah yes, I see what's happening"

#

Just tested the script and it worked flawlessly! Thanks again! anne7

snow bolt
#

no problem