package mezz.jei;

import mezz.jei.config.JEIClientConfigs;
import mezz.jei.events.PermanentEventSubscriptions;
import mezz.jei.gui.textures.JeiSpriteUploader;
import mezz.jei.gui.textures.Textures;
import mezz.jei.startup.ClientLifecycleHandler;
import mezz.jei.startup.NetworkHandler;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;

public class JustEnoughItemsClient {
	private final NetworkHandler networkHandler;
	private final PermanentEventSubscriptions subscriptions;
	private final JEIClientConfigs jeiClientConfigs = new JEIClientConfigs();

	public JustEnoughItemsClient(NetworkHandler networkHandler, PermanentEventSubscriptions subscriptions) {
		this.networkHandler = networkHandler;
		this.subscriptions = subscriptions;
	}

	public void register() {
		jeiClientConfigs.register(subscriptions);
		subscriptions.register(RegisterClientReloadListenersEvent.class, event -> this.onRegisterReloadListenerEvent(event, subscriptions));
	}

	private void onRegisterReloadListenerEvent(RegisterClientReloadListenersEvent event, PermanentEventSubscriptions subscriptions) {
		// Add the Sprite uploader reload listener
		Minecraft minecraft = Minecraft.getInstance();
		JeiSpriteUploader spriteUploader = new JeiSpriteUploader(minecraft.textureManager);
		Textures textures = new Textures(spriteUploader);
		Internal.setTextures(textures);
		event.registerReloadListener(spriteUploader);

		ClientLifecycleHandler clientLifecycleHandler = new ClientLifecycleHandler(networkHandler, textures, jeiClientConfigs);
		clientLifecycleHandler.register(subscriptions);
		event.registerReloadListener(clientLifecycleHandler);
	}
}

@@ -539,83 +539,8 @@
 ons;
-%0A%09private final JEIClientConfigs jeiClientConfigs = new JEIClientConfigs();
 %0A%0A%09p
@@ -751,16 +751,78 @@
 ter() %7B%0A
+%09%09JEIClientConfigs jeiClientConfigs = new JEIClientConfigs();%0A
 %09%09jeiCli
@@ -975,28 +975,31 @@
 (event, 
-subscription
+jeiClientConfig
 s));%0A%09%7D%0A
@@ -1089,48 +1089,40 @@
 nt, 
-PermanentEventSubscriptions subscription
+JEIClientConfigs jeiClientConfig
 s) %7B

Fix #2727 Server crash on startup with JEI