so basically i made an event that checks if the player is crouching. If you are crouching, you get 2 potion effects. This worked, but when i released shift the potion effects still appeared on my gui, though the effects weren't doing anything. How do i fix this?
package com.watizdat.mysterymod.events;
import com.watizdat.mysterymod.MysteryMod;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraftforge.client.event.InputUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
@Mod.EventBusSubscriber(modid = MysteryMod.MOD_ID, bus = Bus.FORGE)
public class PlayerSneakEvent {
@SubscribeEvent
public static void playerSneakEvent(InputUpdateEvent event){
if(event.getMovementInput().sneaking) {
System.out.println("hello");
LivingEntity livingEntity = event.getEntityLiving();
livingEntity.addPotionEffect(new EffectInstance(Effects.STRENGTH, 20, 2));
livingEntity.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 20, 2));
}
}
}