/
JeiRuntime.java
69 lines (58 loc) · 2.08 KB
/
JeiRuntime.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
package mezz.jei;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.gui.IAdvancedGuiHandler;
import mezz.jei.gui.ItemListOverlay;
import mezz.jei.gui.recipes.RecipesGui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
public class JeiRuntime implements IJeiRuntime {
private final RecipeRegistry recipeRegistry;
private final ItemListOverlay itemListOverlay;
private final RecipesGui recipesGui;
private final IngredientRegistry ingredientRegistry;
private final List<IAdvancedGuiHandler<?>> advancedGuiHandlers;
public JeiRuntime(RecipeRegistry recipeRegistry, ItemListOverlay itemListOverlay, RecipesGui recipesGui, IngredientRegistry ingredientRegistry, List<IAdvancedGuiHandler<?>> advancedGuiHandlers) {
this.recipeRegistry = recipeRegistry;
this.itemListOverlay = itemListOverlay;
this.recipesGui = recipesGui;
this.ingredientRegistry = ingredientRegistry;
this.advancedGuiHandlers = advancedGuiHandlers;
}
public void close() {
if (itemListOverlay.isOpen()) {
itemListOverlay.close();
}
if (recipesGui.isOpen()) {
recipesGui.close();
}
}
@Override
public RecipeRegistry getRecipeRegistry() {
return recipeRegistry;
}
@Override
public ItemListOverlay getItemListOverlay() {
return itemListOverlay;
}
@Override
public RecipesGui getRecipesGui() {
return recipesGui;
}
public IngredientRegistry getIngredientRegistry() {
return ingredientRegistry;
}
public List<IAdvancedGuiHandler<?>> getActiveAdvancedGuiHandlers(GuiScreen guiScreen) {
List<IAdvancedGuiHandler<?>> activeAdvancedGuiHandler = new ArrayList<IAdvancedGuiHandler<?>>();
if (guiScreen instanceof GuiContainer) {
for (IAdvancedGuiHandler<?> advancedGuiHandler : advancedGuiHandlers) {
Class<?> guiContainerClass = advancedGuiHandler.getGuiContainerClass();
if (guiContainerClass.isInstance(guiScreen)) {
activeAdvancedGuiHandler.add(advancedGuiHandler);
}
}
}
return activeAdvancedGuiHandler;
}
}