Java Code Examples for net.minecraft.entity.player.EntityPlayer.removePotionEffect()

The following are Jave code examples for showing how to use removePotionEffect() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Bewitchment   File: ItemRemedyTalisman.java   View Source Code Vote up 6 votes
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
	if (player.ticksExisted % 40 == 0 && player instanceof EntityPlayer) {
		EntityPlayer p = (EntityPlayer) player;
		boolean flag = p.getActivePotionEffect(MobEffects.POISON) != null || p.getActivePotionEffect(MobEffects.NAUSEA) != null || p.getActivePotionEffect(MobEffects.WITHER) != null || p.getActivePotionEffect(MobEffects.BLINDNESS) != null || p.getActivePotionEffect(MobEffects.WEAKNESS) != null;
		p.removePotionEffect(MobEffects.NAUSEA);
		p.removePotionEffect(MobEffects.WITHER);
		p.removePotionEffect(MobEffects.BLINDNESS);
		p.removePotionEffect(MobEffects.POISON);
		p.removePotionEffect(MobEffects.WEAKNESS);
		if (flag) {
			itemstack.setItemDamage(itemstack.getItemDamage() + 1);
			if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) {
				itemstack.setCount(0);
			}
		}
	}
}
 
Example 2
Project: ToughExpansion   File: ItemThirstQuencher.java   View Source Code Vote up 5 votes
private void doTick(Entity entity, ItemStack stack) {
	if (entity instanceof EntityPlayer && SyncedConfig.getBooleanValue(GameplayOption.ENABLE_THIRST)) {
		int energyPerTick = Options.THIRST_QUNCHER_RF_PER_TICK;
		if (getEnergyStored(stack) < energyPerTick || getFluidStored(stack) < 100) {
			return;
		}
		EntityPlayer player = (EntityPlayer) entity;
		ThirstHandler thirstHandler = (ThirstHandler) ThirstHelper.getThirstData(player);
		int currentThirst = thirstHandler.getThirst();
		int currentTime = getTime(stack);
		if (currentThirst < 20) {
			if (currentTime <= 0) {
				player.removePotionEffect(TANPotions.thirst);
				if (currentThirst < 20) {
					thirstHandler.setThirst(currentThirst + 1);
					thirstHandler.setHydration(5.0F);
					thirstHandler.setExhaustion(0.0F);
				}
				drainFluid(stack, 100);
				setTime(stack, 50);
				setEnergyStored(stack, getEnergyStored(stack) - energyPerTick);
			}
			else {
				setTime(stack, currentTime - 1);
				setEnergyStored(stack, getEnergyStored(stack) - energyPerTick);
			}
		}
		else {
			if (getTime(stack) != 50) {
				setTime(stack, 50);
			}
		}
	}
}
 
Example 3
Project: TrustCircle   File: Events.java   View Source Code Vote up 4 votes
@SubscribeEvent
public void onPlayerUpdate(LivingUpdateEvent event){
    EntityLivingBase entity = event.getEntityLiving();
    if(entity != null && !entity.worldObj.isRemote && entity instanceof EntityPlayer){
        EntityPlayer player = (EntityPlayer)entity;
        if(player.worldObj.getTotalWorldTime()%TrustCircle.updateInterval == 0){
            double modifier = 0;

            for(EntityPlayer other : player.worldObj.playerEntities){
                if(other != player && !other.isSpectator()){
                    if(doesTeamWork(player.getTeam(), other.getTeam())){
                        double dist = other.getDistanceSq(player.posX, player.posY, player.posZ);
                        if(dist <= TrustCircle.maxRange*TrustCircle.maxRange){
                            double mod = dist <= 0 ? 1 : (1/Math.sqrt(dist));
                            modifier += mod*TrustCircle.baseCalcModifier;

                            if(!TrustCircle.allowMultiplePlayers){
                                break;
                            }
                        }
                    }
                }
            }

            if(modifier > 0){
                int amplifier = Math.min(3, MathHelper.ceiling_double_int(modifier*TrustCircle.amplifierModifier)-1);
                int duration = Math.max(TrustCircle.updateInterval+1, MathHelper.ceiling_double_int(modifier*TrustCircle.durationModifier));

                PotionEffect active = player.getActivePotionEffect(TrustCircle.potionTrust);
                boolean ampChange = active != null && active.getAmplifier() != amplifier;
                if(active == null || ampChange || active.getDuration() <= TrustCircle.updateInterval){
                    if(ampChange){
                        player.removePotionEffect(TrustCircle.potionTrust);
                    }

                    player.addPotionEffect(new PotionEffect(TrustCircle.potionTrust, duration, amplifier, true, true));
                }
            }
        }
    }
}
 
Example 4
Project: ToughExpansion   File: ItemTempRegulator.java   View Source Code Vote up 4 votes
private void doTick(Entity entity, ItemStack stack) {
	init(stack);
	int energy = Options.PORTABLE_TEMP_REGULATOR_RF_PER_TICK;
	if (entity instanceof EntityPlayer && SyncedConfig.getBooleanValue(GameplayOption.ENABLE_TEMPERATURE)) {
		if (getEnergyStored(stack) < energy) {
			return;
		}

		EntityPlayer player = (EntityPlayer) entity;
		TemperatureHandler tempHandler = (TemperatureHandler) TemperatureHelper.getTemperatureData(player);
		//float temp = (float) MathUtils.clamp(tempHandler.debugger.targetTemperature, 0, TemperatureScale.getScaleTotal()) / (float) TemperatureScale.getScaleTotal();
		ITemperature data = TemperatureHelper.getTemperatureData(player);
		Temperature playerTemp = data.getTemperature();
		int currentTemp = playerTemp.getRawValue();
		int currentTime = getTime(stack);
		if (currentTemp != 14) {
			if (currentTime <= 0) {
				tempHandler.setChangeTime(0);
				player.removePotionEffect(TANPotions.hypothermia);
				player.removePotionEffect(TANPotions.hyperthermia);
				if (currentTemp < 14) {
					tempHandler.setTemperature(new Temperature(currentTemp + 1));
				}
				else if (currentTemp > 14) {
					tempHandler.setTemperature(new Temperature(currentTemp - 1));
				}
				setTime(stack, 100);
				setEnergyStored(stack, getEnergyStored(stack) - energy);
			}
			else {
				setTime(stack, currentTime - 1);
				setEnergyStored(stack, getEnergyStored(stack) - energy);
			}
		}
		else {
			if (getTime(stack) != 100) {
				setTime(stack, 100);
			}
		}
	}
}
 
Example 5
Project: ToughExpansion   File: TileTempRegulator.java   View Source Code Vote up 4 votes
@Override
public void update() {
	if (getWorld() != null) {
		IBlockState state = getWorld().getBlockState(pos);
		state.getBlock().updateTick(getWorld(), getPos(), state, getWorld().rand);
	}
	if (!isRunning() || getWorld() == null || getEnergyStored(null) < ENERGY_USE) {
		return;
	}

	BlockPos negPos = new BlockPos(getPos().getX() - Options.TEMP_REGULATOR_RADIUS, 0, getPos().getZ() - Options.TEMP_REGULATOR_RADIUS);
	BlockPos posPos = new BlockPos(getPos().getX() + Options.TEMP_REGULATOR_RADIUS, 255, getPos().getZ() + Options.TEMP_REGULATOR_RADIUS);
	List<EntityPlayer> playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(negPos, posPos));
	if (playerList.size() > 0) {
		for (EntityPlayer player : playerList) {
			TemperatureHandler tempHandler = (TemperatureHandler) TemperatureHelper.getTemperatureData(player);
			ITemperature data = TemperatureHelper.getTemperatureData(player);
			Temperature playerTemp = data.getTemperature();
			int currentTemp = playerTemp.getRawValue();
			int currentTime = getTime(player);
			if (currentTemp != 14) {
				if (getTime(player) <= 0) {
					player.removePotionEffect(TANPotions.hypothermia);
					player.removePotionEffect(TANPotions.hyperthermia);
					if (currentTemp < 14) {
						tempHandler.setTemperature(new Temperature(currentTemp + 1));
					}
					else if (currentTemp > 14) {
						tempHandler.setTemperature(new Temperature(currentTemp - 1));
					}
					setTime(player, 100);
					setEnergyStored(getEnergyStored() - ENERGY_USE);
				}
				else {
					setTime(player, currentTime - 1);
					setEnergyStored(getEnergyStored() - ENERGY_USE);
				}
			}
			else {
				removePlayerTimer(player);
			}
		}
	}

}