Java Code Examples for net.minecraft.entity.EntityLivingBase#removePotionEffect()

The following examples show how to use net.minecraft.entity.EntityLivingBase#removePotionEffect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VanillaWares.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleSpiderNightVision(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(Items.SPIDER_EYE)))
	{
		e.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, Integer.MAX_VALUE, -53, true, false));
	}
	else
	{
		PotionEffect effect = e.getActivePotionEffect(MobEffects.NIGHT_VISION);
		if (effect != null && effect.getAmplifier() == -53)
		{
			e.removePotionEffect(MobEffects.NIGHT_VISION);
		}
	}
}
 
Example 2
Source File: ItemCybereyeUpgrade.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleNightVision(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	ItemStack testItem = new ItemStack(this, 1, 0);
	if (CyberwareAPI.isCyberwareInstalled(e, testItem) && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(e, testItem)))
	{

		e.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, Integer.MAX_VALUE, 53, true, false));
	}
	else
	{
		PotionEffect effect = e.getActivePotionEffect(MobEffects.NIGHT_VISION);
		if (effect != null && effect.getAmplifier() == 53)
		{
			e.removePotionEffect(MobEffects.NIGHT_VISION);
		}
	}
}
 
Example 3
Source File: ItemCyberheart.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent(priority=EventPriority.HIGHEST)
public void power(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	ItemStack test = new ItemStack(this);
	if (e.ticksExisted % 20 == 0 && CyberwareAPI.isCyberwareInstalled(e, test))
	{
		if (!CyberwareAPI.getCapability(e).usePower(test, getPowerConsumption(test)))
		{
			e.attackEntityFrom(EssentialsMissingHandler.heartless, Integer.MAX_VALUE);
		}
	}
	
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this)))
	{
		e.removePotionEffect(MobEffects.WEAKNESS);
	}
}
 
Example 4
Source File: PotionGoldenHeart.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
public void performEffect(EntityLivingBase entityLivingBaseIn, int amplifier) {
  if(entityLivingBaseIn instanceof EntityPlayer){
	  for(Potion potion : ForgeRegistries.POTIONS.getValuesCollection()){
		  if(potion.isBadEffect()&&potion!=ForgeRegistries.POTIONS.getValue(new ResourceLocation("minecraft", "nausea"))) entityLivingBaseIn.removePotionEffect(potion);
	  }
  }
}
 
Example 5
Source File: AntiEffectsMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
  EntityLivingBase living = event.getEntityLiving();
  if (living.equals(MC.player)) {
    living.setInvisible(false);
    living.removePotionEffect(MobEffects.NAUSEA);
    living.removePotionEffect(MobEffects.INVISIBILITY);
    living.removePotionEffect(MobEffects.BLINDNESS);
    // removes particle effect
    FastReflection.Methods.EntityLivingBase_resetPotionEffectMetadata.invoke(living);
  } else if (no_particles.get()) {
    living.setInvisible(false);
    FastReflection.Methods.EntityLivingBase_resetPotionEffectMetadata.invoke(living);
  }
}
 
Example 6
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void handleImportantEntityTicks(EntityLivingBase e) {
	if (e.hurtTime > 0) {
		e.hurtTime--;
	}
	if (e.hurtResistantTime > 0) {
		e.hurtResistantTime--;
	}

	e.prevLimbSwingAmount = e.limbSwingAmount;
	e.prevRenderYawOffset = e.renderYawOffset;
	e.prevRotationPitch = e.rotationPitch;
	e.prevRotationYaw = e.rotationYaw;
	e.prevRotationYawHead = e.rotationYawHead;
	e.prevSwingProgress = e.swingProgress;
	e.prevDistanceWalkedModified = e.distanceWalkedModified;
	e.prevCameraPitch = e.cameraPitch;

	if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) {
		PotionEffect pe = e.getActivePotionEffect(ModPotions.TIME_SLOW);
		if (!pe.onUpdate(e)) {
			if (!e.world.isRemote) {
				e.removePotionEffect(ModPotions.TIME_SLOW);
			}
		}
	}

	if(e instanceof EntityDragon) {
		IPhase phase = ((EntityDragon) e).getPhaseManager().getCurrentPhase();
		if(phase.getType() != PhaseList.HOLDING_PATTERN && phase.getType() != PhaseList.DYING) {
			((EntityDragon) e).getPhaseManager().setPhase(PhaseList.HOLDING_PATTERN);
		}
	}
}
 
Example 7
Source File: ItemCybereyes.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
public void handleBlindnessImmunity(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this)))
	{
		e.removePotionEffect(MobEffects.BLINDNESS);
	}
	
}