Skip to content

Commit

Permalink
Possible fix for Ridanisaurus#202, Testing required
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanzaji committed Feb 14, 2024
1 parent 8d9a2de commit cc1d207
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import org.jetbrains.annotations.NotNull;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(Reference.MOD_ID)
Expand Down Expand Up @@ -102,7 +102,7 @@ private void commonEvents(FMLCommonSetupEvent event) {

public static final CreativeModeTab TAB = new CreativeModeTab("emendatusenigmatica") {
@Override
public ItemStack makeIcon() {
public @NotNull ItemStack makeIcon() {
return new ItemStack(EERegistrar.ENIGMATIC_HAMMER.get());
}
};
Expand All @@ -113,14 +113,20 @@ private static void registerDataGen() {
EmendatusEnigmatica.getInstance().getLoader().datagen(generator);
}

public static void generate() {
public static void generate() {
if (!hasGenerated) {
try {
if(generator == null)
registerDataGen();
if(generator == null) registerDataGen();
if (!ModLoader.isLoadingStateValid()) {
LOGGER.error("Loading state is invalid! Aborting running Data Generation to avoid even more issues.");
return;
}
generator.run();
} catch (IOException e) {
e.printStackTrace();
} catch (Throwable e) {
LOGGER.error("Exception caught while running data generation!", e);
if (ModLoader.isLoadingStateValid()) throw new RuntimeException(e);
LOGGER.error("It was probably caused by another mod crashing before Data Generation, as LoadingState is already invalid!");
return;
}
hasGenerated = true;
}
Expand Down

0 comments on commit cc1d207

Please sign in to comment.