当前位置: 首页>>代码示例>>Java>>正文


Java Items.CARROT属性代码示例

本文整理汇总了Java中net.minecraft.init.Items.CARROT属性的典型用法代码示例。如果您正苦于以下问题:Java Items.CARROT属性的具体用法?Java Items.CARROT怎么用?Java Items.CARROT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.minecraft.init.Items的用法示例。


在下文中一共展示了Items.CARROT属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasEnoughItems

/**
 * 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.func_190926_b())
        {
            if (itemstack.getItem() == Items.BREAD && itemstack.func_190916_E() >= 3 * multiplier || itemstack.getItem() == Items.POTATO && itemstack.func_190916_E() >= 12 * multiplier || itemstack.getItem() == Items.CARROT && itemstack.func_190916_E() >= 12 * multiplier || itemstack.getItem() == Items.BEETROOT && itemstack.func_190916_E() >= 12 * multiplier)
            {
                return true;
            }

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

    return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:EntityVillager.java

示例2: hasEnoughItems

/**
 * 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 || itemstack.getItem() == Items.BEETROOT && itemstack.stackSize >= 12 * multiplier)
            {
                return true;
            }

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

    return false;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:27,代码来源:EntityVillager.java

示例3: getIsWillingToMate

/**
 * Returns current or updated value of {@link #isWillingToMate}
 */
public boolean getIsWillingToMate(boolean updateFirst)
{
    if (!this.isWillingToMate && updateFirst && this.hasEnoughFoodToBreed())
    {
        boolean flag = false;

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

            if (!itemstack.func_190926_b())
            {
                if (itemstack.getItem() == Items.BREAD && itemstack.func_190916_E() >= 3)
                {
                    flag = true;
                    this.villagerInventory.decrStackSize(i, 3);
                }
                else if ((itemstack.getItem() == Items.POTATO || itemstack.getItem() == Items.CARROT) && itemstack.func_190916_E() >= 12)
                {
                    flag = true;
                    this.villagerInventory.decrStackSize(i, 12);
                }
            }

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

    return this.isWillingToMate;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:38,代码来源:EntityVillager.java

示例4: isFarmItemInInventory

/**
 * 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.func_190926_b() && (itemstack.getItem() == Items.WHEAT_SEEDS || itemstack.getItem() == Items.POTATO || itemstack.getItem() == Items.CARROT || itemstack.getItem() == Items.BEETROOT_SEEDS))
        {
            return true;
        }
    }

    return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:EntityVillager.java

示例5: getIsWillingToMate

/**
 * Returns current or updated value of {@link #isWillingToMate}
 */
public boolean getIsWillingToMate(boolean updateFirst)
{
    if (!this.isWillingToMate && updateFirst && this.hasEnoughFoodToBreed())
    {
        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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:38,代码来源:EntityVillager.java

示例6: isFarmItemInInventory

/**
 * 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 || itemstack.getItem() == Items.BEETROOT_SEEDS))
        {
            return true;
        }
    }

    return false;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:EntityVillager.java

示例7: updateTask

/**
 * 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.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.theVillager.getVillagerInventory();

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

                if (!itemstack.func_190926_b())
                {
                    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;
                    }
                }

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

                    if (itemstack.func_190926_b())
                    {
                        inventorybasic.setInventorySlotContents(i, ItemStack.field_190927_a);
                    }

                    break;
                }
            }
        }

        this.currentTask = -1;
        this.runDelay = 10;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:70,代码来源:EntityAIHarvestFarmland.java

示例8: isRabbitBreedingItem

private boolean isRabbitBreedingItem(Item itemIn)
{
    return itemIn == Items.CARROT || itemIn == Items.GOLDEN_CARROT || itemIn == Item.getItemFromBlock(Blocks.YELLOW_FLOWER);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:4,代码来源:EntityRabbit.java

示例9: canVillagerPickupItem

private boolean canVillagerPickupItem(Item itemIn)
{
    return itemIn == Items.BREAD || itemIn == Items.POTATO || itemIn == Items.CARROT || itemIn == Items.WHEAT || itemIn == Items.WHEAT_SEEDS || itemIn == Items.BEETROOT || itemIn == Items.BEETROOT_SEEDS;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:4,代码来源:EntityVillager.java

示例10: getSeed

protected Item getSeed()
{
    return Items.CARROT;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:4,代码来源:BlockCarrot.java

示例11: getCrop

protected Item getCrop()
{
    return Items.CARROT;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:4,代码来源:BlockCarrot.java

示例12: updateTask

/**
 * 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.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.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;
                    }
                    else if (itemstack.getItem() == Items.BEETROOT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    --itemstack.stackSize;

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

                    break;
                }
            }
        }

        this.currentTask = -1;
        this.runDelay = 10;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:70,代码来源:EntityAIHarvestFarmland.java


注:本文中的net.minecraft.init.Items.CARROT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。