Jump to content

Recommended Posts

Posted (edited)

I have been following a tutorial for creating a custom tab for items and the names are not registering correctly and I honestly cant figure it out.

 

 

package Julian.watermod;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import Julian.watermod.lists.BlockList;
import Julian.watermod.lists.ItemList;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod("watermod")
public class WaterMod 
{
	public static WaterMod instance;
	public static final String modid ="watermod";
	private static final Logger logger = LogManager.getLogger(modid);
	
	public static final ItemGroup tutorial = new TutorialItemGroup();
	
	public WaterMod() 
	{
		instance = this;
		
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries);
		
		MinecraftForge.EVENT_BUS.register(this);
	}
	
	private void setup(final FMLCommonSetupEvent event)
	{
		logger.info("Setup method registered.");
	}
	
	private void clientRegistries(final FMLClientSetupEvent event)
	{
		logger.info("ClientRegistries method registered.");
	}
	
	@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
	public static class RegistryEvents
	{
		@SubscribeEvent
		public static void registerItems(final RegistryEvent.Register<Item> event)
		{
			event.getRegistry().registerAll
			(
					ItemList.tutorial_item = new Item(new Item.Properties().group(tutorial)).setRegistryName(location("tutorial_item")),
					
					ItemList.tutorial_block = new BlockItem(BlockList.tutorial_block, new Item.Properties().group(tutorial)).setRegistryName(BlockList.tutorial_block.getRegistryName())
			);
					
			logger.info("Items registered.");
		}
		
		@SubscribeEvent
		public static void registerBlocks(final RegistryEvent.Register<Block> event)
		{
			event.getRegistry().registerAll
			(
					BlockList.tutorial_block = new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(2.0f, 3.0f).lightValue(5).sound(SoundType.METAL)).setRegistryName(location("tutorial_block"))
			);
					
			logger.info("Blocks registered.");
		}
		
		private static ResourceLocation location(String name)
		{
			return new ResourceLocation(modid, name);
		}
	}
}

 

and here in the lang file.

 

{
	"item.watermod.tutorial_item": "Tutorial Item",
	
	"block.watermod.tutorial_block": "Tutorial Block"
	
	"itemGroup.tutorial": "Tutorial Item Group"
}

 

If anyone could help me figure it out I would really appreciate it.

Edited by thevapinggaymer
Topic Solved
Posted

There is a comma missing in the language file, after "tutorial block". Is the file a json, or are you using a .lang still? What are you seeing when you mouse over the item in game?

  • Thanks 1
Posted

Well that actually fixed it. i feel so dumb that i forgot a comma and i overlooked it. Also the lang is a json file. I didn't noticed the comma because for some reason my generic text editor is not showing it as code.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.