Java Code Examples for net.minecraft.potion.PotionEffect

The following are top voted examples for showing how to use net.minecraft.potion.PotionEffect. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CustomWorldGen   File: EntityTippedArrow.java   Source Code and License 6 votes vote down vote up
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("Potion", 8))
    {
        this.potion = PotionUtils.getPotionTypeFromNBT(compound);
    }

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound))
    {
        this.addEffect(potioneffect);
    }

    if (this.potion != PotionTypes.EMPTY || !this.customPotionEffects.isEmpty())
    {
        this.dataManager.set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, this.customPotionEffects))));
    }
}
 
Example 2
Project: Soot   File: CaskManager.java   Source Code and License 6 votes vote down vote up
public void applyEffects(EntityLivingBase target, EntityLivingBase source, EntityLivingBase indirectsource) {
    for (CaskPotionEffect effect : effects)
    {
        PotionEffect potioneffect = effect.potionEffect;
        PotionEffect currentStack = target.getActivePotionEffect(potioneffect.getPotion());
        if (potioneffect.getPotion().isInstant())
        {
            potioneffect.getPotion().affectEntity(source, indirectsource, target, potioneffect.getAmplifier(), 1.0D);
        }
        else
        {
            int amplifier = currentStack.getAmplifier();
            int duration = currentStack.getDuration();
            if(currentStack != null)
            {
                amplifier = Math.min(amplifier + currentStack.getAmplifier() + 1,effect.maxStack);
                if(amplifier != currentStack.getAmplifier())
                    duration += currentStack.getDuration();
            }
            PotionEffect newStack = new PotionEffect(potioneffect.getPotion(),duration,amplifier,false,false); //TODO: curative item?? alchemical hangover cure???
            target.addPotionEffect(newStack);
        }
    }
}
 
Example 3
Project: connor41-etfuturum2   File: EntityLingeringEffect.java   Source Code and License 6 votes vote down vote up
@Override
public void applyEntityCollision(Entity e) {
	if (!(e instanceof EntityLivingBase))
		return;
	EntityLivingBase entity = (EntityLivingBase) e;
	List<PotionEffect> effects = ((LingeringPotion) ModItems.lingering_potion).getEffects(stack);
	boolean addedEffect = false;

	for (PotionEffect effect : effects) {
		int effectID = effect.getPotionID();
		if (Potion.potionTypes[effectID].isInstant()) {
			Potion.potionTypes[effectID].affectEntity(thrower, entity, effect.getAmplifier(), 0.25);
			addedEffect = true;
		} else if (!entity.isPotionActive(effectID)) {
			entity.addPotionEffect(effect);
			addedEffect = true;
		}
	}

	if (addedEffect) {
		int ticks = dataWatcher.getWatchableObjectInt(TICKS_DATA_WATCHER);
		if (setTickCount(ticks + 5 * 20)) // Add 5 seconds to the expiration time (decreasing radius by 0.5 blocks)
			return;
	}
}
 
Example 4
Project: BetterBeginningsReborn   File: RegisterItems.java   Source Code and License 6 votes vote down vote up
public static void tweakVanilla()
{
	((ItemFood) Items.BEEF).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 20);
	((ItemFood) Items.PORKCHOP).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 25);
	((ItemFood) Items.FISH).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30, 1), 60); // Both fish types here
	((ItemFood) Items.MUTTON).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 25);
	((ItemFood) Items.RABBIT).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 30);

	if(BBConfig.makeStuffStackable)
	{
		// Let's face it, the vanilla stack sizes for these suck.
		Items.MINECART.setMaxStackSize(16);
		// Strangely enough the oak one doesn't change name.
		Items.OAK_DOOR.setMaxStackSize(16);
		Items.SPRUCE_DOOR.setMaxStackSize(16);
		Items.BIRCH_DOOR.setMaxStackSize(16);
		Items.ACACIA_DOOR.setMaxStackSize(16);
		Items.DARK_OAK_DOOR.setMaxStackSize(16);
		Items.IRON_DOOR.setMaxStackSize(16);
	}

	if(BBConfig.moduleFurnaces) Items.FURNACE_MINECART.setUnlocalizedName(ModMain.MODID + ".kilnCart");
}
 
Example 5
Project: Backmemed   File: EntityTippedArrow.java   Source Code and License 6 votes vote down vote up
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("Potion", 8))
    {
        this.potion = PotionUtils.getPotionTypeFromNBT(compound);
    }

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound))
    {
        this.addEffect(potioneffect);
    }

    if (compound.hasKey("Color", 99))
    {
        this.func_191507_d(compound.getInteger("Color"));
    }
    else
    {
        this.func_190548_o();
    }
}
 
Example 6
Project: Backmemed   File: ItemAppleGold.java   Source Code and License 6 votes vote down vote up
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    if (!worldIn.isRemote)
    {
        if (stack.getMetadata() > 0)
        {
            player.addStat(AchievementList.OVERPOWERED);
            player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
            player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 6000, 0));
            player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 6000, 0));
            player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 3));
        }
        else
        {
            player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 100, 1));
            player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 0));
        }
    }
}
 
Example 7
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
public void fall(float distance, float damageMultiplier)
{
    super.fall(distance, damageMultiplier);
    PotionEffect potioneffect = this.getActivePotionEffect(Potion.jump);
    float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F;
    int i = MathHelper.ceiling_float_int((distance - 3.0F - f) * damageMultiplier);

    if (i > 0)
    {
        this.playSound(this.getFallSoundString(i), 1.0F, 1.0F);
        this.attackEntityFrom(DamageSource.fall, (float)i);
        int j = MathHelper.floor_double(this.posX);
        int k = MathHelper.floor_double(this.posY - 0.20000000298023224D);
        int l = MathHelper.floor_double(this.posZ);
        Block block = this.worldObj.getBlockState(new BlockPos(j, k, l)).getBlock();

        if (block.getMaterial() != Material.air)
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
Example 8
Project: ExPetrum   File: DownStrike.java   Source Code and License 6 votes vote down vote up
@Override
public void onExecutionStart(EntityPlayer player)
{
	ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
	EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
	Vec3d look = player.getLookVec().scale(5);
	Vec3d pos = player.getPositionVector();
	List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
	EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
	if (assumedToBeLookedAt != null)
	{
		if (!player.world.isRemote)
		{
			assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, weight == EnumWeaponWeight.NORMAL ? 20 : 30, 0, false, false));
		}
		
		player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 1F);
		Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
		assumedToBeLookedAt.knockBack(player, 1, pos.x - targetPos.x, pos.z - targetPos.z);
		for (int i = 0; i < 50; ++i)
		{
			player.world.spawnParticle(EnumParticleTypes.CRIT_MAGIC, targetPos.x + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + player.world.rand.nextDouble() - player.world.rand.nextDouble(), 0, -0.1, 0);
		}
	}
}
 
Example 9
Project: connor41-etfuturum2   File: LingeringPotion.java   Source Code and License 6 votes vote down vote up
@Override
public List<PotionEffect> getEffects(ItemStack stack) {
	if (stack.hasTagCompound() && stack.getTagCompound().hasKey("CustomPotionEffects", 9)) {
		List<PotionEffect> list = new ArrayList<PotionEffect>();
		NBTTagList nbttaglist = stack.getTagCompound().getTagList("CustomPotionEffects", 10);

		for (int i = 0; i < nbttaglist.tagCount(); i++) {
			NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
			PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbt);
			if (potioneffect != null)
				list.add(potioneffect);
		}

		return list;
	} else
		return getEffects(stack.getItemDamage());
}
 
Example 10
Project: connor41-etfuturum2   File: LingeringPotion.java   Source Code and License 6 votes vote down vote up
@Override
public String getItemStackDisplayName(ItemStack stack) {
	if (stack.getItemDamage() == 0)
		return StatCollector.translateToLocal("item.emptyPotion.name").trim();
	else {
		String s = StatCollector.translateToLocal("potion.prefix.lingering").trim() + " ";

		List<PotionEffect> list = getEffects(stack);
		String s1;

		if (list != null && !list.isEmpty()) {
			s1 = list.get(0).getEffectName();
			s1 = s1 + ".postfix";
			return s + StatCollector.translateToLocal(s1).trim();
		} else {
			s1 = PotionHelper.func_77905_c(stack.getItemDamage());
			return StatCollector.translateToLocal(s1).trim() + " " + super.getItemStackDisplayName(stack);
		}
	}
}
 
Example 11
Project: BaseClient   File: ItemPotion.java   Source Code and License 6 votes vote down vote up
public boolean isEffectInstant(int meta)
{
    List<PotionEffect> list = this.getEffects(meta);

    if (list != null && !list.isEmpty())
    {
        for (PotionEffect potioneffect : list)
        {
            if (Potion.potionTypes[potioneffect.getPotionID()].isInstant())
            {
                return true;
            }
        }

        return false;
    }
    else
    {
        return false;
    }
}
 
Example 12
Project: Bewitchment   File: OutcastsShameBrew.java   Source Code and License 6 votes vote down vote up
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
	if (amplifier >= 3) {
		if (entity instanceof EntityWitch) {
			entity.setFire(500);
			entity.attackEntityFrom(DamageSource.MAGIC, 20);
		} else if (entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER) {
			entity.addPotionEffect(new PotionEffect(MobEffects.WITHER, 1500, 0));
			entity.attackEntityFrom(DamageSource.MAGIC, 20);
		}
	} else if (amplifier == 2 && entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER || entity instanceof EntityWitch) {
		entity.attackEntityFrom(DamageSource.MAGIC, 16);
	} else if (entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER) {
		entity.attackEntityFrom(DamageSource.MAGIC, 10);
	}
}
 
Example 13
Project: BaseClient   File: ServerConfigurationManager.java   Source Code and License 6 votes vote down vote up
/**
 * moves provided player from overworld to nether or vice versa
 */
public void transferPlayerToDimension(EntityPlayerMP playerIn, int dimension)
{
    int i = playerIn.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.dimension = dimension;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.playerNetServerHandler.sendPacket(new S07PacketRespawn(playerIn.dimension, playerIn.worldObj.getDifficulty(), playerIn.worldObj.getWorldInfo().getTerrainType(), playerIn.theItemInWorldManager.getGameType()));
    worldserver.removePlayerEntityDangerously(playerIn);
    playerIn.isDead = false;
    this.transferEntityToWorld(playerIn, i, worldserver, worldserver1);
    this.preparePlayer(playerIn, worldserver);
    playerIn.playerNetServerHandler.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.theItemInWorldManager.setWorld(worldserver1);
    this.updateTimeAndWeatherForPlayer(playerIn, worldserver1);
    this.syncPlayerInventory(playerIn);

    for (PotionEffect potioneffect : playerIn.getActivePotionEffects())
    {
        playerIn.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), potioneffect));
    }
}
 
Example 14
Project: Backmemed   File: EntityPotion.java   Source Code and License 6 votes vote down vote up
private void func_190542_a(ItemStack p_190542_1_, PotionType p_190542_2_)
{
    EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
    entityareaeffectcloud.setOwner(this.getThrower());
    entityareaeffectcloud.setRadius(3.0F);
    entityareaeffectcloud.setRadiusOnUse(-0.5F);
    entityareaeffectcloud.setWaitTime(10);
    entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float)entityareaeffectcloud.getDuration());
    entityareaeffectcloud.setPotion(p_190542_2_);

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromItem(p_190542_1_))
    {
        entityareaeffectcloud.addEffect(new PotionEffect(potioneffect));
    }

    NBTTagCompound nbttagcompound = p_190542_1_.getTagCompound();

    if (nbttagcompound != null && nbttagcompound.hasKey("CustomPotionColor", 99))
    {
        entityareaeffectcloud.setColor(nbttagcompound.getInteger("CustomPotionColor"));
    }

    this.world.spawnEntityInWorld(entityareaeffectcloud);
}
 
Example 15
Project: harshencastle   File: HandlerTotemOfUndying.java   Source Code and License 6 votes vote down vote up
@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 16
Project: Backmemed   File: EntityShulkerBullet.java   Source Code and License 6 votes vote down vote up
protected void bulletHit(RayTraceResult result)
{
    if (result.entityHit == null)
    {
        ((WorldServer)this.world).spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 2, 0.2D, 0.2D, 0.2D, 0.0D, new int[0]);
        this.playSound(SoundEvents.ENTITY_SHULKER_BULLET_HIT, 1.0F, 1.0F);
    }
    else
    {
        boolean flag = result.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.owner).setProjectile(), 4.0F);

        if (flag)
        {
            this.applyEnchantments(this.owner, result.entityHit);

            if (result.entityHit instanceof EntityLivingBase)
            {
                ((EntityLivingBase)result.entityHit).addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200));
            }
        }
    }

    this.setDead();
}
 
Example 17
Project: CombinedPotions   File: RecipeCombinedPotions2.java   Source Code and License 6 votes vote down vote up
@Override
public ItemStack getCraftingResult(InventoryCrafting inv)
{
	ItemStack outputStack = ItemStack.EMPTY;
	if (countSlotsNotEmpty(inv) <= 1) return outputStack;

	Collection<PotionEffect> effects = new ArrayList<PotionEffect>();

	for (int i = 0; i < inv.getSizeInventory(); i++)
	{
		ItemStack stack = inv.getStackInSlot(i);
		if (!stack.isEmpty())
		{
			if (outputStack.isEmpty()) outputStack = getOutputStack(stack);
			if (outputStack.isEmpty()) return outputStack;

			effects.addAll(getEffectsFromStack(stack));
		}
	}

	outputStack = PotionUtils.appendEffects(outputStack, effects);
	outputStack.setStackDisplayName(I18n.translateToLocal("item.combined_" + outputStack.getItem().getUnlocalizedName().substring(5) + ".name"));

	return outputStack;
}
 
Example 18
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
public void clearActivePotions()
{
    Iterator<Integer> iterator = this.activePotionsMap.keySet().iterator();

    while (iterator.hasNext())
    {
        Integer integer = (Integer)iterator.next();
        PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer);

        if (!this.worldObj.isRemote)
        {
            iterator.remove();
            this.onFinishedPotionEffect(potioneffect);
        }
    }
}
 
Example 19
Project: UniversalRemote   File: EntityPlayerProxy.java   Source Code and License 5 votes vote down vote up
@Override
public void addPotionEffect(PotionEffect potioneffectIn) {
	if (m_realPlayer == null) {
		super.addPotionEffect(potioneffectIn);
	} else {
		m_realPlayer.addPotionEffect(potioneffectIn);
	}
}
 
Example 20
Project: BaseClient   File: ItemFood.java   Source Code and License 5 votes vote down vote up
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    if (!worldIn.isRemote && this.potionId > 0 && worldIn.rand.nextFloat() < this.potionEffectProbability)
    {
        player.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));
    }
}
 
Example 21
Project: Backmemed   File: EntityAreaEffectCloud.java   Source Code and License 5 votes vote down vote up
public EntityAreaEffectCloud(World worldIn)
{
    super(worldIn);
    this.potion = PotionTypes.EMPTY;
    this.effects = Lists.<PotionEffect>newArrayList();
    this.reapplicationDelayMap = Maps.<Entity, Integer>newHashMap();
    this.duration = 600;
    this.waitTime = 20;
    this.reapplicationDelay = 20;
    this.noClip = true;
    this.isImmuneToFire = true;
    this.setRadius(3.0F);
}
 
Example 22
Project: CustomWorldGen   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
    if (this.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
    {
        Potion potion = potioneffectIn.getPotion();

        if (potion == MobEffects.REGENERATION || potion == MobEffects.POISON)
        {
            return false;
        }
    }

    return true;
}
 
Example 23
Project: ProgressiveDifficulty   File: WeakGazeModifier.java   Source Code and License 5 votes vote down vote up
@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 24
Project: Thermionics   File: BlockRoad.java   Source Code and License 5 votes vote down vote up
@Override
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
	if (world.isRemote) return;
	if (entity instanceof EntityLivingBase) {
		EntityLivingBase living = (EntityLivingBase)entity;
		
		living.addPotionEffect(new PotionEffect(Thermionics.POTION_EFFORTLESS_SPEED, 20, level));
	}
}
 
Example 25
Project: ProgressiveDifficulty   File: OnHitEffectModifier.java   Source Code and License 5 votes vote down vote up
@Override
public void handleDamageEvent(LivingAttackEvent event) {
    super.handleDamageEvent(event);
    if(!(event.getEntity() instanceof EntityLivingBase))
        return;
    EntityLivingBase hitEntity = (EntityLivingBase)event.getEntity();
    EntityLiving cause = (EntityLiving)event.getSource().getTrueSource();
    int level = MobNBTHandler.getModifierLevel(cause,identifier);
    hitEntity.addPotionEffect(new PotionEffect(effect, duration,level,false,false));
}
 
Example 26
Project: ProgressiveDifficulty   File: SlowingGazeModifier.java   Source Code and License 5 votes vote down vote up
@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.SLOWNESS,MobUpkeepController.POTION_EFFECT_LENGTH,numChanges,false,true));
    }
}
 
Example 27
Project: UniversalRemote   File: EntityPlayerMPProxy.java   Source Code and License 5 votes vote down vote up
@Override
public PotionEffect removeActivePotionEffect(Potion potioneffectin) {
	if (m_realPlayer == null) {
		return super.removeActivePotionEffect(potioneffectin);
	} else {
		syncToRealPlayer();
		return syncPublicFieldsFromRealAndReturn(m_realPlayer.removeActivePotionEffect(potioneffectin));
	}
}
 
Example 28
Project: connor41-etfuturum2   File: TippedArrow.java   Source Code and License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubItems(Item item, CreativeTabs tab, List list) {
	List<ItemStack> potions = new ArrayList<ItemStack>();
	ModItems.lingering_potion.getSubItems(ModItems.lingering_potion, tab, potions);
	for (ItemStack potion : potions) {
		List<PotionEffect> effects = PotionHelper.getPotionEffects(potion.getItemDamage(), false);
		if (effects != null && !effects.isEmpty())
			for (PotionEffect effect : effects)
				list.add(setEffect(new ItemStack(this), Potion.potionTypes[effect.getPotionID()], effect.getDuration() / 2));
	}
}
 
Example 29
Project: BaseClient   File: EntitySpider.java   Source Code and License 5 votes vote down vote up
/**
 * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
 * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
 */
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)
{
    livingdata = super.onInitialSpawn(difficulty, livingdata);

    if (this.worldObj.rand.nextInt(100) == 0)
    {
        EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj);
        entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
        entityskeleton.onInitialSpawn(difficulty, (IEntityLivingData)null);
        this.worldObj.spawnEntityInWorld(entityskeleton);
        entityskeleton.mountEntity(this);
    }

    if (livingdata == null)
    {
        livingdata = new EntitySpider.GroupData();

        if (this.worldObj.getDifficulty() == EnumDifficulty.HARD && this.worldObj.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty())
        {
            ((EntitySpider.GroupData)livingdata).func_111104_a(this.worldObj.rand);
        }
    }

    if (livingdata instanceof EntitySpider.GroupData)
    {
        int i = ((EntitySpider.GroupData)livingdata).potionEffectId;

        if (i > 0 && Potion.potionTypes[i] != null)
        {
            this.addPotionEffect(new PotionEffect(i, Integer.MAX_VALUE));
        }
    }

    return livingdata;
}
 
Example 30
Project: Bewitchment   File: NotchedBrew.java   Source Code and License 5 votes vote down vote up
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
	entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
	entity.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 6000, 0));
	entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 6000, 0));
	entity.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 3));
}
 
Example 31
Project: Mods   File: ItemSoldierBackpack.java   Source Code and License 5 votes vote down vote up
@Override
public void onArmorTick(World world, final EntityPlayer player, ItemStack itemStack) {
	if (!world.isRemote) {
		if (player.ticksExisted % 20 == 0) {
			float heal = TF2Attribute.getModifier("Health Regen", itemStack, 0, player);
			if(heal > 0) {
				int lastHitTime = player.ticksExisted - player.getEntityData().getInteger("lasthit");
				if (lastHitTime >= 120)
					player.heal(heal);
				else if(lastHitTime >= 60)
					player.heal(TF2Util.lerp(heal, heal/4f, (lastHitTime-60)/60f));
				else
					player.heal(heal/4f);
			}
		}
		if (player.ticksExisted % 5 == 0 && itemStack.getTagCompound().getBoolean("Active")) {
			itemStack.getTagCompound().setFloat("Rage",
					Math.max(0,
							itemStack.getTagCompound().getFloat("Rage")
									- 1 / (TF2Attribute.getModifier("Buff Duration", itemStack,
											getData(itemStack).getInt(PropertyType.DURATION), player) - 20)));
			if (itemStack.getTagCompound().getFloat("Rage") <= 0)
				itemStack.getTagCompound().setBoolean("Active", false);
			for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class,
					player.getEntityBoundingBox().grow(10, 10, 10), new Predicate<EntityLivingBase>() {

						@Override
						public boolean apply(EntityLivingBase input) {
							// TODO Auto-generated method stub
							return TF2Util.isOnSameTeam(player, input);
						}

					}))
				living.addPotionEffect(new PotionEffect(this.getBuff(itemStack), 25));

		}
		if (player.isCreative())
			itemStack.getTagCompound().setFloat("Rage", 1);
	}
}
 
Example 32
Project: connor41-etfuturum2   File: TippedArrow.java   Source Code and License 5 votes vote down vote up
public static ItemStack setEffect(ItemStack stack, Potion potion, int duration) {
	stack.setTagCompound(new NBTTagCompound());
	NBTTagCompound nbt = new NBTTagCompound();
	stack.getTagCompound().setTag("Potion", nbt);

	PotionEffect effect = new PotionEffect(potion.getId(), potion.isInstant() ? 1 : duration);
	effect.writeCustomPotionEffectToNBT(nbt);

	return stack;
}
 
Example 33
Project: TheOink   File: OinkDiamondPorkChop.java   Source Code and License 5 votes vote down vote up
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
    player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, mobEffectTime, 0, false, false));
    player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, mobEffectTime, 0, false, false));
    player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, mobEffectTime, 0, false, false));
    player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, mobEffectTime, 0, false, false));
    player.addPotionEffect(new PotionEffect(MobEffects.HASTE, mobEffectTime, 0, false, false));
    player.addPotionEffect(new PotionEffect(MobEffects.SPEED, mobEffectTime, 0, false, false));
    player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION,mobEffectTime, 0, false, false));
}
 
Example 34
Project: CustomWorldGen   File: EntityPlayerSP.java   Source Code and License 5 votes vote down vote up
/**
 * Removes the given potion effect from the active potion map and returns it. Does not call cleanup callbacks for
 * the end of the potion effect.
 */
@Nullable
public PotionEffect removeActivePotionEffect(@Nullable Potion potioneffectin)
{
    if (potioneffectin == MobEffects.NAUSEA)
    {
        this.prevTimeInPortal = 0.0F;
        this.timeInPortal = 0.0F;
    }

    return super.removeActivePotionEffect(potioneffectin);
}
 
Example 35
Project: UniversalRemote   File: EntityPlayerProxy.java   Source Code and License 5 votes vote down vote up
@Override
public PotionEffect getActivePotionEffect(Potion potionIn) {
	if (m_realPlayer == null) {
		return super.getActivePotionEffect(potionIn);
	} else {
		return m_realPlayer.getActivePotionEffect(potionIn);
	}
}
 
Example 36
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
    this.potionsNeedUpdate = true;

    if (p_70695_2_ && !this.worldObj.isRemote)
    {
        Potion.potionTypes[id.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), id.getAmplifier());
        Potion.potionTypes[id.getPotionID()].applyAttributesModifiersToEntity(this, this.getAttributeMap(), id.getAmplifier());
    }
}
 
Example 37
Project: customstuff4   File: ItemFood.java   Source Code and License 5 votes vote down vote up
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    WrappedPotionEffect effect = content.potionEffect.get(stack.getMetadata()).orElse(WrappedPotionEffect.of(null));
    float probability = content.potionEffectProbability.get(stack.getMetadata()).orElse(1f);
    PotionEffect potion = effect.getPotionEffect();

    if (!worldIn.isRemote && potion != null && worldIn.rand.nextFloat() < probability)
    {
        player.addPotionEffect(new PotionEffect(potion));
    }
}
 
Example 38
Project: CustomWorldGen   File: TileEntityBeacon.java   Source Code and License 5 votes vote down vote up
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 39
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
    tagCompound.setFloat("HealF", this.getHealth());
    tagCompound.setShort("Health", (short)((int)Math.ceil((double)this.getHealth())));
    tagCompound.setShort("HurtTime", (short)this.hurtTime);
    tagCompound.setInteger("HurtByTimestamp", this.revengeTimer);
    tagCompound.setShort("DeathTime", (short)this.deathTime);
    tagCompound.setFloat("AbsorptionAmount", this.getAbsorptionAmount());

    for (ItemStack itemstack : this.getInventory())
    {
        if (itemstack != null)
        {
            this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers());
        }
    }

    tagCompound.setTag("Attributes", SharedMonsterAttributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));

    for (ItemStack itemstack1 : this.getInventory())
    {
        if (itemstack1 != null)
        {
            this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers());
        }
    }

    if (!this.activePotionsMap.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (PotionEffect potioneffect : this.activePotionsMap.values())
        {
            nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
        }

        tagCompound.setTag("ActiveEffects", nbttaglist);
    }
}
 
Example 40
Project: uniquecrops   File: DevilSnare.java   Source Code and License 5 votes vote down vote up
@Override
  public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
  	
if (this.getAge(state) < getMaxAge())
	return;

if (entity != null && entity instanceof EntityLivingBase) {
	if (entity instanceof EntityPlayer && (((EntityPlayer)entity).inventory.armorInventory[0] != null && ((EntityPlayer)entity).inventory.armorInventory[0].getItem() == UCItems.slippers))
		return;
	
	((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 4));
}
  }
 
Example 41
Project: harshencastle   File: GlassContainerValue.java   Source Code and License 5 votes vote down vote up
public PotionEffect[] getEffects() 
{
	if(effects == null || effects[0] == null)
		return null;
	PotionEffect[] returnEffects = new PotionEffect[effects.length];
	for(int i = 0; i < effects.length; i++)
		returnEffects[i] = new PotionEffect(effects[i].getPotion(), effects[i].getDuration(), effects[i].getAmplifier(), effects[i].getIsAmbient(), effects[i].doesShowParticles());
	return returnEffects;
}
 
Example 42
Project: Thermionics   File: ItemMistcloak.java   Source Code and License 5 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public void onWornTick(ItemStack stack, EntityLivingBase player) {
	if (player.world.isRemote) return;
	
	if (stack.getItemDamage()==1) {
		
		if (player.getBrightness() < 0.4375f) {
			player.addPotionEffect(new PotionEffect(POTION_INVIS, 5));
		}
	}
}
 
Example 43
Project: UniversalRemote   File: EntityPlayerProxy.java   Source Code and License 5 votes vote down vote up
@Override
public PotionEffect removeActivePotionEffect(Potion potioneffectin) {
	if (m_realPlayer == null) {
		return super.removeActivePotionEffect(potioneffectin);
	} else {
		return m_realPlayer.removeActivePotionEffect(potioneffectin);
	}
}
 
Example 44
Project: Backmemed   File: EntityZombieVillager.java   Source Code and License 5 votes vote down vote up
protected void func_190734_b(int p_190734_1_)
{
    this.conversionTime = p_190734_1_;
    this.getDataManager().set(CONVERTING, Boolean.valueOf(true));
    this.removePotionEffect(MobEffects.WEAKNESS);
    this.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, p_190734_1_, Math.min(this.world.getDifficulty().getDifficultyId() - 1, 0)));
    this.world.setEntityState(this, (byte)16);
}
 
Example 45
Project: CustomWorldGen   File: SPacketEntityEffect.java   Source Code and License 5 votes vote down vote up
public SPacketEntityEffect(int entityIdIn, PotionEffect effect)
{
    this.entityId = entityIdIn;
    this.effectId = (byte)(Potion.getIdFromPotion(effect.getPotion()) & 255);
    this.amplifier = (byte)(effect.getAmplifier() & 255);

    if (effect.getDuration() > 32767)
    {
        this.duration = 32767;
    }
    else
    {
        this.duration = effect.getDuration();
    }

    this.flags = 0;

    if (effect.getIsAmbient())
    {
        this.flags = (byte)(this.flags | 1);
    }

    if (effect.doesShowParticles())
    {
        this.flags = (byte)(this.flags | 2);
    }
}
 
Example 46
Project: CombinedPotions   File: RecipeCombinedPotions2.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private List<PotionEffect> getEffectsFromStack(ItemStack stack)
{
	try
	{
		Method method = Class.forName("com.tmtravlr.potioncore.PotionCoreHelper").getMethod("getEffectsFromStack", ItemStack.class);
		return (List<PotionEffect>)method.invoke(null, stack);
	}
	catch (Exception ex)
	{
		CombinedPotions.LOGGER.catching(ex);
		return new ArrayList<PotionEffect>();
	}
}
 
Example 47
Project: CustomWorldGen   File: EntityDragonFireball.java   Source Code and License 5 votes vote down vote up
/**
 * Called when this EntityFireball hits a block or entity.
 */
protected void onImpact(RayTraceResult result)
{
    if (!this.worldObj.isRemote)
    {
        List<EntityLivingBase> list = this.worldObj.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D));
        EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.worldObj, this.posX, this.posY, this.posZ);
        entityareaeffectcloud.setOwner(this.shootingEntity);
        entityareaeffectcloud.setParticle(EnumParticleTypes.DRAGON_BREATH);
        entityareaeffectcloud.setRadius(3.0F);
        entityareaeffectcloud.setDuration(2400);
        entityareaeffectcloud.setRadiusPerTick((7.0F - entityareaeffectcloud.getRadius()) / (float)entityareaeffectcloud.getDuration());
        entityareaeffectcloud.addEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 1, 1));

        if (!list.isEmpty())
        {
            for (EntityLivingBase entitylivingbase : list)
            {
                double d0 = this.getDistanceSqToEntity(entitylivingbase);

                if (d0 < 16.0D)
                {
                    entityareaeffectcloud.setPosition(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ);
                    break;
                }
            }
        }

        this.worldObj.playEvent(2006, new BlockPos(this.posX, this.posY, this.posZ), 0);
        this.worldObj.spawnEntityInWorld(entityareaeffectcloud);
        this.setDead();
    }
}
 
Example 48
Project: uniquecrops   File: PotionBehavior.java   Source Code and License 5 votes vote down vote up
public static void reverseEffects(EntityPlayer player) {
	
	if (!player.getActivePotionEffects().isEmpty()) {
		Iterator it = player.getActivePotionEffects().iterator();
		while (it.hasNext()) {
			PotionEffect pot = (PotionEffect)it.next();
			setReverseEffects(pot, player);
		}
	}
}
 
Example 49
Project: CustomWorldGen   File: EntityZombie.java   Source Code and License 5 votes vote down vote up
/**
 * Convert this zombie into a villager.
 */
protected void convertToVillager()
{
    EntityVillager entityvillager = new EntityVillager(this.worldObj);
    entityvillager.copyLocationAndAnglesFrom(this);
    entityvillager.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
    entityvillager.setLookingForHome();

    if (this.isChild())
    {
        entityvillager.setGrowingAge(-24000);
    }

    this.worldObj.removeEntity(this);
    entityvillager.setNoAI(this.isAIDisabled());
    if (this.getVillagerTypeForge() != null)
        entityvillager.setProfession(this.getVillagerTypeForge());
    else
        entityvillager.setProfession(0);

    if (this.hasCustomName())
    {
        entityvillager.setCustomNameTag(this.getCustomNameTag());
        entityvillager.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag());
    }

    this.worldObj.spawnEntityInWorld(entityvillager);
    entityvillager.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 200, 0));
    this.worldObj.playEvent((EntityPlayer)null, 1027, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
 
Example 50
Project: CustomWorldGen   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
/**
 * Returns true if all of the potion effects in the specified collection are ambient.
 */
public static boolean areAllPotionsAmbient(Collection<PotionEffect> potionEffects)
{
    for (PotionEffect potioneffect : potionEffects)
    {
        if (!potioneffect.getIsAmbient())
        {
            return false;
        }
    }

    return true;
}
 
Example 51
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
    tagCompound.setFloat("HealF", this.getHealth());
    tagCompound.setShort("Health", (short)((int)Math.ceil((double)this.getHealth())));
    tagCompound.setShort("HurtTime", (short)this.hurtTime);
    tagCompound.setInteger("HurtByTimestamp", this.revengeTimer);
    tagCompound.setShort("DeathTime", (short)this.deathTime);
    tagCompound.setFloat("AbsorptionAmount", this.getAbsorptionAmount());

    for (ItemStack itemstack : this.getInventory())
    {
        if (itemstack != null)
        {
            this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers());
        }
    }

    tagCompound.setTag("Attributes", SharedMonsterAttributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));

    for (ItemStack itemstack1 : this.getInventory())
    {
        if (itemstack1 != null)
        {
            this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers());
        }
    }

    if (!this.activePotionsMap.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (PotionEffect potioneffect : this.activePotionsMap.values())
        {
            nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
        }

        tagCompound.setTag("ActiveEffects", nbttaglist);
    }
}
 
Example 52
Project: BaseClient   File: EntityZombie.java   Source Code and License 5 votes vote down vote up
/**
 * Starts converting this zombie into a villager. The zombie converts into a villager after the specified time in
 * ticks.
 */
protected void startConversion(int ticks)
{
    this.conversionTime = ticks;
    this.getDataWatcher().updateObject(14, Byte.valueOf((byte)1));
    this.removePotionEffect(Potion.weakness.id);
    this.addPotionEffect(new PotionEffect(Potion.damageBoost.id, ticks, Math.min(this.worldObj.getDifficulty().getDifficultyId() - 1, 0)));
    this.worldObj.setEntityState(this, (byte)16);
}
 
Example 53
Project: Backmemed   File: ItemFishFood.java   Source Code and License 5 votes vote down vote up
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    ItemFishFood.FishType itemfishfood$fishtype = ItemFishFood.FishType.byItemStack(stack);

    if (itemfishfood$fishtype == ItemFishFood.FishType.PUFFERFISH)
    {
        player.addPotionEffect(new PotionEffect(MobEffects.POISON, 1200, 3));
        player.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 300, 2));
        player.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 300, 1));
    }

    super.onFoodEaten(stack, worldIn, player);
}
 
Example 54
Project: CustomWorldGen   File: EntityWitherSkull.java   Source Code and License 4 votes vote down vote up
/**
 * Called when this EntityFireball hits a block or entity.
 */
protected void onImpact(RayTraceResult result)
{
    if (!this.worldObj.isRemote)
    {
        if (result.entityHit != null)
        {
            if (this.shootingEntity != null)
            {
                if (result.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8.0F))
                {
                    if (result.entityHit.isEntityAlive())
                    {
                        this.applyEnchantments(this.shootingEntity, result.entityHit);
                    }
                    else
                    {
                        this.shootingEntity.heal(5.0F);
                    }
                }
            }
            else
            {
                result.entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
            }

            if (result.entityHit instanceof EntityLivingBase)
            {
                int i = 0;

                if (this.worldObj.getDifficulty() == EnumDifficulty.NORMAL)
                {
                    i = 10;
                }
                else if (this.worldObj.getDifficulty() == EnumDifficulty.HARD)
                {
                    i = 40;
                }

                if (i > 0)
                {
                    ((EntityLivingBase)result.entityHit).addPotionEffect(new PotionEffect(MobEffects.WITHER, 20 * i, 1));
                }
            }
        }

        this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, this.worldObj.getGameRules().getBoolean("mobGriefing"));
        this.setDead();
    }
}
 
Example 55
Project: CustomWorldGen   File: EntityTippedArrow.java   Source Code and License 4 votes vote down vote up
public void addEffect(PotionEffect effect)
{
    this.customPotionEffects.add(effect);
    this.getDataManager().set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, this.customPotionEffects))));
}
 
Example 56
Project: Zombe-Modpack   File: EntityPlayerMP.java   Source Code and License 4 votes vote down vote up
protected void onFinishedPotionEffect(PotionEffect effect)
{
    super.onFinishedPotionEffect(effect);
    this.connection.sendPacket(new SPacketRemoveEntityEffect(this.getEntityId(), effect.getPotion()));
}
 
Example 57
Project: CustomWorldGen   File: EntityWither.java   Source Code and License 4 votes vote down vote up
/**
 * adds a PotionEffect to the entity
 */
public void addPotionEffect(PotionEffect potioneffectIn)
{
}
 
Example 58
Project: CustomWorldGen   File: InventoryEffectRenderer.java   Source Code and License 4 votes vote down vote up
/**
 * Display the potion effects list
 */
private void drawActivePotionEffects()
{
    int i = this.guiLeft - 124;
    int j = this.guiTop;
    int k = 166;
    Collection<PotionEffect> collection = this.mc.thePlayer.getActivePotionEffects();

    if (!collection.isEmpty())
    {
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableLighting();
        int l = 33;

        if (collection.size() > 5)
        {
            l = 132 / (collection.size() - 1);
        }

        for (PotionEffect potioneffect : Ordering.natural().sortedCopy(collection))
        {
            Potion potion = potioneffect.getPotion();
            if(!potion.shouldRender(potioneffect)) continue;
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.getTextureManager().bindTexture(INVENTORY_BACKGROUND);
            this.drawTexturedModalRect(i, j, 0, 166, 140, 32);

            if (potion.hasStatusIcon())
            {
                int i1 = potion.getStatusIconIndex();
                this.drawTexturedModalRect(i + 6, j + 7, 0 + i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
            }

            potion.renderInventoryEffect(i, j, potioneffect, mc);
            if (!potion.shouldRenderInvText(potioneffect)) { j += l; continue; }
            String s1 = I18n.format(potion.getName(), new Object[0]);

            if (potioneffect.getAmplifier() == 1)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
            }
            else if (potioneffect.getAmplifier() == 2)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
            }
            else if (potioneffect.getAmplifier() == 3)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
            }

            this.fontRendererObj.drawStringWithShadow(s1, (float)(i + 10 + 18), (float)(j + 6), 16777215);
            String s = Potion.getPotionDurationString(potioneffect, 1.0F);
            this.fontRendererObj.drawStringWithShadow(s, (float)(i + 10 + 18), (float)(j + 6 + 10), 8355711);
            j += l;
        }
    }
}
 
Example 59
Project: ProgressiveDifficulty   File: AddResistanceModifier.java   Source Code and License 4 votes vote down vote up
@Override
public void handleUpkeepEvent(int numChanges, EntityLiving entity) {
    entity.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, MobUpkeepController.POTION_EFFECT_LENGTH,numChanges,false,true));

}
 
Example 60
Project: Wurst-MC-1.12-OF   File: WPlayer.java   Source Code and License 4 votes vote down vote up
public static void addPotionEffect(Potion potion)
{
	WMinecraft.getPlayer()
		.addPotionEffect(new PotionEffect(potion, 10801220));
}