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


Java Item类代码示例

本文整理汇总了Java中net.minecraft.item.Item的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getEnchantmentDatas

import net.minecraft.item.Item; //导入依赖的package包/类
public static List<EnchantmentData> getEnchantmentDatas(int p_185291_0_, ItemStack p_185291_1_, boolean allowTreasure)
{
    List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
    Item item = p_185291_1_.getItem();
    boolean flag = p_185291_1_.getItem() == Items.BOOK;

    for (Enchantment enchantment : Enchantment.REGISTRY)
    {
        if ((!enchantment.isTreasureEnchantment() || allowTreasure) && (enchantment.type.canEnchantItem(item) || flag))
        {
            for (int i = enchantment.getMaxLevel(); i > enchantment.getMinLevel() - 1; --i)
            {
                if (p_185291_0_ >= enchantment.getMinEnchantability(i) && p_185291_0_ <= enchantment.getMaxEnchantability(i))
                {
                    list.add(new EnchantmentData(enchantment, i));
                    break;
                }
            }
        }
    }

    return list;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:EnchantmentHelper.java

示例2: quantityDroppedWithBonus

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * Get the quantity dropped based on the given fortune level
 */
public int quantityDroppedWithBonus(int fortune, Random random)
{
    if (fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped((IBlockState)this.getBlockState().getValidStates().iterator().next(), random, fortune))
    {
        int i = random.nextInt(fortune + 2) - 1;

        if (i < 0)
        {
            i = 0;
        }

        return this.quantityDropped(random) * (i + 1);
    }
    else
    {
        return this.quantityDropped(random);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:22,代码来源:BlockOre.java

示例3: RenderTarget

import net.minecraft.item.Item; //导入依赖的package包/类
public RenderTarget(Entity entity) {
    this.entity = entity;
    trackEntries = EntityTrackHandler.getTrackersForEntity(entity);
    circle1 = new RenderTargetCircle();
    circle2 = new RenderTargetCircle();
    Item droppedItem = null;
    if (entity instanceof EntityLiving) {
        try {
            droppedItem = null;//TODO 1.8 EntityUtils.getLivingDrop((EntityLiving)entity);
        } catch (Throwable e) {
        }
    }
    if (droppedItem != null) {
        stat = new GuiAnimatedStat(null, entity.getName(), new ItemStack(droppedItem, 1, 0), 20, -20, 0x3000AA00, null, false);
    } else {
        stat = new GuiAnimatedStat(null, entity.getName(), "", 20, -20, 0x3000AA00, null, false);
    }
    stat.setMinDimensionsAndReset(0, 0);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:20,代码来源:RenderTarget.java

示例4: initStats

import net.minecraft.item.Item; //导入依赖的package包/类
private static void initStats()
{
    for (Item item : net.minecraftforge.fml.common.registry.GameData.getItemRegistry().typeSafeIterable())
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null)
            {
                OBJECT_USE_STATS[i] = (new StatCrafting("stat.useItem.", s, new TextComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();

                if (!(item instanceof ItemBlock))
                {
                    USE_ITEM_STATS.add((StatCrafting)OBJECT_USE_STATS[i]);
                }
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_USE_STATS, true);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:StatList.java

示例5: call

import net.minecraft.item.Item; //导入依赖的package包/类
@Override
public void call(String[] args) throws CmdException
{
	if(args.length == 0)
		throw new CmdSyntaxError();
	if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
		throw new CmdError("Creative mode only.");
	ItemStack item = WMinecraft.getPlayer().inventory.getCurrentItem();
	if(item == null || Item.getIdFromItem(item.getItem()) != 387)
		throw new CmdError(
			"You are not holding a written book in your hand.");
	String author = args[0];
	for(int i = 1; i < args.length; i++)
		author += " " + args[i];
	item.setTagInfo("author", new NBTTagString(author));
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:17,代码来源:AuthorCmd.java

示例6: dropBlockAsItemWithChance

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * Spawns this Block's drops into the World as EntityItems.
 */
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
    if (!worldIn.isRemote)
    {
        int i = this.quantityDroppedWithBonus(fortune, worldIn.rand);

        for (int j = 0; j < i; ++j)
        {
            if (worldIn.rand.nextFloat() <= chance)
            {
                Item item = this.getItemDropped(state, worldIn.rand, fortune);

                if (item != null)
                {
                    spawnAsEntity(worldIn, pos, new ItemStack(item, 1, this.damageDropped(state)));
                }
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:24,代码来源:Block.java

示例7: makeItemStack

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * Makes an {@link ItemStack} based on the itemName reference, with supplied meta, stackSize and nbt, if possible
 * <p/>
 * Will return null if the item doesn't exist (because it's not from a loaded mod for example)
 * Will throw a {@link RuntimeException} if the nbtString is invalid for use in an {@link ItemStack}
 *
 * @param itemName  a registry name reference
 * @param meta      the meta
 * @param stackSize the stack size
 * @param nbtString an nbt stack as a string, will be processed by {@link JsonToNBT}
 * @return a new itemstack
 */
public static ItemStack makeItemStack(String itemName, int meta, int stackSize, String nbtString)
{
    if (itemName == null)
    {
        throw new IllegalArgumentException("The itemName cannot be null");
    }
    Item item = GameData.getItemRegistry().getObject(new ResourceLocation(itemName));
    if (item == null)
    {
        FMLLog.getLogger().log(Level.TRACE, "Unable to find item with name {}", itemName);
        return null;
    }
    ItemStack is = new ItemStack(item, stackSize, meta);
    if (!Strings.isNullOrEmpty(nbtString))
    {
        NBTBase nbttag = null;
        try
        {
            nbttag = JsonToNBT.getTagFromJson(nbtString);
        } catch (NBTException e)
        {
            FMLLog.getLogger().log(Level.WARN, "Encountered an exception parsing ItemStack NBT string {}", nbtString, e);
            throw Throwables.propagate(e);
        }
        if (!(nbttag instanceof NBTTagCompound))
        {
            FMLLog.getLogger().log(Level.WARN, "Unexpected NBT string - multiple values {}", nbtString);
            throw new RuntimeException("Invalid NBT JSON");
        }
        else
        {
            is.setTagCompound((NBTTagCompound)nbttag);
        }
    }
    return is;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:49,代码来源:GameRegistry.java

示例8: updateItemUse

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * Plays sounds and makes particles for item in use state
 */
protected void updateItemUse(ItemStack stack, int eatingParticleCount)
{
    if (!stack.func_190926_b() && this.isHandActive())
    {
        if (stack.getItemUseAction() == EnumAction.DRINK)
        {
            this.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
        }

        if (stack.getItemUseAction() == EnumAction.EAT)
        {
            for (int i = 0; i < eatingParticleCount; ++i)
            {
                Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
                vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F);
                vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F);
                double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
                Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
                vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F);
                vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F);
                vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);

                if (stack.getHasSubtypes())
                {
                    this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem()), stack.getMetadata()});
                }
                else
                {
                    this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())});
                }
            }

            this.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:EntityLivingBase.java

示例9: getSubBlocks

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list)
{
    if (itemIn != Item.getItemFromBlock(Blocks.DOUBLE_STONE_SLAB))
    {
        for (BlockStoneSlab.EnumType blockstoneslab$enumtype : BlockStoneSlab.EnumType.values())
        {
            if (blockstoneslab$enumtype != BlockStoneSlab.EnumType.WOOD)
            {
                list.add(new ItemStack(itemIn, 1, blockstoneslab$enumtype.getMetadata()));
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:BlockStoneSlab.java

示例10: registerToolModels

import net.minecraft.item.Item; //导入依赖的package包/类
public static void registerToolModels()
{
    List<Item> toolsList = Arrays.asList(ExPItems.knife, ExPItems.pickaxe, ExPItems.axe, ExPItems.shovel, ExPItems.hoe, ExPItems.sword, ExPItems.scythe, ExPItems.battleaxe, ExPItems.hammer, ExPItems.spear, ExPItems.watering_can, ExPItems.gardening_spade);
    toolsList.forEach(tool -> ModelLoader.setCustomMeshDefinition(tool, stack -> new ModelResourceLocation(new ResourceLocation(tool.getRegistryName().getResourceDomain(), "tools/" + tool.getRegistryName().getResourcePath()), "material=" + EnumToolStats.values()[stack.getMetadata()].getName())));
    for (int i = 0; i < EnumToolStats.values().length; ++i)
    {
        Integer lambdaCaptureInt = i;
        toolsList.forEach(tool -> ModelLoader.registerItemVariants(tool, new ModelResourceLocation(new ResourceLocation(tool.getRegistryName().getResourceDomain(), "tools/" + tool.getRegistryName().getResourcePath()), "material=" + EnumToolStats.values()[lambdaCaptureInt].getName())));
    }
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:11,代码来源:ClientRegistry.java

示例11: remap

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * Remap the missing item to the specified Item.
 *
 * Use this if you have renamed an Item.
 * Existing references using the old name will point to the new one.
 *
 * @param target Item to remap to.
 */
public void remap(Item target)
{
    if (type != GameRegistry.Type.ITEM) throw new IllegalArgumentException("Can't remap a block to an item.");
    if (target == null) throw new NullPointerException("remap target is null");
    if (GameData.getItemRegistry().getId(target) < 0) throw new IllegalArgumentException(String.format("The specified item %s hasn't been registered at startup.", target));

    action = Action.REMAP;
    this.target = target;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:FMLMissingMappingsEvent.java

示例12: doReaction

import net.minecraft.item.Item; //导入依赖的package包/类
public static ItemStack doReaction(ItemStack reagent, ItemStack potionIn)
{
    if (!potionIn.func_190926_b())
    {
        PotionType potiontype = PotionUtils.getPotionFromItem(potionIn);
        Item item = potionIn.getItem();
        int i = 0;

        for (int j = POTION_ITEM_CONVERSIONS.size(); i < j; ++i)
        {
            PotionHelper.MixPredicate<Item> mixpredicate = (PotionHelper.MixPredicate)POTION_ITEM_CONVERSIONS.get(i);

            if (mixpredicate.input == item && mixpredicate.reagent.apply(reagent))
            {
                return PotionUtils.addPotionToItemStack(new ItemStack((Item)mixpredicate.output), potiontype);
            }
        }

        i = 0;

        for (int k = POTION_TYPE_CONVERSIONS.size(); i < k; ++i)
        {
            PotionHelper.MixPredicate<PotionType> mixpredicate1 = (PotionHelper.MixPredicate)POTION_TYPE_CONVERSIONS.get(i);

            if (mixpredicate1.input == potiontype && mixpredicate1.reagent.apply(reagent))
            {
                return PotionUtils.addPotionToItemStack(new ItemStack(item), (PotionType)mixpredicate1.output);
            }
        }
    }

    return potionIn;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:34,代码来源:PotionHelper.java

示例13: getSubItems

import net.minecraft.item.Item; //导入依赖的package包/类
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
	for (int c = 0; c < subs.size(); c++) {
		ItemStack is = new ItemStack(this, 1, c);
		subItems.add(is);
	}
}
 
开发者ID:trigg,项目名称:Firma,代码行数:8,代码来源:MetaItem.java

示例14: getSubBlocks

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
    for (BlockSandStone.EnumType blocksandstone$enumtype : BlockSandStone.EnumType.values())
    {
        list.add(new ItemStack(itemIn, 1, blocksandstone$enumtype.getMetadata()));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:BlockSandStone.java

示例15: getSubBlocks

import net.minecraft.item.Item; //导入依赖的package包/类
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
    for (int i = 0; i < 16; ++i)
    {
        list.add(new ItemStack(itemIn, 1, i));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:11,代码来源:BlockCarpet.java


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