/
JeiStarter.java
109 lines (94 loc) · 5.44 KB
/
JeiStarter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package mezz.jei.startup;
import mezz.jei.Internal;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.helpers.IModIdHelper;
import mezz.jei.api.runtime.IIngredientFilter;
import mezz.jei.bookmarks.BookmarkList;
import mezz.jei.config.BookmarkConfig;
import mezz.jei.config.IClientConfig;
import mezz.jei.config.IEditModeConfig;
import mezz.jei.config.IIngredientFilterConfig;
import mezz.jei.config.IWorldConfig;
import mezz.jei.gui.GuiEventHandler;
import mezz.jei.gui.GuiScreenHelper;
import mezz.jei.gui.overlay.GridAlignment;
import mezz.jei.gui.overlay.IngredientGrid;
import mezz.jei.gui.overlay.IngredientGridWithNavigation;
import mezz.jei.gui.overlay.IngredientListOverlay;
import mezz.jei.gui.overlay.bookmarks.BookmarkOverlay;
import mezz.jei.gui.overlay.bookmarks.LeftAreaDispatcher;
import mezz.jei.gui.recipes.RecipesGui;
import mezz.jei.gui.textures.Textures;
import mezz.jei.ingredients.IngredientFilter;
import mezz.jei.ingredients.IngredientFilterApi;
import mezz.jei.ingredients.IngredientManager;
import mezz.jei.input.InputHandler;
import mezz.jei.load.PluginCaller;
import mezz.jei.load.PluginHelper;
import mezz.jei.load.PluginLoader;
import mezz.jei.load.registration.GuiHandlerRegistration;
import mezz.jei.load.registration.RecipeTransferRegistration;
import mezz.jei.plugins.jei.JeiInternalPlugin;
import mezz.jei.plugins.vanilla.VanillaPlugin;
import mezz.jei.recipes.RecipeManager;
import mezz.jei.recipes.RecipeTransferManager;
import mezz.jei.runtime.JeiRuntime;
import mezz.jei.util.ErrorUtil;
import mezz.jei.util.LoggedTimer;
import java.util.List;
public class JeiStarter {
private boolean started;
public void start(
List<IModPlugin> plugins,
Textures textures,
IClientConfig clientConfig,
IEditModeConfig editModeConfig,
IIngredientFilterConfig ingredientFilterConfig,
IWorldConfig worldConfig,
BookmarkConfig bookmarkConfig,
IModIdHelper modIdHelper
) {
ErrorUtil.checkNotEmpty(plugins, "plugins");
LoggedTimer totalTime = new LoggedTimer();
totalTime.start("Starting JEI");
boolean debugMode = clientConfig.isDebugModeEnabled();
VanillaPlugin vanillaPlugin = PluginHelper.getPluginWithClass(VanillaPlugin.class, plugins);
JeiInternalPlugin jeiInternalPlugin = PluginHelper.getPluginWithClass(JeiInternalPlugin.class, plugins);
ErrorUtil.checkNotNull(vanillaPlugin, "vanilla plugin");
PluginHelper.sortPlugins(plugins, vanillaPlugin, jeiInternalPlugin);
PluginLoader pluginLoader = new PluginLoader(plugins, vanillaPlugin, textures, clientConfig, editModeConfig, ingredientFilterConfig, bookmarkConfig, modIdHelper, debugMode);
GuiHandlerRegistration guiHandlerRegistration = pluginLoader.getGuiHandlerRegistration();
IngredientManager ingredientManager = pluginLoader.getIngredientManager();
IngredientFilter ingredientFilter = pluginLoader.getIngredientFilter();
BookmarkList bookmarkList = pluginLoader.getBookmarkList();
RecipeManager recipeManager = pluginLoader.getRecipeManager();
RecipeTransferRegistration recipeTransferRegistration = pluginLoader.getRecipeTransferRegistration();
RecipeTransferManager recipeTransferManager = new RecipeTransferManager(recipeTransferRegistration.getRecipeTransferHandlers());
LoggedTimer timer = new LoggedTimer();
timer.start("Building runtime");
GuiScreenHelper guiScreenHelper = guiHandlerRegistration.createGuiScreenHelper(ingredientManager);
RecipesGui recipesGui = new RecipesGui(recipeManager, recipeTransferManager, ingredientManager, modIdHelper, clientConfig);
IngredientGrid ingredientListGrid = new IngredientGrid(GridAlignment.LEFT, editModeConfig, ingredientFilterConfig, clientConfig, worldConfig, guiScreenHelper, recipesGui);
IngredientGridWithNavigation ingredientListGridNavigation = new IngredientGridWithNavigation(ingredientFilter, worldConfig, guiScreenHelper, ingredientListGrid, worldConfig);
IngredientListOverlay ingredientListOverlay = new IngredientListOverlay(ingredientFilter, ingredientManager, guiScreenHelper, ingredientListGridNavigation, clientConfig, worldConfig);
IngredientGrid bookmarkListGrid = new IngredientGrid(GridAlignment.RIGHT, editModeConfig, ingredientFilterConfig, clientConfig, worldConfig, guiScreenHelper, recipesGui);
IngredientGridWithNavigation bookmarkListGridNavigation = new IngredientGridWithNavigation(bookmarkList, () -> "", guiScreenHelper, bookmarkListGrid, worldConfig);
BookmarkOverlay bookmarkOverlay = new BookmarkOverlay(bookmarkList, textures, bookmarkListGridNavigation, clientConfig, worldConfig);
IIngredientFilter ingredientFilterApi = new IngredientFilterApi(ingredientFilter, worldConfig);
JeiRuntime jeiRuntime = new JeiRuntime(recipeManager, ingredientListOverlay, bookmarkOverlay, recipesGui, ingredientFilterApi, ingredientManager);
Internal.setRuntime(jeiRuntime);
timer.stop();
PluginCaller.callOnPlugins("Sending Runtime", plugins, p -> p.onRuntimeAvailable(jeiRuntime));
LeftAreaDispatcher leftAreaDispatcher = new LeftAreaDispatcher(guiScreenHelper);
leftAreaDispatcher.addContent(bookmarkOverlay);
GuiEventHandler guiEventHandler = new GuiEventHandler(guiScreenHelper, leftAreaDispatcher, ingredientListOverlay);
Internal.setGuiEventHandler(guiEventHandler);
InputHandler inputHandler = new InputHandler(recipesGui, ingredientFilter, ingredientManager, ingredientListOverlay, editModeConfig, worldConfig, guiScreenHelper, leftAreaDispatcher, bookmarkList);
Internal.setInputHandler(inputHandler);
started = true;
totalTime.stop();
}
public boolean hasStarted() {
return started;
}
}