Skip to content

Commit 03645b7

Browse files
committed
Tried to prevent a crash.
Made IRecipeCategory#getTooltips better.
1 parent 4d39007 commit 03645b7

7 files changed

Lines changed: 15 additions & 7 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ loader_version=0.15.6-bta.7
99

1010
# Other Mods
1111
mod_menu_version=3.0.0
12-
halplibe_version=5.1.5
12+
halplibe_version=5.2.1
1313

1414
# Mod
1515
mod_version=1.1.0

src/main/java/turing/tmb/api/recipe/IRecipeCategory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.jetbrains.annotations.Nullable;
44
import turing.tmb.api.drawable.IDrawable;
55
import turing.tmb.api.drawable.IIngredientList;
6+
import turing.tmb.api.ingredient.IIngredientType;
67
import turing.tmb.api.runtime.ITMBRuntime;
78

89
import java.util.Collections;
@@ -24,7 +25,7 @@ default IDrawable getIcon() {
2425

2526
IRecipeLayout getRecipeLayout();
2627

27-
default List<String> getTooltips(R recipe, int mouseX, int mouseY) {
28+
default <I, T extends IIngredientType<I>> List<String> getTooltips(R recipe, IRecipeSlot<I, T> slot, int mouseX, int mouseY) {
2829
return Collections.emptyList();
2930
}
3031
}

src/main/java/turing/tmb/client/ScreenTMBRecipe.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public void render(int mx, int my, float partialTick) {
302302
int mouseY = my - ((this.height - this.ySize) / 2) - 14 - ((category.getBackground().getHeight() + 4) * i);
303303
renderer.getTooltip(tooltipBuilder, ingredient.getIngredient(), isCtrl, isShift);
304304
slot.getTooltips(tooltipBuilder, ingredient.getIngredient(), mouseX, mouseY, isCtrl, isShift);
305-
tooltipBuilder.addAll(category.getTooltips(recipe, mouseX, mouseY));
305+
tooltipBuilder.addAll(category.getTooltips(recipe, slot, mouseX, mouseY));
306306
if (list instanceof IngredientList && ((IngredientList) list).itemGroup != null) {
307307
tooltipBuilder.add(TextFormatting.formatted(I18n.getInstance().translateKeyAndFormat("tmb.tooltip.itemGroup", ((IngredientList) list).itemGroup), TextFormatting.LIGHT_GRAY));
308308
}
@@ -381,9 +381,10 @@ private void renderCatalysts(IRecipeCategory<?> category, int mx, int my, IToolt
381381

382382
GL11.glEnable(3042);
383383
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
384-
this.mc.textureManager.loadTexture("/assets/tmb/textures/gui/gui_vanilla.png").bind();
385384

386385
for (int i = 0; i < catalysts.size(); i++) {
386+
this.mc.textureManager.loadTexture("/assets/tmb/textures/gui/gui_vanilla.png").bind();
387+
387388
ITypedIngredient<Object> ingredient = (ITypedIngredient<Object>) catalysts.get(i);
388389
int x = ((this.width - this.xSize) / 2) - 20;
389390
int y = ((this.height - this.ySize) / 2) + (4 + (22 * i));

src/main/java/turing/tmb/client/TMBRenderer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public static void renderHeader(int mouseX, int mouseY, int width, int height, M
7777

7878
public static void onTick() {
7979
if (!show) return;
80+
if(search == null) return;
8081
if (search.isFocused) {
8182
search.updateCursorCounter();
8283
}

src/main/java/turing/tmb/mixin/client/MinecraftMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void checkKeybind(CallbackInfo ci) {
3737
if (debounce > 0) debounce--;
3838
if (debounce <= 0) {
3939
if (((IKeybinds) gameSettings).toomanyblocks$getKeyHideTMB().isPressed()) {
40-
if (!TMBRenderer.search.isFocused) {
40+
if (TMBRenderer.search != null && !TMBRenderer.search.isFocused) {
4141
if (currentScreen instanceof ScreenInventoryCreative) {
4242
if (((ScreenInventoryCreativeAccessor) currentScreen).getSearchField().isFocused) {
4343
return;

src/main/java/turing/tmb/vanilla/MobInfoCategory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
import turing.tmb.api.VanillaTypes;
2222
import turing.tmb.api.drawable.IDrawable;
2323
import turing.tmb.api.drawable.IIngredientList;
24+
import turing.tmb.api.ingredient.IIngredientType;
2425
import turing.tmb.api.recipe.ILookupContext;
2526
import turing.tmb.api.recipe.IRecipeCategory;
2627
import turing.tmb.api.recipe.IRecipeLayout;
28+
import turing.tmb.api.recipe.IRecipeSlot;
2729
import turing.tmb.api.runtime.ITMBRuntime;
2830
import turing.tmb.client.DrawableBlank;
2931
import turing.tmb.client.DrawableIngredient;
@@ -173,7 +175,7 @@ public void drawRecipe(ITMBRuntime runtime, MobInfoRecipeTranslator recipe, IRec
173175
}
174176

175177
@Override
176-
public List<String> getTooltips(MobInfoRecipeTranslator recipe, int mouseX, int mouseY) {
178+
public <I, T extends IIngredientType<I>> List<String> getTooltips(MobInfoRecipeTranslator recipe, IRecipeSlot<I, T> slot, int mouseX, int mouseY) {
177179
if (recipe.getOriginal().getDrops() != null && recipe.getOriginal().getDrops().length > 0) {
178180
List<String> tooltips = new ArrayList<>();
179181

@@ -199,6 +201,7 @@ public List<String> getTooltips(MobInfoRecipeTranslator recipe, int mouseX, int
199201
return Collections.emptyList();
200202
}
201203

204+
202205
@Override
203206
public IRecipeLayout getRecipeLayout() {
204207
return new RecipeLayoutBuilder()

src/main/java/turing/tmb/vanilla/TrommelRecipeCategory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
import turing.tmb.api.drawable.IDrawable;
1212
import turing.tmb.api.drawable.IDrawableAnimated;
1313
import turing.tmb.api.drawable.IIngredientList;
14+
import turing.tmb.api.ingredient.IIngredientType;
1415
import turing.tmb.api.recipe.ILookupContext;
1516
import turing.tmb.api.recipe.IRecipeCategory;
1617
import turing.tmb.api.recipe.IRecipeLayout;
18+
import turing.tmb.api.recipe.IRecipeSlot;
1719
import turing.tmb.api.runtime.ITMBRuntime;
1820
import turing.tmb.client.DrawableAnimated;
1921
import turing.tmb.client.DrawableBlank;
@@ -77,7 +79,7 @@ public void drawRecipe(ITMBRuntime runtime, TrommelRecipeTranslator recipe, IRec
7779
}
7880

7981
@Override
80-
public List<String> getTooltips(TrommelRecipeTranslator recipe, int mouseX, int mouseY) {
82+
public <I, T extends IIngredientType<I>> List<String> getTooltips(TrommelRecipeTranslator recipe, IRecipeSlot<I, T> slot, int mouseX, int mouseY) {
8183
List<String> tooltips = new ArrayList<>();
8284
for (int i = 0; i < 9; i++) {
8385
if (recipe.getOriginal().getOutput().getEntries().size() > i) {

0 commit comments

Comments
 (0)