I got it now, thank you diesieben07 for the fast reply and help. I didn't really take the route diesieben07 suggested going about it but the code below worked as well and because of that, issues may arise, only time will tell though.
Code for anyone interested:
package net.dascraft.init;
import net.dascraft.Dascraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class DascraftEventHooks
{
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event)
{
if (event.entityLiving.isPotionActive(Dascraft.protectionPotion))
{
if (event.entityLiving.worldObj.rand.nextInt(20) == 0)
{
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.entityLiving;
player.capabilities.allowEdit = false;
player.sendPlayerAbilities();
}
}
PotionEffect effect = event.entityLiving.getActivePotionEffect(Dascraft.protectionPotion);
if (effect.onUpdate(event.entityLiving) && effect.getDuration() == 1)
{
System.out.println("DOES IT WORK? YES IT DOES.");
EntityPlayer player = (EntityPlayer) event.entityLiving;
player.capabilities.allowEdit = true;
player.sendPlayerAbilities();
return;
}
}
}
}