MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"Creates an effect that makes the player and their armor immune to lightning damage"
/* This mod creates an effect that makes the player and their armor immune to lightning damage. */ public class LightningImmunityEffect extends Effect { public LightningImmunityEffect() { super(EffectType.BENEFICIAL, 0xFFFFFF); // White color } @Override public void applyEffectTick(LivingEntity entity, int amplifier) { if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; /* Make player immune to lightning */ player.addEffect(new MobEffectInstance(Effects.LIGHTNING_RESISTANCE, 20 * 10, 0, false, false)); /* Make player's armor immune to lightning */ for (ItemStack stack : player.getArmorSlots()) { if (!stack.isEmpty()) { stack.addEffect(new MobEffectInstance(Effects.LIGHTNING_RESISTANCE, 20 * 10, 0, false, false)); } } } } @Override public boolean isDurationEffectTick(int duration, int amplifier) { return true; // This makes the effect tick every second } } /* Register this effect in your mod's effects registry. */