MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"Creates an effect that reduces the strength and speed of the player hit."
/* This code creates a mod that applies a potion effect to the player when they are hit, reducing their strength and speed. */ public class WeakeningEffect extends Effect { public WeakeningEffect() { super(EffectType.HARMFUL, 0x660066); // The color is purple } @Override public void applyEffectTick(LivingEntity entity, int amplifier) { if (entity instanceof PlayerEntity) { entity.addEffect(new MobEffectInstance(MobEffects.WEAKNESS, 200, amplifier)); // Reduces strength entity.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 200, amplifier)); // Reduces speed } } @Override public boolean isDurationEffectTick(int duration, int amplifier) { return true; // This ensures the effect is applied every tick } } /* You will need to register your effect in your main mod file or a dedicated registry class. */ public static final RegistryObject<Effect> WEAKENING_EFFECT = EFFECTS.register("weakening_effect", WeakeningEffect::new);