Jump to content

[1.14.4] ASM causing issues with static initializers


MSpace-Dev

Recommended Posts

I have a class called FileManager that manages many things to do with my custom mod files. I'm trying to create a static constant that allows me to reference an array of files whenever I want. However, my program throws an ExceptionInInitializerError.

 

I took a similar test to a basic static void main program, and the program compiled fine. I can't see what I'm doing wrong in my main program below. Here are the relevant files:

 

Log:

[11:26:14] [Client thread/ERROR] [ne.mi.fm.ja.FMLModContainer/]: Exception caught during firing event: null
	Index: 1
	Listeners:
		0: NORMAL
		1: ASM: class com.mspacedev.ModEventSubscriber onRegisterBlocks(Lnet/minecraftforge/event/RegistryEvent$Register;)V
		2: ASM: class com.mspacedev.ModEventSubscriber onRegisterItems(Lnet/minecraftforge/event/RegistryEvent$Register;)V
java.lang.ExceptionInInitializerError
	at com.mspacedev.util.Data$Chests.getChestProperties(Data.java:16)
	at com.mspacedev.ModEventSubscriber.onRegisterBlocks(ModEventSubscriber.java:28)
	at net.minecraftforge.eventbus.ASMEventHandler_0_ModEventSubscriber_onRegisterBlocks_Register.invoke(.dynamic)
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)

 

FileManager:

// Files
public static final ArrayList<File> chestFiles = getFilesInPath("customchests/chests/");

private static ArrayList<File> getFilesInPath(final String pathName)
{
	ArrayList<File> files = new ArrayList<>();

	File folder = new File(pathName);

	for (final File fileEntry : folder.listFiles())
	{
		if (fileEntry.isDirectory())
			continue;

		files.add(new File(fileEntry.getName()));
	}

	return files;
}

 

I call this in my RegistryEvent.Register<Block> function:

if (!FileManager.chestFiles.isEmpty())

And it returns a NullReferenceException because of the earlier ExceptionInInitializerError

Edited by MSpace-Dev
Link to comment
Share on other sites

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.