MSpace-Dev Posted November 23, 2019 Posted November 23, 2019 (edited) 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 November 23, 2019 by MSpace-Dev Quote
MSpace-Dev Posted November 23, 2019 Author Posted November 23, 2019 https://github.com/MSpaceDev/CustomChests/tree/1.14.4/src/main/java/com/mspacedev Quote
Recommended Posts
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.