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


Java Item.getHasSubtypes方法代码示例

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


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

示例1: createSubItems

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static NonNullList<ItemStack> createSubItems(Item item, CreativeTabs creativeTab, Attribute<String> tabLabels, int[] subtypes)
{
    NonNullList<ItemStack> list = NonNullList.create();

    if (item.getHasSubtypes())
    {
        for (int meta : subtypes)
        {
            tabLabels.get(meta)
                     .ifPresent(tabLabel ->
                                {
                                    if (creativeTab == null || creativeTab == CreativeTabs.SEARCH || Objects.equals(tabLabel, getTabLabel(creativeTab)))
                                    {
                                        list.add(new ItemStack(item, 1, meta));
                                    }
                                });
        }
    } else
    {
        list.add(new ItemStack(item, 1, 0));
    }

    return list;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:25,代码来源:ItemHelper.java

示例2: dropEquipment

import net.minecraft.item.Item; //导入方法依赖的package包/类
/**
 * Drop the equipment for this entity.
 */
protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier)
{
    super.dropEquipment(wasRecentlyHit, lootingModifier);
    IBlockState iblockstate = this.getHeldBlockState();

    if (iblockstate != null)
    {
        Item item = Item.getItemFromBlock(iblockstate.getBlock());

        if (item != null)
        {
            int i = item.getHasSubtypes() ? iblockstate.getBlock().getMetaFromState(iblockstate) : 0;
            this.entityDropItem(new ItemStack(item, 1, i), 0.0F);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:EntityEnderman.java

示例3: createStackedBlock

import net.minecraft.item.Item; //导入方法依赖的package包/类
@Nullable
protected ItemStack createStackedBlock(IBlockState state)
{
    Item item = Item.getItemFromBlock(this);

    if (item == null)
    {
        return null;
    }
    else
    {
        int i = 0;

        if (item.getHasSubtypes())
        {
            i = this.getMetaFromState(state);
        }

        return new ItemStack(item, 1, i);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:Block.java

示例4: registerRenders

import net.minecraft.item.Item; //导入方法依赖的package包/类
@Load(side = Side.CLIENT)
public void registerRenders() {
    for (Field field : FCRItems.class.getFields()) {
        field.setAccessible(true);
        RegItem anno = field.getAnnotation(RegItem.class);
        try {
            if (anno == null)
                continue;

            Item item = (Item) field.get(null);
            if (item.getHasSubtypes()) {
                if (item instanceof IMetadatable) {
                    for (int i = 0; i < ((IMetadatable) item).getMaxMetadata(); i++)
                        registerRender(item, i);
                }
            } else {
                registerRender(item, 0);
            }
        } catch (Exception e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register item " + field.toGenericString(), e);
        }
    }
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:24,代码来源:ItemLoader.java

示例5: stackEqualsNonNBT

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static boolean stackEqualsNonNBT(@Nonnull ItemStack stack, @Nonnull  ItemStack other) {
    if (stack.isEmpty() && other.isEmpty())
        return true;
    if (stack.isEmpty() || other.isEmpty())
        return false;
    Item sItem = stack.getItem();
    Item oItem = other.getItem();
    if (sItem.getHasSubtypes() || oItem.getHasSubtypes()) {
        return sItem.equals(other.getItem()) &&
                (stack.getItemDamage() == other.getItemDamage() ||
                        stack.getItemDamage() == OreDictionary.WILDCARD_VALUE ||
                        other.getItemDamage() == OreDictionary.WILDCARD_VALUE);
    } else {
        return sItem.equals(other.getItem());
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:17,代码来源:ItemUtils.java

示例6: createStackedBlock

import net.minecraft.item.Item; //导入方法依赖的package包/类
protected ItemStack createStackedBlock(IBlockState state)
{
    int i = 0;
    Item item = Item.getItemFromBlock(this);

    if (item != null && item.getHasSubtypes())
    {
        i = this.getMetaFromState(state);
    }

    return new ItemStack(item, 1, i);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:13,代码来源:Block.java

示例7: createStackedBlock

import net.minecraft.item.Item; //导入方法依赖的package包/类
protected ItemStack createStackedBlock(IBlockState state) {
	int i = 0;
	Item item = Item.getItemFromBlock(this);

	if (item != null && item.getHasSubtypes()) {
		i = this.getMetaFromState(state);
	}

	return new ItemStack(item, 1, i);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:11,代码来源:Block.java

示例8: getSilkTouchDrop

import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
protected ItemStack getSilkTouchDrop(IBlockState state)
{
    Item item = Item.getItemFromBlock(this);
    int subtype = 0;

    if (item.getHasSubtypes())
    {
        subtype = getSubtype(state);
    }

    return new ItemStack(item, 1, subtype);
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:14,代码来源:BlockMixin.java

示例9: dropEquipment

import net.minecraft.item.Item; //导入方法依赖的package包/类
/**
 * Drop the equipment for this entity.
 */
protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier)
{
    super.dropEquipment(wasRecentlyHit, lootingModifier);
    IBlockState iblockstate = this.getHeldBlockState();

    if (iblockstate != null)
    {
        Item item = Item.getItemFromBlock(iblockstate.getBlock());
        int i = item.getHasSubtypes() ? iblockstate.getBlock().getMetaFromState(iblockstate) : 0;
        this.entityDropItem(new ItemStack(item, 1, i), 0.0F);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:16,代码来源:EntityEnderman.java

示例10: getSilkTouchDrop

import net.minecraft.item.Item; //导入方法依赖的package包/类
protected ItemStack getSilkTouchDrop(IBlockState state)
{
    Item item = Item.getItemFromBlock(this);
    int i = 0;

    if (item.getHasSubtypes())
    {
        i = this.getMetaFromState(state);
    }

    return new ItemStack(item, 1, i);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:Block.java

示例11: execute

import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    ItemStack held = player.getHeldItemMainhand();
    if(held.isEmpty()) {
        held = player.getHeldItemOffhand();
    }
    if(held.isEmpty()) {
        player.sendMessage(new TextComponentTranslation("command.modularmachinery.hand.empty"));
        return;
    }
    Item i = held.getItem();
    StringBuilder sb = new StringBuilder();
    sb.append(i.getRegistryName().toString());
    if(i.getHasSubtypes()) {
        sb.append("@").append(held.getItemDamage());
    }
    NBTTagCompound cmp = held.serializeNBT();
    if(cmp.hasKey("tag")) {
        String json = NBTJsonSerializer.serializeNBT(cmp.getTag("tag"));
        if(!json.isEmpty()) {
            sb.append(" (with nbt: ").append(json).append(" )");
        }
    }

    String str = sb.toString();
    player.sendMessage(new TextComponentString(str));
    ModularMachinery.NET_CHANNEL.sendTo(new PktCopyToClipboard(str), player);

    int burn = TileEntityFurnace.getItemBurnTime(held);
    if(burn > 0) {
        player.sendMessage(new TextComponentString("Fuel BurnTime: " + burn));
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:35,代码来源:CommandHand.java

示例12: hasSubTypes

import net.minecraft.item.Item; //导入方法依赖的package包/类
public static boolean hasSubTypes(Item item) {
    return item != null && item.getHasSubtypes();
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:4,代码来源:ZWrapper.java

示例13: drawSlot

import net.minecraft.item.Item; //导入方法依赖的package包/类
protected void drawSlot(int entryID, int insideLeft, int yPos, int insideSlotHeight, int mouseXIn, int mouseYIn)
{
    FlatLayerInfo flatlayerinfo = (FlatLayerInfo)GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().get(GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - entryID - 1);
    IBlockState iblockstate = flatlayerinfo.getLayerMaterial();
    Block block = iblockstate.getBlock();
    Item item = Item.getItemFromBlock(block);

    if (item == Items.field_190931_a)
    {
        if (block != Blocks.WATER && block != Blocks.FLOWING_WATER)
        {
            if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA)
            {
                item = Items.LAVA_BUCKET;
            }
        }
        else
        {
            item = Items.WATER_BUCKET;
        }
    }

    ItemStack itemstack = new ItemStack(item, 1, item.getHasSubtypes() ? block.getMetaFromState(iblockstate) : 0);
    String s = item.getItemStackDisplayName(itemstack);
    this.drawItem(insideLeft, yPos, itemstack);
    GuiCreateFlatWorld.this.fontRendererObj.drawString(s, insideLeft + 18 + 5, yPos + 3, 16777215);
    String s1;

    if (entryID == 0)
    {
        s1 = I18n.format("createWorld.customize.flat.layer.top", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
    }
    else if (entryID == GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - 1)
    {
        s1 = I18n.format("createWorld.customize.flat.layer.bottom", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
    }
    else
    {
        s1 = I18n.format("createWorld.customize.flat.layer", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
    }

    GuiCreateFlatWorld.this.fontRendererObj.drawString(s1, insideLeft + 2 + 213 - GuiCreateFlatWorld.this.fontRendererObj.getStringWidth(s1), yPos + 3, 16777215);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:44,代码来源:GuiCreateFlatWorld.java


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