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

The following are Jave code examples for showing how to use addPotionEffect() 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: DecompiledMinecraft   File: ItemAppleGold.java   View Source Code Vote up 6 votes
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    if (!worldIn.isRemote)
    {
        player.addPotionEffect(new PotionEffect(Potion.absorption.id, 2400, 0));
    }

    if (stack.getMetadata() > 0)
    {
        if (!worldIn.isRemote)
        {
            player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 4));
            player.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
            player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
        }
    }
    else
    {
        super.onFoodEaten(stack, worldIn, player);
    }
}
 
Example 2
Project: Melodium   File: SongHunt.java   View Source Code Vote up 6 votes
@Override
public void songEnded(EntityPlayer player, ItemStack instrument, int interval) {
	World world = player.world;
	int radius = 15;
	AxisAlignedBB area = new AxisAlignedBB(player.posX - radius, player.posY - radius, player.posZ - radius,
			player.posX + radius, player.posY + radius, player.posZ + radius);
	List<Entity> mobs = world.getEntitiesWithinAABBExcludingEntity(player, area);
	for (Entity e : mobs) {
		if (e instanceof EntityLivingBase) {
			String key = EntityList.getEntityString(e);

			if (effects.containsKey(key)) {
				Potion p = effects.get(key);
				PotionEffect effect = new PotionEffect(p, (interval) * 20 * 6000);
				player.addPotionEffect(effect);
				return;
			}
		}
	}
}
 
Example 3
Project: FirstAid   File: ConstantDebuff.java   View Source Code Vote up 6 votes
@Override
public void update(EntityPlayer player, float healthPerMax) {
    if (!this.isEnabled.getAsBoolean()) return;
    if (activeMultiplier == 0) {
        ticks = 0;
    } else {
        if (ticks == 0) {
            if (healthPerMax != -1)
                syncMultiplier(healthPerMax); //There are apparently some cases where the multiplier does not sync up right... fix this
            if (activeMultiplier != 0)
                player.addPotionEffect(new PotionEffect(effect, 240, activeMultiplier - 1, false, false));
        }
        ticks++;
        if (ticks >= 200) ticks = 0;
    }
}
 
Example 4
Project: harshencastle   File: HandlerTotemOfUndying.java   View Source Code Vote up 6 votes
@HarshenEvent
public void PlayerDeath(LivingDeathEvent event)
{
	EntityPlayer player = (EntityPlayer) event.getEntity();
	event.setCanceled(true);
	if (player instanceof EntityPlayerMP)
	{
           EntityPlayerMP entityplayermp = (EntityPlayerMP)player;
           entityplayermp.addStat(StatList.getObjectUseStats(Items.TOTEM_OF_UNDYING));
           CriteriaTriggers.USED_TOTEM.trigger(entityplayermp, HarshenUtils.getFirstOccuringItem(player, Items.TOTEM_OF_UNDYING));
       }
	
	HarshenUtils.setStackInSlot(player, Items.TOTEM_OF_UNDYING, ItemStack.EMPTY);
	player.setHealth(1.0F);
	player.clearActivePotions();
	player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
	player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1));
	player.world.setEntityState(player, (byte)35);
}
 
Example 5
Project: ProgressiveDifficulty   File: WeakGazeModifier.java   View Source Code Vote up 5 votes
@Override
public void handleUpkeepEvent(int numChanges, EntityLiving entity) {
    if(entity.getAttackTarget() instanceof EntityPlayer && entity.canEntityBeSeen(entity.getAttackTarget())){
        EntityPlayer player = (EntityPlayer)entity.getAttackTarget();
        player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS,MobUpkeepController.POTION_EFFECT_LENGTH,numChanges,false,true));
    }
}
 
Example 6
Project: DecompiledMinecraft   File: ItemPotion.java   View Source Code Vote up 5 votes
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        List<PotionEffect> list = this.getEffects(stack);

        if (list != null)
        {
            for (PotionEffect potioneffect : list)
            {
                playerIn.addPotionEffect(new PotionEffect(potioneffect));
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);

    if (!playerIn.capabilities.isCreativeMode)
    {
        if (stack.stackSize <= 0)
        {
            return new ItemStack(Items.glass_bottle);
        }

        playerIn.inventory.addItemStackToInventory(new ItemStack(Items.glass_bottle));
    }

    return stack;
}
 
Example 7
Project: Mods   File: ItemChargingTarge.java   View Source Code Vote up 5 votes
@Override
public ActionResult<ItemStack> onItemRightClick( World world, EntityPlayer living, EnumHand hand) {
	//if (!living.getCapability(TF2weapons.WEAPONS_CAP, null).effectsCool.containsKey("Charging")) {
	ItemStack stack=living.getHeldItem(hand);
		if (!world.isRemote)
			living.addPotionEffect(new PotionEffect(TF2weapons.charging, 40));
		living.getCooldownTracker().setCooldown(this, (int) (280f/TF2Attribute.getModifier("Charge Recharge", stack, 1, living)));
		//living.getCapability(TF2weapons.WEAPONS_CAP, null).effectsCool.put("Charging", 280);
	//}
	return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
 
Example 8
Project: MagicWinds   File: ToolTestSword.java   View Source Code Vote up 5 votes
@Override
public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player) {
        player.addPotionEffect(new PotionEffect(Potion.getPotionById(15), 100, 2));
        EntityLightningBolt lightningBolt = new EntityLightningBolt(player.world, 5, 5 ,5,false);
        lightningBolt.setPosition(player.posX, player.posY, player.posZ);
        player.world.spawnEntity(lightningBolt);
    return super.onDroppedByPlayer(item, player);
}
 
Example 9
Project: BaseClient   File: TileEntityBeacon.java   View Source Code Vote up 5 votes
private void addEffectsToPlayers()
{
    if (this.isComplete && this.levels > 0 && !this.worldObj.isRemote && this.primaryEffect > 0)
    {
        double d0 = (double)(this.levels * 10 + 10);
        int i = 0;

        if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect)
        {
            i = 1;
        }

        int j = this.pos.getX();
        int k = this.pos.getY();
        int l = this.pos.getZ();
        AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double)j, (double)k, (double)l, (double)(j + 1), (double)(k + 1), (double)(l + 1))).expand(d0, d0, d0).addCoord(0.0D, (double)this.worldObj.getHeight(), 0.0D);
        List<EntityPlayer> list = this.worldObj.<EntityPlayer>getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);

        for (EntityPlayer entityplayer : list)
        {
            entityplayer.addPotionEffect(new PotionEffect(this.primaryEffect, 180, i, true, true));
        }

        if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect > 0)
        {
            for (EntityPlayer entityplayer1 : list)
            {
                entityplayer1.addPotionEffect(new PotionEffect(this.secondaryEffect, 180, 0, true, true));
            }
        }
    }
}
 
Example 10
Project: BaseClient   File: TileEntityBeacon.java   View Source Code Vote up 5 votes
private void addEffectsToPlayers()
{
    if (this.isComplete && this.levels > 0 && !this.worldObj.isRemote && this.primaryEffect > 0)
    {
        double d0 = (double)(this.levels * 10 + 10);
        int i = 0;

        if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect)
        {
            i = 1;
        }

        int j = this.pos.getX();
        int k = this.pos.getY();
        int l = this.pos.getZ();
        AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double)j, (double)k, (double)l, (double)(j + 1), (double)(k + 1), (double)(l + 1))).expand(d0, d0, d0).addCoord(0.0D, (double)this.worldObj.getHeight(), 0.0D);
        List<EntityPlayer> list = this.worldObj.<EntityPlayer>getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);

        for (EntityPlayer entityplayer : list)
        {
            entityplayer.addPotionEffect(new PotionEffect(this.primaryEffect, 180, i, true, true));
        }

        if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect > 0)
        {
            for (EntityPlayer entityplayer1 : list)
            {
                entityplayer1.addPotionEffect(new PotionEffect(this.secondaryEffect, 180, 0, true, true));
            }
        }
    }
}
 
Example 11
Project: Bewitchment   File: ItemCrop.java   View Source Code Vote up 5 votes
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
	if (!worldIn.isRemote && potions != null) {
		final int modifier = isDry(stack) ? 160 : 80;
		for (Potion effect : potions) {
			player.addPotionEffect(new PotionEffect(effect, modifier, modifier / 80));
		}
	}
}
 
Example 12
Project: CustomWorldGen   File: TileEntityBeacon.java   View Source Code Vote up 5 votes
private void addEffectsToPlayers()
{
    if (this.isComplete && this.levels > 0 && !this.worldObj.isRemote && this.primaryEffect != null)
    {
        double d0 = (double)(this.levels * 10 + 10);
        int i = 0;

        if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect)
        {
            i = 1;
        }

        int j = (9 + this.levels * 2) * 20;
        int k = this.pos.getX();
        int l = this.pos.getY();
        int i1 = this.pos.getZ();
        AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double)k, (double)l, (double)i1, (double)(k + 1), (double)(l + 1), (double)(i1 + 1))).expandXyz(d0).addCoord(0.0D, (double)this.worldObj.getHeight(), 0.0D);
        List<EntityPlayer> list = this.worldObj.<EntityPlayer>getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);

        for (EntityPlayer entityplayer : list)
        {
            entityplayer.addPotionEffect(new PotionEffect(this.primaryEffect, j, i, true, true));
        }

        if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null)
        {
            for (EntityPlayer entityplayer1 : list)
            {
                entityplayer1.addPotionEffect(new PotionEffect(this.secondaryEffect, j, 0, true, true));
            }
        }
    }
}
 
Example 13
Project: harshencastle   File: ZombieEye.java   View Source Code Vote up 5 votes
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    if (!worldIn.isRemote)
    {
        
            player.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 100, 0));
            player.addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, 310, 0));
            player.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 50, 0));
    }
}
 
Example 14
Project: Melodium   File: SongInvisible.java   View Source Code Vote up 5 votes
@Override
public boolean songTick(EntityPlayer player, ItemStack instrument, int interval, int ticks, int length) {
	if (interval > 0) {
		player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 2, 1));
	}
	return true;
}
 
Example 15
Project: harshencastle   File: OneRing.java   View Source Code Vote up 4 votes
@Override
public void onTick(EntityPlayer player, int tick) {
	player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 7, 0, false, false));
}
 
Example 16
Project: Bewitchment   File: ItemHoney.java   View Source Code Vote up 4 votes
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
	player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 450, 0));
	player.addPotionEffect(new PotionEffect(MobEffects.LUCK, 450, 0));
}
 
Example 17
Project: Bewitchment   File: ItemAsphodel.java   View Source Code Vote up 4 votes
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
	player.addPotionEffect(new PotionEffect(MobEffects.UNLUCK, 10, 0));
}
 
Example 18
Project: harshencastle   File: PontusRing.java   View Source Code Vote up 4 votes
@Override
public void onTick(EntityPlayer player, int tick) {
	player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 100, 0, false, false));
}
 
Example 19
Project: rtap   File: foodRamenCold.java   View Source Code Vote up 2 votes
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
	
	player.addPotionEffect(new PotionEffect(Potion.getPotionById(2), 200, 0));
	
}
 
Example 20
Project: rtap   File: foodBologna.java   View Source Code Vote up 2 votes
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
	
	player.addPotionEffect(new PotionEffect(Potion.getPotionById(21), 1, 0));
	
}