Skip to content

Commit

Permalink
fix emi issue in server (#976)
Browse files Browse the repository at this point in the history
* fix orevein recipes empty on server

* ??
  • Loading branch information
Arborsm authored Mar 19, 2024
1 parent 6e807ab commit 96965ef
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,6 +73,13 @@ protected void apply(Map<ResourceLocation, JsonElement> resourceList, ResourceMa
LOGGER.error("Parsing error loading ore vein {}", location, jsonParseException);
}
}
buildVeinGenerator();

GTOres.updateLargestVeinSize();
GTRegistries.ORE_VEINS.freeze();
}

public static void buildVeinGenerator() {
Iterator<Map.Entry<ResourceLocation, GTOreDefinition>> iterator = GTRegistries.ORE_VEINS.entries().iterator();
while (iterator.hasNext()) {
var entry = iterator.next().getValue();
Expand All @@ -83,9 +89,6 @@ protected void apply(Map<ResourceLocation, JsonElement> resourceList, ResourceMa
iterator.remove();
}
}

GTOres.updateLargestVeinSize();
GTRegistries.ORE_VEINS.freeze();
}

public static GTOreDefinition fromJson(ResourceLocation id, JsonObject json, RegistryOps<JsonElement> ops) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 96965ef

Please sign in to comment.