Skip to content

Commit

Permalink
Fix setting up IConfigScreenFactory within main mod initializer inste…
Browse files Browse the repository at this point in the history
…ad of client side
  • Loading branch information
Dragon-Seeker committed Sep 25, 2024
1 parent 3b59acf commit 3a388e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/main/java/io/wispforest/owo/Owo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

import io.wispforest.owo.client.screens.ScreenInternals;
import io.wispforest.owo.command.debug.OwoDebugCommands;
import io.wispforest.owo.config.ui.ConfigScreen;
import io.wispforest.owo.config.ui.ConfigScreenProviders;
import io.wispforest.owo.ops.LootOps;
import io.wispforest.owo.util.OwoFreezer;
import io.wispforest.owo.util.Wisdom;
import net.minecraft.server.MinecraftServer;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.server.ServerLifecycleHooks;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -57,13 +52,6 @@ public Owo(IEventBus modBus) {

modBus.addListener((FMLLoadCompleteEvent event) -> OwoFreezer.freeze());

modBus.addListener(FMLCommonSetupEvent.class, event -> {
ConfigScreenProviders.forEach((modId, screenFactory) -> {
ModList.get().getModContainerById(modId)
.ifPresent(mod -> mod.registerExtensionPoint(IConfigScreenFactory.class, (modContainer, modsScreen) -> screenFactory.apply(modsScreen)));
});
});

Wisdom.spread();

if (!DEBUG) return;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/io/wispforest/owo/client/OwoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.wispforest.owo.client.screens.ScreenInternals;
import io.wispforest.owo.command.debug.OwoDebugCommands;
import io.wispforest.owo.config.OwoConfigCommand;
import io.wispforest.owo.config.ui.ConfigScreenProviders;
import io.wispforest.owo.itemgroup.json.OwoItemGroupLoader;
import io.wispforest.owo.moddata.ModDataLoader;
import io.wispforest.owo.shader.BlurProgram;
Expand All @@ -16,9 +17,12 @@
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.common.NeoForge;
import org.jetbrains.annotations.ApiStatus;

Expand Down Expand Up @@ -80,5 +84,12 @@ public OwoClient(IEventBus modBus) {

if (!Owo.DEBUG) return;
OwoDebugCommands.Client.register();

modBus.addListener(FMLClientSetupEvent.class, event -> {
ConfigScreenProviders.forEach((modId, screenFactory) -> {
ModList.get().getModContainerById(modId)
.ifPresent(mod -> mod.registerExtensionPoint(IConfigScreenFactory.class, (modContainer, modsScreen) -> screenFactory.apply(modsScreen)));
});
});
}
}

0 comments on commit 3a388e0

Please sign in to comment.