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

The following are Jave code examples for showing how to use potato() 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: EntityVillager.java   Source Code and License Vote up 6 votes
/**
 * Returns true if villager has enough items in inventory
 */
private boolean hasEnoughItems(int multiplier)
{
    boolean flag = this.getProfession() == 0;

    for (int i = 0; i < this.villagerInventory.getSizeInventory(); ++i)
    {
        ItemStack itemstack = this.villagerInventory.getStackInSlot(i);

        if (itemstack != null)
        {
            if (itemstack.getItem() == Items.bread && itemstack.stackSize >= 3 * multiplier || itemstack.getItem() == Items.potato && itemstack.stackSize >= 12 * multiplier || itemstack.getItem() == Items.carrot && itemstack.stackSize >= 12 * multiplier)
            {
                return true;
            }

            if (flag && itemstack.getItem() == Items.wheat && itemstack.stackSize >= 9 * multiplier)
            {
                return true;
            }
        }
    }

    return false;
}
 
Example 2
Project: BaseClient   File: EntityVillager.java   Source Code and License Vote up 6 votes
/**
 * Returns true if villager has enough items in inventory
 */
private boolean hasEnoughItems(int multiplier)
{
    boolean flag = this.getProfession() == 0;

    for (int i = 0; i < this.villagerInventory.getSizeInventory(); ++i)
    {
        ItemStack itemstack = this.villagerInventory.getStackInSlot(i);

        if (itemstack != null)
        {
            if (itemstack.getItem() == Items.bread && itemstack.stackSize >= 3 * multiplier || itemstack.getItem() == Items.potato && itemstack.stackSize >= 12 * multiplier || itemstack.getItem() == Items.carrot && itemstack.stackSize >= 12 * multiplier)
            {
                return true;
            }

            if (flag && itemstack.getItem() == Items.wheat && itemstack.stackSize >= 9 * multiplier)
            {
                return true;
            }
        }
    }

    return false;
}
 
Example 3
Project: BaseClient   File: EntityVillager.java   Source Code and License Vote up 5 votes
/**
 * Returns true if villager has seeds, potatoes or carrots in inventory
 */
public boolean isFarmItemInInventory()
{
    for (int i = 0; i < this.villagerInventory.getSizeInventory(); ++i)
    {
        ItemStack itemstack = this.villagerInventory.getStackInSlot(i);

        if (itemstack != null && (itemstack.getItem() == Items.wheat_seeds || itemstack.getItem() == Items.potato || itemstack.getItem() == Items.carrot))
        {
            return true;
        }
    }

    return false;
}
 
Example 4
Project: BaseClient   File: EntityVillager.java   Source Code and License Vote up 5 votes
/**
 * Returns current or updated value of {@link #isWillingToMate}
 */
public boolean getIsWillingToMate(boolean updateFirst)
{
    if (!this.isWillingToMate && updateFirst && this.func_175553_cp())
    {
        boolean flag = false;

        for (int i = 0; i < this.villagerInventory.getSizeInventory(); ++i)
        {
            ItemStack itemstack = this.villagerInventory.getStackInSlot(i);

            if (itemstack != null)
            {
                if (itemstack.getItem() == Items.bread && itemstack.stackSize >= 3)
                {
                    flag = true;
                    this.villagerInventory.decrStackSize(i, 3);
                }
                else if ((itemstack.getItem() == Items.potato || itemstack.getItem() == Items.carrot) && itemstack.stackSize >= 12)
                {
                    flag = true;
                    this.villagerInventory.decrStackSize(i, 12);
                }
            }

            if (flag)
            {
                this.worldObj.setEntityState(this, (byte)18);
                this.isWillingToMate = true;
                break;
            }
        }
    }

    return this.isWillingToMate;
}
 
Example 5
Project: BaseClient   File: EntityAIHarvestFarmland.java   Source Code and License Vote up 4 votes
/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();
    this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.theVillager.worldObj;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.field_179501_f == 0 && block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7)
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.field_179501_f == 1 && block == Blocks.air)
        {
            InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (itemstack != null)
                {
                    if (itemstack.getItem() == Items.wheat_seeds)
                    {
                        world.setBlockState(blockpos, Blocks.wheat.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.potato)
                    {
                        world.setBlockState(blockpos, Blocks.potatoes.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.carrot)
                    {
                        world.setBlockState(blockpos, Blocks.carrots.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    --itemstack.stackSize;

                    if (itemstack.stackSize <= 0)
                    {
                        inventorybasic.setInventorySlotContents(i, (ItemStack)null);
                    }

                    break;
                }
            }
        }

        this.field_179501_f = -1;
        this.runDelay = 10;
    }
}
 
Example 6
Project: BaseClient   File: EntityAIHarvestFarmland.java   Source Code and License Vote up 4 votes
/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();
    this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.theVillager.worldObj;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.field_179501_f == 0 && block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7)
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.field_179501_f == 1 && block == Blocks.air)
        {
            InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (itemstack != null)
                {
                    if (itemstack.getItem() == Items.wheat_seeds)
                    {
                        world.setBlockState(blockpos, Blocks.wheat.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.potato)
                    {
                        world.setBlockState(blockpos, Blocks.potatoes.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.carrot)
                    {
                        world.setBlockState(blockpos, Blocks.carrots.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    --itemstack.stackSize;

                    if (itemstack.stackSize <= 0)
                    {
                        inventorybasic.setInventorySlotContents(i, (ItemStack)null);
                    }

                    break;
                }
            }
        }

        this.field_179501_f = -1;
        this.runDelay = 10;
    }
}
 
Example 7
Project: BaseClient   File: BlockPotato.java   Source Code and License Vote up 4 votes
protected Item getCrop()
{
    return Items.potato;
}
 
Example 8
Project: BaseClient   File: EntityVillager.java   Source Code and License Vote up 4 votes
private boolean canVillagerPickupItem(Item itemIn)
{
    return itemIn == Items.bread || itemIn == Items.potato || itemIn == Items.carrot || itemIn == Items.wheat || itemIn == Items.wheat_seeds;
}
 
Example 9
Project: BaseClient   File: BlockPotato.java   Source Code and License Vote up 4 votes
protected Item getSeed()
{
    return Items.potato;
}
 
Example 10
Project: BaseClient   File: BlockPotato.java   Source Code and License Vote up 4 votes
protected Item getSeed()
{
    return Items.potato;
}