diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/RecipeTab.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/RecipeTab.java index 61b1d9ef7e..4df75f7670 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/RecipeTab.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/RecipeTab.java @@ -4,9 +4,4 @@ public interface RecipeTab extends RecipeAreaDisplay { ItemStack icon(); - - /** - * If this tab does not use the search bar then no-op this. - */ - void initializeSearchResults(String query); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingRecipeResults.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingRecipeResults.java index d6d7ea56f4..834440a55d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingRecipeResults.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingRecipeResults.java @@ -16,7 +16,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.recipebook.RecipeBookResults; import net.minecraft.client.gui.widget.ToggleButtonWidget; import net.minecraft.component.DataComponentTypes; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingTab.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingTab.java index 953c1da1a1..7b69f72544 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingTab.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockCraftingTab.java @@ -21,32 +21,40 @@ public void initialize(MinecraftClient client, int parentLeft, int parentTop) { @Override public void draw(DrawContext context, int x, int y, int mouseX, int mouseY, float delta) { assert recipeBook.searchField != null; - recipeBook.searchField.render(context, mouseX, mouseY, delta); - recipeBook.filterOption.render(context, mouseX, mouseY, delta); - results.draw(context, x, y, mouseX, mouseY, delta); + + if (ItemRepository.filesImported()) { + recipeBook.searchField.render(context, mouseX, mouseY, delta); + recipeBook.filterOption.render(context, mouseX, mouseY, delta); + results.draw(context, x, y, mouseX, mouseY, delta); + } else { + //68 is from 137 / 2 and 137 is the height from which the page flip buttons are rendered + context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, "Loading...", x + (SkyblockRecipeBookWidget.IMAGE_WIDTH / 2), y + 68, 0xFFFFFFFF); + } } @Override public void drawTooltip(DrawContext context, int x, int y) { - results.drawTooltip(context, x, y); + if (ItemRepository.filesImported()) results.drawTooltip(context, x, y); } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (results.mouseClicked(mouseX, mouseY, button)) { - return true; - } else { - if (recipeBook.searchField != null) { - boolean magnifyingGlassClicked = recipeBook.searchFieldRect != null && recipeBook.searchFieldRect.contains(MathHelper.floor(mouseX), MathHelper.floor(mouseY)); + if (ItemRepository.filesImported()) { + if (results.mouseClicked(mouseX, mouseY, button)) { + return true; + } else { + if (recipeBook.searchField != null) { + boolean magnifyingGlassClicked = recipeBook.searchFieldRect != null && recipeBook.searchFieldRect.contains(MathHelper.floor(mouseX), MathHelper.floor(mouseY)); - if (magnifyingGlassClicked || recipeBook.searchField.mouseClicked(mouseX, mouseY, button)) { - results.closeRecipeView(); - recipeBook.searchField.setFocused(true); + if (magnifyingGlassClicked || recipeBook.searchField.mouseClicked(mouseX, mouseY, button)) { + results.closeRecipeView(); + recipeBook.searchField.setFocused(true); - return true; + return true; + } + recipeBook.searchField.setFocused(false); + return recipeBook.filterOption.mouseClicked(mouseX, mouseY, button); } - recipeBook.searchField.setFocused(false); - return recipeBook.filterOption.mouseClicked(mouseX, mouseY, button); } } @@ -55,18 +63,11 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { @Override public boolean keyPressed(double mouseX, double mouseY, int keyCode, int scanCode, int modifiers) { - return this.results.keyPressed(mouseX, mouseY, keyCode, scanCode, modifiers); + return ItemRepository.filesImported() ? this.results.keyPressed(mouseX, mouseY, keyCode, scanCode, modifiers) : false; } @Override public void updateSearchResults(String query, FilterOption filterOption, boolean refresh) { - results.updateSearchResults(query, filterOption, refresh); - } - - @Override - public void initializeSearchResults(String query) { - if (ItemRepository.filesImported()) { - updateSearchResults(query, FilterOption.ALL); - } + if (ItemRepository.filesImported()) results.updateSearchResults(query, filterOption, refresh); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockRecipeBookWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockRecipeBookWidget.java index b1767acd0f..adc9993bca 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockRecipeBookWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/SkyblockRecipeBookWidget.java @@ -31,7 +31,7 @@ * Based on {@link net.minecraft.client.gui.screen.recipebook.RecipeBookWidget}. */ public class SkyblockRecipeBookWidget extends RecipeBookWidget { - private static final int IMAGE_WIDTH = RecipeBookWidget.field_32408; + protected static final int IMAGE_WIDTH = RecipeBookWidget.field_32408; private static final int IMAGE_HEIGHT = RecipeBookWidget.field_32409; //Corresponds to field_32410 in RecipeBookWidget private static final int OFFSET_X_POSITION = 86; @@ -106,7 +106,7 @@ protected void reset() { //Tab Init this.currentTab.left().initialize(this.client, left, top); - this.currentTab.left().initializeSearchResults(defaultSearchText); + this.currentTab.left().updateSearchResults(defaultSearchText, FilterOption.ALL); } @Override diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/UpcomingEventsTab.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/UpcomingEventsTab.java index c30df2943b..ee91d458f4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/UpcomingEventsTab.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipebook/UpcomingEventsTab.java @@ -97,9 +97,6 @@ public ItemStack icon() { @Override public void updateSearchResults(String query, FilterOption filterOption, boolean refresh) {} - @Override - public void initializeSearchResults(String query) {} - private static class EventRenderer { private static final int HEIGHT = 20;