Skip to content

Commit 91c9ae7

Browse files
committed
A bit of a clean
1 parent 3a509db commit 91c9ae7

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/main/java/turing/tmb/RecipeIndex.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
import java.util.function.Function;
1010

1111
public class RecipeIndex implements IRecipeIndex {
12-
private final TMBRuntime runtime;
1312
protected final List<IRecipeCategory<?>> categories = new ArrayList<>();
1413
protected final List<String> hiddenCategories = new ArrayList<>();
1514
protected final Map<IRecipeCategory<?>, List<ITypedIngredient<?>>> catalysts = new HashMap<>();
1615
protected final Map<IRecipeCategory<?>, List<IRecipeTranslator<?>>> recipeLists = new HashMap<>();
1716
protected final Map<ILookupContext, List<Pair<IRecipeCategory<?>, IRecipeTranslator<?>>>> recipeLookupCache = new HashMap<>();
1817

1918
public RecipeIndex(TMBRuntime runtime) {
20-
this.runtime = runtime;
19+
2120
}
2221

2322
protected void clear() {

src/main/java/turing/tmb/TMB.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static void onClientStart() {
7272
category1.withComponent(new BooleanOptionComponent(TMBOptions.isRecipeViewEnabled));
7373
OptionsPages.GENERAL.withComponent(category1);
7474
loadTMB();
75-
runtime.index.gatherIngredients();
75+
runtime.gatherIngredients();
7676
}
7777

7878
@Override
@@ -90,7 +90,7 @@ private static void loadTMB() {
9090
plugin.registerIngredientTypes(runtime);
9191
plugin.registerRecipeCategories(runtime);
9292
}
93-
runtime.getRecipeIndex().loadLists();
93+
runtime.loadLists();
9494
for (ITMBPlugin plugin : plugins) {
9595
plugin.registerIngredients(runtime);
9696
plugin.registerRecipeCatalysts(runtime);
@@ -220,15 +220,15 @@ public static void reloadTMB() {
220220
clear();
221221
gatherPlugins(true);
222222
loadTMB();
223-
runtime.index.gatherIngredients();
223+
runtime.gatherIngredients();
224224
}
225225

226226
public static void registerPlugin(ITMBPlugin plugin) {
227227
plugins.add(plugin);
228228
}
229229

230230
public static ITMBRuntime getRuntime() {
231-
if (!runtime.isReady) {
231+
if (!runtime.isReady()) {
232232
throw new IllegalStateException("Attempt to get runtime before it is ready!");
233233
}
234234
return runtime;

src/main/java/turing/tmb/TMBRuntime.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class TMBRuntime implements ITMBRuntime {
3434
protected final GuiHelper guiHelper = new GuiHelper(this);
3535
public final List<ITypedIngredient<?>> favourites = new ArrayList<>();
3636
protected final Map<RecipeIngredient, IRecipeTranslator<?>> defaultRecipes = new HashMap<>();
37-
protected final Map<Class<? extends Screen>, RecipeFiller> recipeFillers = new HashMap<>();
37+
protected final Map<Class<? extends Screen>, RecipeFiller<?, ?>> recipeFillers = new HashMap<>();
3838
protected boolean isReady;
3939

4040
protected TMBRuntime() {
@@ -50,6 +50,19 @@ protected void clear() {
5050
recipeFillers.clear();
5151
}
5252

53+
protected void gatherIngredients() {
54+
index.gatherIngredients();
55+
}
56+
57+
protected void loadLists() {
58+
recipeIndex.loadLists();
59+
}
60+
61+
@Override
62+
public boolean isReady() {
63+
return isReady;
64+
}
65+
5366
@Override
5467
public void showRecipe(ILookupContext lookup) {
5568
List<Pair<IRecipeCategory<?>, IRecipeTranslator<?>>> results = recipeIndex.searchRecipes(lookup);
@@ -117,7 +130,7 @@ public RecipeIndex getRecipeIndex() {
117130
}
118131

119132
@Override
120-
public Map<Class<? extends Screen>, RecipeFiller> getRecipeFillers() {
133+
public Map<Class<? extends Screen>, RecipeFiller<?, ?>> getRecipeFillers() {
121134
return recipeFillers;
122135
}
123136

src/main/java/turing/tmb/api/runtime/ITMBRuntime.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface ITMBRuntime {
2727

2828
IRecipeIndex getRecipeIndex();
2929

30-
Map<Class<? extends Screen>, RecipeFiller> getRecipeFillers();
30+
Map<Class<? extends Screen>, RecipeFiller<?, ?>> getRecipeFillers();
3131

3232
void showRecipe(ILookupContext lookup);
3333

@@ -38,4 +38,6 @@ public interface ITMBRuntime {
3838
Map<RecipeIngredient, IRecipeTranslator<?>> getDefaultRecipes();
3939

4040
List<ITypedIngredient<?>> getFavourites();
41+
42+
boolean isReady();
4143
}

0 commit comments

Comments
 (0)