Jump to content

Recommended Posts

Posted

No idea why but I have a ResourceLocationException when registering my item. Any help is appreciated

 

Stacktrace

[18:51:09.439] [Client thread/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Caught exception during event RegistryEvent.Register<minecraft:items> dispatch for modid tutorialmod
java.lang.ExceptionInInitializerError: null
	at harry.tutorialmod.TutorialMod$RegistryEvents.registerItems(TutorialMod.java:46) ~[main/:?]
	at net.minecraftforge.eventbus.ASMEventHandler_1_RegistryEvents_registerItems_Register.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:79) ~[eventbus-0.6.0-service.jar:?]
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:249) ~[eventbus-0.6.0-service.jar:?]
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:105) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:25.0]
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_201]
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_201]
	at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:100) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.fml.ModList.lambda$dispatchSynchronousEvent$4(ModList.java:111) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_201]
	at net.minecraftforge.fml.ModList.dispatchSynchronousEvent(ModList.java:111) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.fml.ModList.lambda$static$0(ModList.java:82) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.fml.LifecycleEventProvider.dispatch(LifecycleEventProvider.java:72) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:146) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:814) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.fml.ModLoader.loadMods(ModLoader.java:134) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:52) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:411) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:344) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraft.client.main.Main.main(SourceFile:144) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201]
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:19) [modlauncher-0.9.4.jar:?]
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:35) [modlauncher-0.9.4.jar:?]
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-0.9.4.jar:?]
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:58) [modlauncher-0.9.4.jar:?]
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:44) [modlauncher-0.9.4.jar:?]
	at net.minecraftforge.userdev.UserdevLauncher.main(UserdevLauncher.java:77) [forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
Caused by: net.minecraft.util.ResourceLocationException: Non [a-z0-9/._-] character in path of location: tutorialmod:tutorialItem
	at net.minecraft.util.ResourceLocation.<init>(SourceFile:38) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraft.util.ResourceLocation.<init>(SourceFile:47) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.registries.GameData.checkPrefix(GameData.java:833) ~[forge-1.13.2-25.0.13_mapped_snapshot_20180921-1.13.jar:?]
	at net.minecraftforge.registries.ForgeRegistryEntry.setRegistryName(ForgeRegistryEntry.java:45) ~[?:?]
	at net.minecraftforge.registries.ForgeRegistryEntry.setRegistryName(ForgeRegistryEntry.java:52) ~[?:?]
	at harry.tutorialmod.items.ItemBase.<init>(ItemBase.java:13) ~[?:?]
	at harry.tutorialmod.init.ItemInit.<clinit>(ItemInit.java:14) ~[?:?]
	... 31 more

 

ItemBase

public class ItemBase extends Item 
{	
	public ItemBase(String name) 
	{
		super(new Item.Properties());
		setRegistryName(new ResourceLocation(ModConfig.MODID, name));
		ItemInit.ITEMS.add(this);
	}
}

 

ItemInit

public class ItemInit 
{
	public static final List<Item> ITEMS = new ArrayList<Item>();
	
	public static final Item tutorialItem = new ItemBase("tutorialItem");
}

 

Main Class

@Mod(ModConfig.MODID)
public class TutorialMod 
{
	private static final Logger LOGGER = LogManager.getLogger(ModConfig.MODID);
	
	public TutorialMod() 
	{
		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. (This is what used to be preInit)");
	}
	
	private void clientRegistries(final FMLClientSetupEvent event)
	{
		LOGGER.info("Client registries registered. This is for all things that are client side only.");
	}
	
	@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
	public static class RegistryEvents
	{
		@SubscribeEvent
		public static void registerItems(final RegistryEvent.Register<Item> event)
		{
			event.getRegistry().registerAll((Item[]) ItemInit.ITEMS.toArray());
			LOGGER.info("Items registered.");
		}
		
		@SubscribeEvent
		public static void registerBlocks(final RegistryEvent.Register<Block> event)
		{
			LOGGER.info("Blocks registered.");
		}
	}
}

 

Posted (edited)

 

  On 2/17/2019 at 6:55 PM, HarryTechReviews said:

ItemBase

Expand  

Dont use ItemBase, there is already an ItemBase, it's called Item.

 

  On 2/17/2019 at 6:55 PM, HarryTechReviews said:

public static final Item tutorialItem = new ItemBase("tutorialItem");

Expand  

Don't use static initializers, ever. Instantinate your stuff directly in the appropriate registry event.

 

As for the error itself - read it. It tells you what's wrong right there, in the exception message.

  On 2/17/2019 at 6:55 PM, HarryTechReviews said:

Caused by: net.minecraft.util.ResourceLocationException: Non [a-z0-9/._-] character in path of location: tutorialmod:tutorialItem

Expand  

All registry names must be lowercase. They may include numbers from 0 to 9 and characters like ., _ and -. Nothing else is allowed and you have a capital I in there.

Edited by V0idWa1k3r
Posted
  On 2/17/2019 at 7:09 PM, V0idWa1k3r said:

 

Dont use ItemBase, there is already an ItemBase, it's called Item.

 

Don't use static initializers, ever. Instantinate your stuff directly in the appropriate registry event.

 

As for the error itself - read it. It tells you what's wrong right there, in the exception message.

All registry names must be lowercase. They may include numbers from 0 to 9 and characters like ., _ and -. Nothing else is allowed and you have a capital I in there.

Expand  

Thanks for your help with the error.

 

What's wrong with ItemBase? It's just a class that I can use to make all of my items do something, rather than having to individually do it for every item.

Thanks for the help with the static stuff though, I'll change that now

Posted
  On 2/17/2019 at 7:20 PM, HarryTechReviews said:

What's wrong with ItemBase? It's just a class that I can use to make all of my items do something, rather than having to individually do it for every item.

 

Expand  
  1. It prevents you from overriding other classes. Say you want to create a custom elytra - well, you have to override ItemElytraWings(or whatever it's called) since minecraft uses a lot of instanceof checks. With your ItemBase though you can't. And now you have to duplicate your code for no good reason.
  2. It is not needed. You are just creating extra classes for no good reason. Why do you need it? Everything is now passed to the constructor via the corresponding Properties object and setRegistryName already returns you your object so you can chain it. It serves no purpose apart from enforcing cargo-cult programming.
  3. In general you shouldn't abuse inheritance just to write less code, that's not what inheritance is for. If you really need it create a helper method:
public static <T extends IForgeRegistryEntry<T>> T setCommonParameters(T object, String registryName)
{
   return object.setRegistryName(new ResourceLocation(TestMod.MODID, registryName));
}

// In your registry handler
event.getRegistry().register(setCommonParameters(new Item(new Item.Properties()), "test_item"));

But even this is not needed since you can just do

event.getRegistry().register(new Item(new Item.Properties().group(GroupsRef.GROUP_TEST_MOD)).setRegistryName(NAME_VOID_INGOT));

 

  • Like 1
Posted
  On 2/17/2019 at 7:29 PM, V0idWa1k3r said:
  1. It prevents you from overriding other classes. Say you want to create a custom elytra - well, you have to override ItemElytraWings(or whatever it's called) since minecraft uses a lot of instanceof checks. With your ItemBase though you can't. And now you have to duplicate your code for no good reason.
  2. It is not needed. You are just creating extra classes for no good reason. Why do you need it? Everything is now passed to the constructor via the corresponding Properties object and setRegistryName already returns you your object so you can chain it. It serves no purpose apart from enforcing cargo-cult programming.
  3. In general you shouldn't abuse inheritance just to write less code, that's not what inheritance is for. If you really need it create a helper method:
public static <T extends IForgeRegistryEntry<T>> T setCommonParameters(T object, String registryName)
{
   return object.setRegistryName(new ResourceLocation(TestMod.MODID, registryName));
}

// In your registry handler
event.getRegistry().register(setCommonParameters(new Item(new Item.Properties()), "test_item"));

But even this is not needed since you can just do

event.getRegistry().register(new Item(new Item.Properties().group(GroupsRef.GROUP_TEST_MOD)).setRegistryName(NAME_VOID_INGOT));

 

Expand  

Thanks for the clarification

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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