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.
Example 1
Project: BaseClient   File: EntityPotion.java   Source Code and License 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: connor41-etfuturum2   File: TileEntityNewBrewingStand.java   Source Code and License 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 3
Project: BaseClient   File: ContainerBrewingStand.java   Source Code and License 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 4
Project: BaseClient   File: TileEntityBrewingStand.java   Source Code and License 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 5
Project: BaseClient   File: ItemGlassBottle.java   Source Code and License 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 6
Project: BaseClient   File: CreativeTabs.java   Source Code and License Vote up 4 votes
public Item getTabIconItem()
{
    return Items.potionitem;
}
 
Example 7
Project: BaseClient   File: TileEntityBrewingStand.java   Source Code and License 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: TileEntityBrewingStand.java   Source Code and License 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 9
Project: BaseClient   File: EntityPotion.java   Source Code and License Vote up 4 votes
public EntityPotion(World worldIn, EntityLivingBase throwerIn, int meta)
{
    this(worldIn, throwerIn, new ItemStack(Items.potionitem, 1, meta));
}
 
Example 10
Project: BaseClient   File: ContainerBrewingStand.java   Source Code and License Vote up 4 votes
public static boolean canHoldPotion(ItemStack stack)
{
    return stack != null && (stack.getItem() == Items.potionitem || stack.getItem() == Items.glass_bottle);
}
 
Example 11
Project: BaseClient   File: ContainerBrewingStand.java   Source Code and License Vote up 4 votes
public static boolean canHoldPotion(ItemStack stack)
{
    return stack != null && (stack.getItem() == Items.potionitem || stack.getItem() == Items.glass_bottle);
}