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

The following examples show how to use net.minecraft.init.Items#BREAD . 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 check out the related API usage on the sidebar.
Example 1
Source File: EntityTofunian.java    From TofuCraftReload with 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
Source File: EntityTofunian.java    From TofuCraftReload with 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 3
Source File: SentientBread.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SubscribeEvent
public static void onClientTick(TickEvent.ClientTickEvent event)
{
    Minecraft mc = Minecraft.getMinecraft();

    if (!isLoaded)
    {
        return;
    }

    if (event.phase == TickEvent.Phase.END && mc.world != null && !mc.isGamePaused())
    {
        ItemStack stack = mc.player.getActiveItemStack();

        if (!stack.isEmpty() && stack.getItem() == Items.BREAD)
        {
            Random rand = mc.player.world.rand;

            if (rand.nextFloat() < 0.04)
            {
                String msg = MESSAGES_STOP[rand.nextInt(MESSAGES_STOP.length)];
                int i = mc.gameSettings.narrator;

                if (NARRATOR.active() && (i == 0 || i == 3)) // Don't narrate if the setting is already turned on
                {
                    NARRATOR.clear();
                    NARRATOR.say(msg);
                }

                mc.player.sendMessage(stack.getTextComponent().appendSibling(new TextComponentString(": " + msg)));
            }
        }
    }
}
 
Example 4
Source File: SlotCraftingTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
@Override
protected void onCrafting(ItemStack stack)
{
	if (this.amountCrafted > 0)
	{
		stack.onCrafting(this.player.world, this.player, this.amountCrafted);
		net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(this.player, stack, craftMatrix);
	}

	this.amountCrafted = 0;

	if (stack.getItem() == Item.getItemFromBlock(Blocks.CRAFTING_TABLE))
	{
		this.player.addStat(AchievementList.BUILD_WORK_BENCH);
	}

	if (stack.getItem() instanceof ItemPickaxe)
	{
		this.player.addStat(AchievementList.BUILD_PICKAXE);
	}

	if (stack.getItem() == Item.getItemFromBlock(Blocks.FURNACE))
	{
		this.player.addStat(AchievementList.BUILD_FURNACE);
	}

	if (stack.getItem() instanceof ItemHoe)
	{
		this.player.addStat(AchievementList.BUILD_HOE);
	}

	if (stack.getItem() == Items.BREAD)
	{
		this.player.addStat(AchievementList.MAKE_BREAD);
	}

	if (stack.getItem() == Items.CAKE)
	{
		this.player.addStat(AchievementList.BAKE_CAKE);
	}

	if (stack.getItem() instanceof ItemPickaxe && ((ItemPickaxe)stack.getItem()).getToolMaterial() != Item.ToolMaterial.WOOD)
	{
		this.player.addStat(AchievementList.BUILD_BETTER_PICKAXE);
	}

	if (stack.getItem() instanceof ItemSword)
	{
		this.player.addStat(AchievementList.BUILD_SWORD);
	}

	if (stack.getItem() == Item.getItemFromBlock(Blocks.ENCHANTING_TABLE))
	{
		this.player.addStat(AchievementList.ENCHANTMENTS);
	}

	if (stack.getItem() == Item.getItemFromBlock(Blocks.BOOKSHELF))
	{
		this.player.addStat(AchievementList.BOOKCASE);
	}
}