MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create an effect that makes me completely invisible to monsters"
/* This mod creates an effect that makes the player completely invisible to monsters. */ public class InvisibleToMonstersEffect extends Effect { public InvisibleToMonstersEffect() { super(EffectType.BENEFICIAL, 0xffffff); } @Override public void applyEffectTick(LivingEntity entity, int amplifier) { if (entity instanceof PlayerEntity) { for (MobEntity mob : entity.level.getEntitiesOfClass(MobEntity.class, entity.getBoundingBox().inflate(10.0D))) { mob.setTarget(null); } } } @Override public boolean isDurationEffectTick(int duration, int amplifier) { return true; // This will make the effect apply every tick } } /* Don't forget to register your effect in your mod's registry event. */