Java Code Examples for net.minecraft.init.Items#POTATO

The following examples show how to use net.minecraft.init.Items#POTATO . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TofuCraftReload   File: EntityTofunian.java    License: MIT License 6 votes vote down vote up
private boolean hasEnoughItems(int multiplier) {
    boolean flag = this.getTofuProfession() == TofuProfession.TOFUCOOK;

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

        if (!itemstack.isEmpty()) {
            if (itemstack.getItem() == Items.BREAD && itemstack.getCount() >= 3 * multiplier || itemstack.getItem() == Items.POTATO && itemstack.getCount() >= 12 * multiplier || itemstack.getItem() == Items.CARROT && itemstack.getCount() >= 12 * multiplier || itemstack.getItem() == Items.BEETROOT && itemstack.getCount() >= 12 * multiplier || itemstack.getItem() == ItemLoader.foodset && itemstack.getCount() >= 12 * multiplier || itemstack.getItem() == ItemLoader.soybeans && itemstack.getCount() >= 12 * multiplier) {
                return true;
            }

            if (itemstack.getItem() == ItemLoader.tofu_food && itemstack.getCount() >= 14 * multiplier) {
                return true;
            }

            if (flag && itemstack.getItem() == Items.WHEAT && itemstack.getCount() >= 9 * multiplier || flag && itemstack.getItem() == ItemLoader.rice && itemstack.getCount() >= 9 * multiplier) {
                return true;
            }
        }
    }

    return false;
}
 
Example 2
@Override
public ItemStack getLootItem(Random rand, int level) {
	
	if(rand.nextInt(20) == 0) return new ItemStack(Items.CARROT, 1);
	if(rand.nextInt(20) == 0) return new ItemStack(Items.POTATO, 1);

	switch(rand.nextInt(8)){
	case 0: return new ItemStack(Items.WHEAT_SEEDS, rand.nextInt(8) + 1);
	case 1: return new ItemStack(Items.PUMPKIN_SEEDS, rand.nextInt(8) + 1);
	case 2: return new ItemStack(Items.MELON_SEEDS, rand.nextInt(8) + 1);		
	case 3: return new ItemStack(Items.WHEAT, rand.nextInt(8) + 1);
	case 4: return new ItemStack(Blocks.TORCH, 10 + rand.nextInt(10));
	case 5: return new ItemStack(Items.PAPER, rand.nextInt(8) + 1);
	case 6:	return new ItemStack(Items.BOOK, rand.nextInt(4) + 1);
	case 7:	return new ItemStack(Blocks.SAPLING, rand.nextInt(4) + 1, rand.nextInt(4));
	default: return new ItemStack(Items.STICK, 1);
	}
}
 
Example 3
Source Project: TofuCraftReload   File: EntityTofunian.java    License: MIT License 5 votes vote down vote up
public boolean getIsWillingToMate(boolean updateFirst) {
    if (!this.isWillingToMate && updateFirst && this.hasEnoughFoodToBreed()) {
        boolean flag = false;

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

            if (!itemstack.isEmpty()) {
                if (itemstack.getItem() == Items.BREAD && itemstack.getCount() >= 3) {
                    flag = true;
                    this.getVillagerInventory().decrStackSize(i, 3);
                } else if ((itemstack.getItem() == ItemLoader.soybeans || itemstack.getItem() == ItemLoader.tofu_food || itemstack.getItem() == ItemLoader.foodset || itemstack.getItem() == Items.POTATO || itemstack.getItem() == Items.CARROT) && itemstack.getCount() >= 12) {
                    flag = true;
                    this.getVillagerInventory().decrStackSize(i, 12);
                }
            }

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

    return this.isWillingToMate;
}
 
Example 4
Source Project: TofuCraftReload   File: EntityTofunian.java    License: MIT License 5 votes vote down vote up
public boolean isFarmItemInInventory() {
    for (int i = 0; i < this.getVillagerInventory().getSizeInventory(); ++i) {
        ItemStack itemstack = this.getVillagerInventory().getStackInSlot(i);

        if (!itemstack.isEmpty() && (itemstack.getItem() == Items.WHEAT_SEEDS || itemstack.getItem() == Items.POTATO || itemstack.getItem() == Items.CARROT || itemstack.getItem() == Items.BEETROOT_SEEDS || itemstack.getItem() == ItemLoader.soybeans)) {
            return true;
        }
    }

    return false;
}
 
Example 5
Source Project: EmergingTechnology   File: PlantHelper.java    License: MIT License 5 votes vote down vote up
public static IBlockState getBlockStateFromItemStackForPlanting(ItemStack itemStack, World world, BlockPos pos) {

        if (itemStack.getItem() == Items.WHEAT_SEEDS) {
            return Blocks.WHEAT.getDefaultState();
        }
        if (itemStack.getItem() == Items.POTATO) {
            return Blocks.POTATOES.getDefaultState();
        }
        if (itemStack.getItem() == Items.CARROT) {
            return Blocks.CARROTS.getDefaultState();
        }
        if (itemStack.getItem() == Items.BEETROOT_SEEDS) {
            return Blocks.BEETROOTS.getDefaultState();
        }
        if (itemStack.getItem() == Items.REEDS) {
            return Blocks.REEDS.getDefaultState();
        }
        if (itemStack.getItem() == Items.PUMPKIN_SEEDS) {
            return Blocks.PUMPKIN_STEM.getDefaultState();
        }
        if (itemStack.getItem() == Items.MELON_SEEDS) {
            return Blocks.MELON_STEM.getDefaultState();
        }

        if (itemStack.getItem() instanceof IPlantable) {
            return ((IPlantable) itemStack.getItem()).getPlant(world, pos);
        }

        return null;
    }
 
Example 6
private boolean canBeReplanted(BlockPos pos)
{
	Item item = plants.get(pos);
	
	if(item == Items.WHEAT_SEEDS || item == Items.CARROT
		|| item == Items.POTATO || item == Items.BEETROOT_SEEDS
		|| item == Items.PUMPKIN_SEEDS || item == Items.MELON_SEEDS)
		return BlockUtils.getBlock(pos.down()) instanceof BlockFarmland;
	
	if(item == Items.NETHER_WART)
		return BlockUtils.getBlock(pos.down()) instanceof BlockSoulSand;
	
	return false;
}
 
Example 7
/**
 * Keep ticking a continuous task that has already been started
 */
public void updateTask()
{
    super.updateTask();
    this.villager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.villager.getVerticalFaceSpeed());

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

        if (this.currentTask == 0 && block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate))
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.currentTask == 1 && iblockstate.getMaterial() == Material.AIR)
        {
            InventoryBasic inventorybasic = this.villager.getVillagerInventory();

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

                if (!itemstack.isEmpty())
                {
                    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;
                    }
                    else if (itemstack.getItem() == Items.BEETROOT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() instanceof net.minecraftforge.common.IPlantable) {
                        if(((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlantType(world,blockpos) == net.minecraftforge.common.EnumPlantType.Crop) {
                            world.setBlockState(blockpos, ((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlant(world,blockpos),3);
                            flag = true;
                        }
                    }
                }

                if (flag)
                {
                    itemstack.shrink(1);

                    if (itemstack.isEmpty())
                    {
                        inventorybasic.setInventorySlotContents(i, ItemStack.EMPTY);
                    }

                    break;
                }
            }
        }

        this.currentTask = -1;
        this.runDelay = 10;
    }
}