Jump to content

mikestah

Members
  • Posts

    2
  • Joined

  • Last visited

mikestah's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I'm new to modding, but I'm trying to make a mod that replaces the hunger effect with weakness. It should check if the player has received the hunger effect, then add a weakness effect of equal strength/duration, and then remove the hunger effect. However, for some reason it won't remove the hunger effect. I'm really hoping someone can explain why it doesn't work and give criticism if I have any bad practices. Below is the event handler class. Thanks in advance! @Mod.EventBusSubscriber(modid = StahTweaks.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ModClientEvents { @SubscribeEvent /** Theoretically checks if the effect gained is hunger and then replaces * it with a weakness effect of equal strength */ public static void onPlayerHungerEffect(PotionEvent.PotionAddedEvent event) { LivingEntity player = event.getEntityLiving(); EffectInstance effect = event.getPotionEffect(); if(effect.getPotion().equals(Effects.HUNGER)) { player.addPotionEffect(new EffectInstance(Effects.WEAKNESS, effect.getDuration(), effect.getAmplifier())); player.removePotionEffect(Effects.HUNGER); } } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.