#Make a mob emit potions effects in a radius

5 messages · Page 1 of 1 (latest)

river sinew
#

Howdy! Is there an efficient way to have a mob apply potion effects in a radius like the elder guardian's mining fatigue? The elder guardian checks for players once every minute, so i imagine that there must be some way to add that logic to any mob, but i haven't been able to find any examples out there. It appears to be possible with commands, but I'd like to avoid having kubeJS running commands if i could do it in javascript.

I know i could probably add logic from the player perspective to constantly check for if a certain mob is nearby, but that would probably create some lag to have it constantly checking even when the mob isn't anywhere nearby. I'd like to have the logic from the mob's perspective so that the check only needs to happen when that mob is loaded.

foggy rockBOT
#

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

true trellis
amber fulcrumBOT
#

[➤](#1241969379327868980 message)

StartupEvents.registry('mob_effect', e => {
    e.create('dist_check')
    .beneficial()
    .effectTick((entity, level) =>{
        if(!entity || entity.level.isClientSide() || entity.age % 20) return;

        let timer = 0
        Utils.server.players.forEach(player => {
            timer++;
            Utils.server.scheduleInTicks(timer, ()=>{if(!entity.closerThan(player, 30, 30)) entity.setRemoved('unloaded_to_chunk')});
        });
    });
});
true trellis
#

not sure how vanilla's working