forked from CleanroomMC/HadEnoughItems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternal.java
More file actions
169 lines (140 loc) · 4.84 KB
/
Internal.java
File metadata and controls
169 lines (140 loc) · 4.84 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package mezz.jei;
import com.google.common.base.Preconditions;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.bookmarks.BookmarkList;
import mezz.jei.color.ColorNamer;
import mezz.jei.gui.GuiEventHandler;
import mezz.jei.ingredients.CollapsedStackRegistry;
import mezz.jei.ingredients.IngredientFilter;
import mezz.jei.ingredients.IngredientRegistry;
import mezz.jei.input.InputHandler;
import mezz.jei.runtime.JeiHelpers;
import mezz.jei.runtime.JeiRuntime;
import mezz.jei.runtime.SubtypeRegistry;
import mezz.jei.startup.StackHelper;
import net.minecraftforge.common.MinecraftForge;
import javax.annotation.Nullable;
/**
* For HEI internal use only, these are normally accessed from the API.
*/
public final class Internal {
@Nullable
private static SubtypeRegistry subtypeRegistry;
@Nullable
private static StackHelper stackHelper;
@Nullable
private static JeiHelpers helpers;
@Nullable
private static JeiRuntime runtime;
@Nullable
private static IngredientRegistry ingredientRegistry;
@Nullable
private static ColorNamer colorNamer;
@Nullable
private static IngredientFilter ingredientFilter;
@Nullable
private static GuiEventHandler guiEventHandler;
@Nullable
private static InputHandler inputHandler;
@Nullable
private static BookmarkList bookmarkList;
@Nullable
private static CollapsedStackRegistry collapsedStackRegistry;
private Internal() {
}
public static ISubtypeRegistry getSubtypeRegistry() {
Preconditions.checkState(subtypeRegistry != null, "SubtypeRegistry has not been created yet.");
return subtypeRegistry;
}
public static void setSubtypeRegistry(SubtypeRegistry subtypeRegistry) {
Internal.subtypeRegistry = subtypeRegistry;
}
public static StackHelper getStackHelper() {
Preconditions.checkState(stackHelper != null, "StackHelper has not been created yet.");
return stackHelper;
}
public static void setStackHelper(StackHelper stackHelper) {
Internal.stackHelper = stackHelper;
}
public static JeiHelpers getHelpers() {
Preconditions.checkState(helpers != null, "JeiHelpers has not been created yet.");
return helpers;
}
public static void setHelpers(JeiHelpers helpers) {
Internal.helpers = helpers;
}
@Nullable
public static JeiRuntime getRuntime() {
return runtime;
}
public static void setRuntime(JeiRuntime runtime) {
JeiRuntime jeiRuntime = Internal.runtime;
if (jeiRuntime != null) {
jeiRuntime.close();
}
Internal.runtime = runtime;
}
public static IngredientRegistry getIngredientRegistry() {
Preconditions.checkState(ingredientRegistry != null, "Ingredient Registry has not been created yet.");
return ingredientRegistry;
}
public static void setIngredientRegistry(IngredientRegistry ingredientRegistry) {
Internal.ingredientRegistry = ingredientRegistry;
}
public static ColorNamer getColorNamer() {
Preconditions.checkState(colorNamer != null, "Color Namer has not been created yet.");
return colorNamer;
}
public static void setColorNamer(ColorNamer colorNamer) {
Internal.colorNamer = colorNamer;
}
public static boolean hasIngredientFilter() {
return ingredientFilter != null;
}
public static IngredientFilter getIngredientFilter() {
Preconditions.checkState(ingredientFilter != null, "Ingredient Filter has not been created yet.");
return ingredientFilter;
}
public static void setIngredientFilter(IngredientFilter ingredientFilter) {
if (Internal.ingredientFilter != null) {
MinecraftForge.EVENT_BUS.unregister(Internal.ingredientFilter);
}
Internal.ingredientFilter = ingredientFilter;
MinecraftForge.EVENT_BUS.register(ingredientFilter);
}
public static void setGuiEventHandler(GuiEventHandler guiEventHandler) {
if (Internal.guiEventHandler != null) {
MinecraftForge.EVENT_BUS.unregister(Internal.guiEventHandler);
}
Internal.guiEventHandler = guiEventHandler;
MinecraftForge.EVENT_BUS.register(guiEventHandler);
}
public static void setInputHandler(InputHandler inputHandler) {
if (Internal.inputHandler != null) {
MinecraftForge.EVENT_BUS.unregister(Internal.inputHandler);
}
Internal.inputHandler = inputHandler;
MinecraftForge.EVENT_BUS.register(inputHandler);
}
@Nullable
public static InputHandler getInputHandler() {
return inputHandler;
}
public static void setBookmarkList(BookmarkList bookmarkList) {
Internal.bookmarkList = bookmarkList;
}
public static BookmarkList getBookmarkList() {
Preconditions.checkState(bookmarkList != null, "Bookmark List has not been created yet.");
return bookmarkList;
}
public static CollapsedStackRegistry getCollapsedStackRegistry() {
if (collapsedStackRegistry == null) {
collapsedStackRegistry = CollapsedStackRegistry.getInstance();
}
return collapsedStackRegistry;
}
public static void setCollapsedStackRegistry(CollapsedStackRegistry registry) {
Internal.collapsedStackRegistry = registry;
CollapsedStackRegistry.setInstance(registry);
}
}