Java Code Examples for net.minecraft.item.Item#getHasSubtypes()
The following examples show how to use
net.minecraft.item.Item#getHasSubtypes() .
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 check out the related API usage on the sidebar.
Example 1
Source Project: customstuff4 File: ItemHelper.java License: GNU General Public License v3.0 | 6 votes |
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; }
Example 2
Source Project: customstuff4 File: BlockMixin.java License: GNU General Public License v3.0 | 5 votes |
@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); }
Example 3
Source Project: NOVA-Core File: WrapUtility.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static String getItemID(Item item, int meta) { if (item.getHasSubtypes()) { return Item.REGISTRY.getNameForObject(item) + ":" + meta; } else { return Objects.toString(Item.REGISTRY.getNameForObject(item)); } }
Example 4
Source Project: NOVA-Core File: WrapUtility.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Nonnull public static String getItemID(@Nonnull Item item, int meta) { if (item.getHasSubtypes()) { return String.format("%s:%d", Item.itemRegistry.getNameForObject(item), meta); } else { return String.valueOf(Item.itemRegistry.getNameForObject(item)); } }
Example 5
Source Project: NOVA-Core File: WrapUtility.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Nonnull public static String getItemID(@Nonnull Item item, int meta) { if (item.getHasSubtypes()) { return String.format("%s:%d", Item.itemRegistry.getNameForObject(item), meta); } else { return Item.itemRegistry.getNameForObject(item); } }