• 0

    posted a message on How do I apply potion effects on hit while under the effect of a potion?

    I am trying to make two status effects that will be applied to custom potions in my mod:

    • The first status effect will apply slowness and weakness to any entity hit while the player is under the effect of the custom status effect.
    • The second will make entities that attack the player take the same amount of damage as they have dealt to the player while they are under the custom status effect (similar to how Thorns works in vanilla).

    My issue is I can't figure out how to make an effect that interacts with other entities while the player is under that effect. I've made a Java Class for the first status effect that will apply Slowness and Weakness periodically to the player while they have the parent effect,, but obviously I want this to apply to hit entities instead while the player has the custom effect:

    import net.minecraft.entity.LivingEntity;
    import net.minecraft.entity.effect.StatusEffect;
    import net.minecraft.entity.effect.StatusEffectCategory;
    import net.minecraft.entity.effect.StatusEffectInstance;
    import net.minecraft.entity.effect.StatusEffects;
    
    public class BlizzardEffect extends StatusEffect {
        public BlizzardEffect(StatusEffectCategory statusEffectCategory, int color) {
            super(statusEffectCategory, color);
        }
    
        @Override
        public void applyUpdateEffect(LivingEntity target, int pAmplifier) {
            target.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 200, 1 ));
            target.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 200, 1 ));
            super.applyUpdateEffect(target, pAmplifier);
        }
    
        @Override
        public boolean canApplyUpdateEffect(int pDuration, int pAmplifier) {
            return true;
        }
    }


    Any insight would be appreciated.

    Posted in: Modification Development
  • To post a comment, please .