diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 449563a819..9b31730e39 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -32,6 +32,7 @@ import com.gregtechceu.gtceu.data.lang.MaterialLangGenerator; import com.gregtechceu.gtceu.data.loot.ChestGenHooks; import com.gregtechceu.gtceu.forge.AlloyBlastPropertyAddition; +import com.gregtechceu.gtceu.integration.GTOreVeinWidget; import com.gregtechceu.gtceu.integration.kjs.GTCEuStartupEvents; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.kjs.events.MaterialModificationEventJS; @@ -49,14 +50,11 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLModContainer; -import net.minecraftforge.registries.ForgeDeferredRegistriesSetup; -import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegisterEvent; import java.util.List; @@ -109,6 +107,7 @@ public static void init() { GTFoods.init(); GTItems.init(); AddonFinder.getAddons().forEach(IGTAddon::initializeAddon); + GTOreVeinWidget.init(); // fabric exclusive, squeeze this in here to register before stuff is used GTRegistration.REGISTRATE.registerRegistrate(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java index eda53c8de5..02805989e0 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java @@ -10,7 +10,6 @@ import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; import com.gregtechceu.gtceu.api.data.worldgen.generator.veins.NoopVeinGenerator; -import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTOres; import com.gregtechceu.gtceu.integration.kjs.GTCEuServerEvents; @@ -74,6 +73,13 @@ protected void apply(Map resourceList, ResourceMa LOGGER.error("Parsing error loading ore vein {}", location, jsonParseException); } } + buildVeinGenerator(); + + GTOres.updateLargestVeinSize(); + GTRegistries.ORE_VEINS.freeze(); + } + + public static void buildVeinGenerator() { Iterator> iterator = GTRegistries.ORE_VEINS.entries().iterator(); while (iterator.hasNext()) { var entry = iterator.next().getValue(); @@ -83,9 +89,6 @@ protected void apply(Map resourceList, ResourceMa iterator.remove(); } } - - GTOres.updateLargestVeinSize(); - GTRegistries.ORE_VEINS.freeze(); } public static GTOreDefinition fromJson(ResourceLocation id, JsonObject json, RegistryOps ops) { diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/forge/OreDataLoaderImpl.java b/src/main/java/com/gregtechceu/gtceu/data/loader/forge/OreDataLoaderImpl.java index bbf92cee8c..5d26d5e40b 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/forge/OreDataLoaderImpl.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/forge/OreDataLoaderImpl.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.data.loader.forge; import com.gregtechceu.gtceu.data.loader.OreDataLoader; -import net.minecraft.core.RegistryAccess; public class OreDataLoaderImpl extends OreDataLoader { public OreDataLoaderImpl() { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/GTOreVeinWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/GTOreVeinWidget.java index 2a4fb8487d..c68d997cb5 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/GTOreVeinWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/GTOreVeinWidget.java @@ -1,10 +1,15 @@ package com.gregtechceu.gtceu.integration; +import com.gregtechceu.gtceu.api.addon.AddonFinder; +import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.common.data.GTBedrockFluids; +import com.gregtechceu.gtceu.common.data.GTOres; +import com.gregtechceu.gtceu.data.loader.OreDataLoader; import com.lowdragmc.lowdraglib.gui.texture.TextTexture; import com.lowdragmc.lowdraglib.gui.widget.*; import com.lowdragmc.lowdraglib.jei.IngredientIO; @@ -64,6 +69,7 @@ public GTOreVeinWidget(BedrockFluidDefinition fluid) { setupText(fluid); } + @SuppressWarnings("all") private String range(GTOreDefinition oreDefinition) { HeightProvider height = oreDefinition.range().height; int minHeight = 0, maxHeight = 0; @@ -99,7 +105,7 @@ private void setupBaseGui(BedrockFluidDefinition fluid){ addWidget(fluidSlot); } - private void setupText(GTOreDefinition oreDefinition){ + private void setupText(GTOreDefinition ignored){ addWidget(new ImageWidget(5, 0, width - 10, 16, new TextTexture("gtceu.jei.ore_vein." + name).setType(TextTexture.TextType.LEFT_ROLL).setWidth(width - 10))); addWidget(new LabelWidget(5, 40, @@ -113,7 +119,7 @@ private void setupText(GTOreDefinition oreDefinition){ addWidget(new LabelWidget(5, 80, dimensions)); } - private void setupText(BedrockFluidDefinition fluid){ + private void setupText(BedrockFluidDefinition ignored){ addWidget(new ImageWidget(5, 0, width - 10, 16, new TextTexture("gtceu.jei.bedrock_fluid." + name).setType(TextTexture.TextType.LEFT_ROLL).setWidth(width - 10))); addWidget(new LabelWidget(5, 40, @@ -145,4 +151,20 @@ public String getFluidName(BedrockFluidDefinition fluid) { ResourceLocation id = GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(fluid); return id.getPath(); } + + public static void init(){ + if (GTRegistries.ORE_VEINS.values().isEmpty()){ + GTRegistries.ORE_VEINS.unfreeze(); + GTOres.init(); + AddonFinder.getAddons().forEach(IGTAddon::registerOreVeins); + OreDataLoader.buildVeinGenerator(); + GTRegistries.ORE_VEINS.freeze(); + } + if (GTRegistries.BEDROCK_FLUID_DEFINITIONS.values().isEmpty()){ + GTRegistries.BEDROCK_FLUID_DEFINITIONS.unfreeze(); + GTBedrockFluids.init(); + AddonFinder.getAddons().forEach(IGTAddon::registerFluidVeins); + GTRegistries.BEDROCK_FLUID_DEFINITIONS.freeze(); + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java index aed5a5691b..1e2e72463e 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java @@ -46,7 +46,10 @@ public void register(EmiRegistry registry) { registry.addRecipeHandler(PatternEncodingTermMenu.TYPE, new Ae2PatternTerminalHandler<>()); } // recipes - MultiblockInfoEmiCategory.registerDisplays(registry); + try { + MultiblockInfoEmiCategory.registerDisplays(registry); + } catch (NullPointerException ignored){ + } GTRecipeTypeEmiCategory.registerDisplays(registry); GTOreProcessingEmiCategory.registerDisplays(registry); GTOreVeinEmiCategory.registerDisplays(registry); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java index 1883ffc735..ca69a6c020 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java @@ -15,7 +15,7 @@ public class GTOreVeinEmiCategory extends ModularUIEmiRecipeCategory { public static final GTOreVeinEmiCategory CATEGORY = new GTOreVeinEmiCategory(); public GTOreVeinEmiCategory() { - super(GTCEu.id("ore_vein_diagram"), EmiStack.of(Items.IRON_INGOT)); + super(GTCEu.id("ore_vein_diagram"), EmiStack.of(Items.RAW_IRON)); } public static void registerDisplays(EmiRegistry registry) {