Java Code Examples for net.minecraft.init.Items.potionitem()

The following are Jave code examples for showing how to use potionitem() of the net.minecraft.init.Items 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: EntityPotion.java   View Source Code Vote up 5 votes
/**
 * Sets the PotionEffect by the given id of the potion effect.
 */
public void setPotionDamage(int potionId)
{
    if (this.potionDamage == null)
    {
        this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
    }

    this.potionDamage.setItemDamage(potionId);
}
 
Example 2
Project: BaseClient   File: EntityPotion.java   View Source Code Vote up 5 votes
/**
 * Sets the PotionEffect by the given id of the potion effect.
 */
public void setPotionDamage(int potionId)
{
    if (this.potionDamage == null)
    {
        this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
    }

    this.potionDamage.setItemDamage(potionId);
}
 
Example 3
Project: DecompiledMinecraft   File: EntityPotion.java   View Source Code Vote up 5 votes
/**
 * Returns the damage value of the thrown potion that this EntityPotion represents.
 */
public int getPotionDamage()
{
    if (this.potionDamage == null)
    {
        this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
    }

    return this.potionDamage.getMetadata();
}
 
Example 4
Project: connor41-etfuturum2   File: TileEntityNewBrewingStand.java   View Source Code Vote up 5 votes
private boolean canBrew() {
	if (fuel > 0 && inventory[3] != null && inventory[3].stackSize > 0) {
		ItemStack itemstack = inventory[3];

		if (!itemstack.getItem().isPotionIngredient(itemstack))
			return false;
		else if (itemstack.getItem() == ModItems.dragon_breath) {
			for (int i = 0; i < 3; i++)
				if (inventory[i] != null && inventory[i].getItem() == Items.potionitem)
					if (ItemPotion.isSplash(inventory[i].getItemDamage()))
						return true;
			return false;
		} else {
			boolean flag = false;

			for (int i = 0; i < 3; i++)
				if (inventory[i] != null && inventory[i].getItem() instanceof ItemPotion) {
					int j = inventory[i].getItemDamage();
					int k = applyIngredient(j, itemstack);

					if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k)) {
						flag = true;
						break;
					}

					List<?> list = Items.potionitem.getEffects(j);
					List<?> list1 = Items.potionitem.getEffects(k);

					if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && j != k) {
						flag = true;
						break;
					}
				}

			return flag;
		}
	} else
		return false;
}
 
Example 5
Project: DecompiledMinecraft   File: ContainerBrewingStand.java   View Source Code Vote up 5 votes
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
{
    if (stack.getItem() == Items.potionitem && stack.getMetadata() > 0)
    {
        this.player.triggerAchievement(AchievementList.potion);
    }

    super.onPickupFromSlot(playerIn, stack);
}
 
Example 6
Project: BaseClient   File: ContainerBrewingStand.java   View Source Code Vote up 5 votes
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
{
    if (stack.getItem() == Items.potionitem && stack.getMetadata() > 0)
    {
        this.player.triggerAchievement(AchievementList.potion);
    }

    super.onPickupFromSlot(playerIn, stack);
}
 
Example 7
Project: BaseClient   File: TileEntityBrewingStand.java   View Source Code Vote up 4 votes
private void brewPotions()
{
    if (this.canBrew())
    {
        ItemStack itemstack = this.brewingItemStacks[3];

        for (int i = 0; i < 3; ++i)
        {
            if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() == Items.potionitem)
            {
                int j = this.brewingItemStacks[i].getMetadata();
                int k = this.getPotionResult(j, itemstack);
                List<PotionEffect> list = Items.potionitem.getEffects(j);
                List<PotionEffect> list1 = Items.potionitem.getEffects(k);

                if (j > 0 && list == list1 || list != null && (list.equals(list1) || list1 == null))
                {
                    if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
                    {
                        this.brewingItemStacks[i].setItemDamage(k);
                    }
                }
                else if (j != k)
                {
                    this.brewingItemStacks[i].setItemDamage(k);
                }
            }
        }

        if (itemstack.getItem().hasContainerItem())
        {
            this.brewingItemStacks[3] = new ItemStack(itemstack.getItem().getContainerItem());
        }
        else
        {
            --this.brewingItemStacks[3].stackSize;

            if (this.brewingItemStacks[3].stackSize <= 0)
            {
                this.brewingItemStacks[3] = null;
            }
        }
    }
}
 
Example 8
Project: BaseClient   File: ItemGlassBottle.java   View Source Code Vote up 4 votes
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);

    if (movingobjectposition == null)
    {
        return itemStackIn;
    }
    else
    {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = movingobjectposition.getBlockPos();

            if (!worldIn.isBlockModifiable(playerIn, blockpos))
            {
                return itemStackIn;
            }

            if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
            {
                return itemStackIn;
            }

            if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.water)
            {
                --itemStackIn.stackSize;
                playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);

                if (itemStackIn.stackSize <= 0)
                {
                    return new ItemStack(Items.potionitem);
                }

                if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.potionitem)))
                {
                    playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.potionitem, 1, 0), false);
                }
            }
        }

        return itemStackIn;
    }
}
 
Example 9
Project: BaseClient   File: CreativeTabs.java   View Source Code Vote up 4 votes
public Item getTabIconItem()
{
    return Items.potionitem;
}
 
Example 10
Project: BaseClient   File: TileEntityBrewingStand.java   View Source Code Vote up 4 votes
private void brewPotions()
{
    if (this.canBrew())
    {
        ItemStack itemstack = this.brewingItemStacks[3];

        for (int i = 0; i < 3; ++i)
        {
            if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() == Items.potionitem)
            {
                int j = this.brewingItemStacks[i].getMetadata();
                int k = this.getPotionResult(j, itemstack);
                List<PotionEffect> list = Items.potionitem.getEffects(j);
                List<PotionEffect> list1 = Items.potionitem.getEffects(k);

                if (j > 0 && list == list1 || list != null && (list.equals(list1) || list1 == null))
                {
                    if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
                    {
                        this.brewingItemStacks[i].setItemDamage(k);
                    }
                }
                else if (j != k)
                {
                    this.brewingItemStacks[i].setItemDamage(k);
                }
            }
        }

        if (itemstack.getItem().hasContainerItem())
        {
            this.brewingItemStacks[3] = new ItemStack(itemstack.getItem().getContainerItem());
        }
        else
        {
            --this.brewingItemStacks[3].stackSize;

            if (this.brewingItemStacks[3].stackSize <= 0)
            {
                this.brewingItemStacks[3] = null;
            }
        }
    }
}
 
Example 11
Project: BaseClient   File: TileEntityBrewingStand.java   View Source Code Vote up 4 votes
/**
 * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
 */
public boolean isItemValidForSlot(int index, ItemStack stack)
{
    return index == 3 ? stack.getItem().isPotionIngredient(stack) : stack.getItem() == Items.potionitem || stack.getItem() == Items.glass_bottle;
}
 
Example 12
Project: DecompiledMinecraft   File: TileEntityBrewingStand.java   View Source Code Vote up 4 votes
private boolean canBrew()
{
    if (this.brewingItemStacks[3] != null && this.brewingItemStacks[3].stackSize > 0)
    {
        ItemStack itemstack = this.brewingItemStacks[3];

        if (!itemstack.getItem().isPotionIngredient(itemstack))
        {
            return false;
        }
        else
        {
            boolean flag = false;

            for (int i = 0; i < 3; ++i)
            {
                if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() == Items.potionitem)
                {
                    int j = this.brewingItemStacks[i].getMetadata();
                    int k = this.getPotionResult(j, itemstack);

                    if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
                    {
                        flag = true;
                        break;
                    }

                    List<PotionEffect> list = Items.potionitem.getEffects(j);
                    List<PotionEffect> list1 = Items.potionitem.getEffects(k);

                    if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && j != k)
                    {
                        flag = true;
                        break;
                    }
                }
            }

            return flag;
        }
    }
    else
    {
        return false;
    }
}
 
Example 13
Project: BaseClient   File: EntityPotion.java   View Source Code Vote up 4 votes
public EntityPotion(World worldIn, EntityLivingBase throwerIn, int meta)
{
    this(worldIn, throwerIn, new ItemStack(Items.potionitem, 1, meta));
}
 
Example 14
Project: BaseClient   File: ContainerBrewingStand.java   View Source Code Vote up 4 votes
public static boolean canHoldPotion(ItemStack stack)
{
    return stack != null && (stack.getItem() == Items.potionitem || stack.getItem() == Items.glass_bottle);
}
 
Example 15
Project: BaseClient   File: ContainerBrewingStand.java   View Source Code Vote up 4 votes
public static boolean canHoldPotion(ItemStack stack)
{
    return stack != null && (stack.getItem() == Items.potionitem || stack.getItem() == Items.glass_bottle);
}
 
Example 16
Project: DecompiledMinecraft   File: EntityPotion.java   View Source Code Vote up 4 votes
public EntityPotion(World worldIn, double x, double y, double z, int p_i1791_8_)
{
    this(worldIn, x, y, z, new ItemStack(Items.potionitem, 1, p_i1791_8_));
}
 
Example 17
Project: DecompiledMinecraft   File: CreativeTabs.java   View Source Code Vote up 4 votes
public Item getTabIconItem()
{
    return Items.potionitem;
}
 
Example 18
Project: DecompiledMinecraft   File: EntityWitch.java   View Source Code Vote up 4 votes
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    if (!this.worldObj.isRemote)
    {
        if (this.getAggressive())
        {
            if (this.witchAttackTimer-- <= 0)
            {
                this.setAggressive(false);
                ItemStack itemstack = this.getHeldItem();
                this.setCurrentItemOrArmor(0, (ItemStack)null);

                if (itemstack != null && itemstack.getItem() == Items.potionitem)
                {
                    List<PotionEffect> list = Items.potionitem.getEffects(itemstack);

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

                this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).removeModifier(MODIFIER);
            }
        }
        else
        {
            int i = -1;

            if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.water) && !this.isPotionActive(Potion.waterBreathing))
            {
                i = 8237;
            }
            else if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(Potion.fireResistance))
            {
                i = 16307;
            }
            else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth())
            {
                i = 16341;
            }
            else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                i = 16274;
            }
            else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                i = 16274;
            }

            if (i > -1)
            {
                this.setCurrentItemOrArmor(0, new ItemStack(Items.potionitem, 1, i));
                this.witchAttackTimer = this.getHeldItem().getMaxItemUseDuration();
                this.setAggressive(true);
                IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
                iattributeinstance.removeModifier(MODIFIER);
                iattributeinstance.applyModifier(MODIFIER);
            }
        }

        if (this.rand.nextFloat() < 7.5E-4F)
        {
            this.worldObj.setEntityState(this, (byte)15);
        }
    }

    super.onLivingUpdate();
}
 
Example 19
Project: DecompiledMinecraft   File: ContainerBrewingStand.java   View Source Code Vote up 4 votes
public static boolean canHoldPotion(ItemStack stack)
{
    return stack != null && (stack.getItem() == Items.potionitem || stack.getItem() == Items.glass_bottle);
}
 
Example 20
Project: DecompiledMinecraft   File: RenderPotion.java   View Source Code Vote up 4 votes
public RenderPotion(RenderManager renderManagerIn, RenderItem itemRendererIn)
{
    super(renderManagerIn, Items.potionitem, itemRendererIn);
}