Java Code Examples for net.minecraftforge.fml.common.registry.GameRegistry#registerItem()

The following examples show how to use net.minecraftforge.fml.common.registry.GameRegistry#registerItem() . 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: ItemConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void registerNOVAItem(ItemFactory itemFactory) {
	if (map.containsKey(itemFactory)) {
		// just a safeguard - don't map stuff twice
		return;
	}

	net.minecraft.item.Item itemWrapper;

	Item dummy = itemFactory.build();
	if (dummy instanceof ItemBlock) {
		BlockFactory blockFactory = ((ItemBlock) dummy).blockFactory;
		net.minecraft.block.Block mcBlock = BlockConverter.instance().toNative(blockFactory);
		itemWrapper = net.minecraft.item.Item.getItemFromBlock(mcBlock);
		if (itemWrapper == null) {
			throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID());
		}
	} else {
		itemWrapper = new FWItem(itemFactory);
	}

	MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0);
	map.put(itemFactory, minecraftItemMapping);

	// Don't register ItemBlocks twice
	if (!(dummy instanceof ItemBlock)) {
		NovaMinecraft.proxy.registerItem((FWItem) itemWrapper);
		String itemId = itemFactory.getID();
		if (!itemId.contains(":"))
			itemId = NovaLauncher.instance().flatMap(NovaLauncher::getCurrentMod).map(Mod::id).orElse("nova") + ':' + itemId;
		GameRegistry.registerItem(itemWrapper, itemId);

		if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
			//Add into creative tab
			Category category = dummy.components.get(Category.class);
			itemWrapper.setCreativeTab(CategoryConverter.instance().toNative(category, itemWrapper));
		}

		Game.logger().info("Registered item: {}", itemFactory.getID());
	}
}
 
Example 2
Source File: Mobycraft.java    From mobycraft with Apache License 2.0 4 votes vote down vote up
private void registerItem(Item item, String name) {
	GameRegistry.registerItem(item, name);
	mesher.register(item, 0, new ModelResourceLocation("moby:" + name,
			"inventory"));
}
 
Example 3
Source File: TeleportItems.java    From ModdingTutorials with GNU General Public License v2.0 4 votes vote down vote up
public static void register()
{
	GameRegistry.registerItem(coord_cache, coord_cache.getUnlocalizedName().substring(5));
}
 
Example 4
Source File: TeleportItems.java    From ModdingTutorials with GNU General Public License v2.0 4 votes vote down vote up
public static void register()
{
	GameRegistry.registerItem(coord_cache, coord_cache.getUnlocalizedName().substring(5));
}