diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-03-06 04:18:21 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-03-06 04:18:21 +0800 |
| commit | 12223ae029f3d206ebb19ba0cd134e3c36827315 (patch) | |
| tree | 85c1743dfb0855aef23855a92240279a0a019eec /src | |
| parent | 2bf1e9f370a4c52a61575f0405425a51c670abed (diff) | |
| download | RoughlyEnoughItems-12223ae029f3d206ebb19ba0cd134e3c36827315.tar.gz RoughlyEnoughItems-12223ae029f3d206ebb19ba0cd134e3c36827315.tar.bz2 RoughlyEnoughItems-12223ae029f3d206ebb19ba0cd134e3c36827315.zip | |
3.0.7
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src')
38 files changed, 398 insertions, 226 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 552e2a9cb..17afa2d4a 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -276,14 +276,14 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { if (screen instanceof ContainerScreen) ScreenHelper.setLastContainerScreen((ContainerScreen<?>) screen); boolean alreadyAdded = false; - for (Element element : Lists.newArrayList(screenHooks.cloth_getInputListeners())) + for (Element element : Lists.newArrayList(screenHooks.cloth_getChildren())) if (ContainerScreenOverlay.class.isAssignableFrom(element.getClass())) if (alreadyAdded) - screenHooks.cloth_getInputListeners().remove(element); + screenHooks.cloth_getChildren().remove(element); else alreadyAdded = true; if (!alreadyAdded) - screenHooks.cloth_getInputListeners().add(ScreenHelper.getLastOverlay(true, false)); + screenHooks.cloth_getChildren().add(ScreenHelper.getLastOverlay(true, false)); }); ClothClientHooks.SCREEN_RENDER_POST.register((minecraftClient, screen, i, i1, v) -> { if (shouldReturn(screen.getClass())) diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index 207e51dd1..d0f310649 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -36,9 +36,8 @@ public interface ClientHelper { /** * @return the api instance of {@link ClientHelperImpl} */ - @SuppressWarnings("deprecation") static ClientHelper getInstance() { - return ClientHelperImpl.instance; + return ClientHelperImpl.getInstance(); } /** diff --git a/src/main/java/me/shedaniel/rei/api/REIHelper.java b/src/main/java/me/shedaniel/rei/api/REIHelper.java new file mode 100644 index 000000000..99a5e0415 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/api/REIHelper.java @@ -0,0 +1,42 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api; + +import me.shedaniel.rei.gui.widget.TextFieldWidget; +import me.shedaniel.rei.impl.ScreenHelper; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public interface REIHelper { + static REIHelper getInstance() { + return ScreenHelper.getInstance(); + } + + boolean isDarkThemeEnabled(); + + TextFieldWidget getSearchTextField(); + + List<ItemStack> getInventoryStacks(); +} diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java index 1149b9be0..826c0add1 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java @@ -30,7 +30,6 @@ import me.shedaniel.rei.gui.entries.SimpleRecipeEntry; import me.shedaniel.rei.gui.widget.PanelWidget; import me.shedaniel.rei.gui.widget.RecipeBaseWidget; import me.shedaniel.rei.gui.widget.Widget; -import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.util.Identifier; import org.jetbrains.annotations.ApiStatus; @@ -99,7 +98,7 @@ public interface RecipeCategory<T extends RecipeDisplay> { @ApiStatus.OverrideOnly default void drawCategoryBackground(Rectangle bounds, int mouseX, int mouseY, float delta) { PanelWidget.render(bounds, -1); - if (ScreenHelper.isDarkModeEnabled()) { + if (REIHelper.getInstance().isDarkThemeEnabled()) { DrawableHelper.fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, 0xFF404040); DrawableHelper.fill(bounds.x + 17, bounds.y + 19, bounds.x + bounds.width - 17, bounds.y + 31, 0xFF404040); } else { diff --git a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java index afc1f4b1a..2e61a9bcc 100644 --- a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java +++ b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java @@ -27,6 +27,7 @@ import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.api.Point; import me.shedaniel.math.impl.PointHelper; +import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.gui.widget.TextFieldWidget; import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.client.MinecraftClient; @@ -73,7 +74,7 @@ public class OverlaySearchField extends TextFieldWidget { public void laterRender(int int_1, int int_2, float float_1) { RenderSystem.disableDepthTest(); - setEditableColor(isMain && ContainerScreenOverlay.getEntryListWidget().getAllStacks().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching && isMain ? -852212 : (containsMouse(PointHelper.fromMouse()) || isFocused()) ? (ScreenHelper.isDarkModeEnabled() ? -17587 : -1) : -6250336); + setEditableColor(isMain && ContainerScreenOverlay.getEntryListWidget().getAllStacks().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching && isMain ? -852212 : (containsMouse(PointHelper.fromMouse()) || isFocused()) ? (REIHelper.getInstance().isDarkThemeEnabled() ? -17587 : -1) : -6250336); setSuggestion(!isFocused() && getText().isEmpty() ? I18n.translate("text.rei.search.field.suggestion") : null); super.render(int_1, int_2, float_1); RenderSystem.enableDepthTest(); @@ -82,7 +83,7 @@ public class OverlaySearchField extends TextFieldWidget { @Override protected void renderSuggestion(int x, int y) { if (containsMouse(PointHelper.fromMouse()) || isFocused()) - this.font.drawWithShadow(this.font.trimToWidth(this.getSuggestion(), this.getWidth()), x, y, ScreenHelper.isDarkModeEnabled() ? 0xccddaa3d : 0xddeaeaea); + this.font.drawWithShadow(this.font.trimToWidth(this.getSuggestion(), this.getWidth()), x, y, REIHelper.getInstance().isDarkThemeEnabled() ? 0xccddaa3d : 0xddeaeaea); else this.font.drawWithShadow(this.font.trimToWidth(this.getSuggestion(), this.getWidth()), x, y, -6250336); } diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java b/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java index 6ada23c54..4b9a88f0c 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeDisplayExporter.java @@ -79,7 +79,7 @@ public final class RecipeDisplayExporter extends Widget { private void exportRecipe(Rectangle rectangle, List<Widget> widgets) { Framebuffer framebuffer = new Framebuffer(rectangle.width * 8, rectangle.height * 8, true, MinecraftClient.IS_SYSTEM_MAC); framebuffer.setClearColor(0, 0, 0, 0); - // int color = ScreenHelper.isDarkModeEnabled() ? -13750738 : -3750202; + // int color = REIHelper.getInstance().isDarkThemeEnabled() ? -13750738 : -3750202; // framebuffer.setClearColor(((color >> 16) & 0xFF) / 255f, ((color >> 8) & 0xFF) / 255f, (color & 0xFF) / 255f, ((color >> 24) & 0xFF) / 255f); framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC); RenderSystem.pushMatrix(); diff --git a/src/main/java/me/shedaniel/rei/gui/StackToNoticeScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeScreen.java index 93325e92f..3bd6f0afe 100644 --- a/src/main/java/me/shedaniel/rei/gui/StackToNoticeScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeScreen.java @@ -24,13 +24,20 @@ package me.shedaniel.rei.gui; import me.shedaniel.rei.api.EntryStack; +import net.minecraft.util.Identifier; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal -public interface StackToNoticeScreen { +public interface RecipeScreen { @ApiStatus.Internal void addIngredientStackToNotice(EntryStack stack); @ApiStatus.Internal void addResultStackToNotice(EntryStack stack); + + @ApiStatus.Internal + Identifier getCurrentCategory(); + + @ApiStatus.Internal + void recalculateCategoryPage(); }
\ No newline at end of file diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index a678ce12c..e6e5bccdc 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -32,6 +32,7 @@ import me.shedaniel.math.api.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.*; import me.shedaniel.rei.gui.widget.*; +import me.shedaniel.rei.impl.ClientHelperImpl; import me.shedaniel.rei.impl.ScreenHelper; import me.shedaniel.rei.utils.CollectionUtils; import net.minecraft.client.MinecraftClient; @@ -41,11 +42,11 @@ import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.sound.PositionedSoundInstance; +import net.minecraft.client.util.NarratorManager; import net.minecraft.client.util.Window; import net.minecraft.client.util.math.Matrix4f; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.LiteralText; import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -57,46 +58,47 @@ import java.util.*; import java.util.function.Supplier; @ApiStatus.Internal -public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { +public class RecipeViewingScreen extends Screen implements RecipeScreen { public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); - private final List<Widget> preWidgets; - private final List<Widget> widgets; - private final Map<Rectangle, List<Widget>> recipeBounds; - private final List<TabWidget> tabs; + private final List<Widget> preWidgets = Lists.newArrayList(); + private final List<Widget> widgets = Lists.newArrayList(); + private final Map<Rectangle, List<Widget>> recipeBounds = Maps.newHashMap(); + private final List<TabWidget> tabs = Lists.newArrayList(); private final Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap; private final List<RecipeCategory<?>> categories; + private final RecipeCategory<RecipeDisplay> selectedCategory; public int guiWidth; public int guiHeight; - public int page, categoryPages; + public int page; + public int categoryPages = -1; public int largestWidth, largestHeight; - public boolean choosePageActivated; + public boolean choosePageActivated = false; public RecipeChoosePageWidget recipeChoosePageWidget; private int tabsPerPage = 5; private Rectangle bounds; - @Nullable private CategoryBaseWidget workingStationsBaseWidget; - private RecipeCategory<RecipeDisplay> selectedCategory; + @Nullable + private CategoryBaseWidget workingStationsBaseWidget; private ButtonWidget recipeBack, recipeNext, categoryBack, categoryNext; private EntryStack ingredientStackToNotice = EntryStack.empty(); private EntryStack resultStackToNotice = EntryStack.empty(); - public RecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap) { - super(new LiteralText("")); - this.categoryPages = 0; - this.preWidgets = Lists.newArrayList(); - this.widgets = Lists.newArrayList(); - this.recipeBounds = Maps.newHashMap(); + public RecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> categoriesMap, @Nullable Identifier category) { + super(NarratorManager.EMPTY); Window window = MinecraftClient.getInstance().getWindow(); this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, 176, 150); this.categoriesMap = categoriesMap; - this.categories = Lists.newArrayList(); - for (RecipeCategory<?> category : RecipeHelper.getInstance().getAllCategories()) { - if (categoriesMap.containsKey(category)) - categories.add(category); + this.categories = Lists.newArrayList(categoriesMap.keySet()); + RecipeCategory<?> selected = categories.get(0); + if (category != null) { + for (RecipeCategory<?> recipeCategory : categories) { + if (recipeCategory.getIdentifier().equals(category)) { + selected = recipeCategory; + break; + } + } } - this.selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(0); - this.tabs = new ArrayList<>(); - this.choosePageActivated = false; + this.selectedCategory = (RecipeCategory<RecipeDisplay>) selected; } @ApiStatus.Internal @@ -138,6 +140,16 @@ public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { this.resultStackToNotice = stack; } + @Override + public Identifier getCurrentCategory() { + return selectedCategory.getIdentifier(); + } + + @Override + public void recalculateCategoryPage() { + this.categoryPages = -1; + } + @Nullable public CategoryBaseWidget getWorkingStationsBaseWidget() { return workingStationsBaseWidget; @@ -202,10 +214,13 @@ public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { this.widgets.clear(); this.largestWidth = width - 100; this.largestHeight = Math.max(height - 36, 100); - int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), display -> selectedCategory.getDisplayWidth(display), (Comparator<Integer>) Comparator.naturalOrder()).orElse(150); + int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), selectedCategory::getDisplayWidth, Comparator.naturalOrder()).orElse(150); this.guiWidth = maxWidthDisplay + 20; this.guiHeight = MathHelper.floor(MathHelper.clamp((double) (selectedCategory.getDisplayHeight() + 4) * (getRecipesPerPage() + 1) + 36, 100, largestHeight)); this.tabsPerPage = Math.max(5, MathHelper.floor((guiWidth - 20d) / tabSize)); + if (this.categoryPages == -1) { + this.categoryPages = Math.max(0, categories.indexOf(selectedCategory) / tabsPerPage); + } this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight); this.page = MathHelper.clamp(page, 0, getTotalPages(selectedCategory) - 1); ButtonWidget w, w2; @@ -227,10 +242,7 @@ public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { currentCategoryIndex--; if (currentCategoryIndex < 0) currentCategoryIndex = categories.size() - 1; - selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(currentCategoryIndex); - categoryPages = MathHelper.floor(currentCategoryIndex / (double) tabsPerPage); - page = 0; - RecipeViewingScreen.this.init(); + ClientHelperImpl.getInstance().openRecipeViewingScreen(categoriesMap, categories.get(currentCategoryIndex).getIdentifier(), ingredientStackToNotice, resultStackToNotice); }).tooltip(() -> I18n.translate("text.rei.previous_category"))); widgets.add(LabelWidget.createClickable(new Point(bounds.getCenterX(), bounds.getY() + 7), selectedCategory.getCategoryName(), clickableLabelWidget -> { MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); @@ -241,10 +253,7 @@ public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { currentCategoryIndex++; if (currentCategoryIndex >= categories.size()) currentCategoryIndex = 0; - selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(currentCategoryIndex); - categoryPages = MathHelper.floor(currentCategoryIndex / (double) tabsPerPage); - page = 0; - RecipeViewingScreen.this.init(); + ClientHelperImpl.getInstance().openRecipeViewingScreen(categoriesMap, categories.get(currentCategoryIndex).getIdentifier(), ingredientStackToNotice, resultStackToNotice); }).tooltip(() -> I18n.translate("text.rei.next_category"))); categoryBack.enabled = categories.size() > 1; categoryNext.enabled = categories.size() > 1; @@ -281,21 +290,13 @@ public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { int j = i + categoryPages * tabsPerPage; if (categories.size() > j) { TabWidget tab; - tabs.add(tab = new TabWidget(i, tabSize, bounds.x + bounds.width / 2 - Math.min(categories.size() - categoryPages * tabsPerPage, tabsPerPage) * tabSize / 2, bounds.y, 0, tabV) { - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (containsMouse(mouseX, mouseY)) { - MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - if (getId() + categoryPages * tabsPerPage == categories.indexOf(selectedCategory)) - return false; - selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(getId() + categoryPages * tabsPerPage); - page = 0; - RecipeViewingScreen.this.init(); - return true; - } + tabs.add(tab = TabWidget.create(i, tabSize, bounds.x + bounds.width / 2 - Math.min(categories.size() - categoryPages * tabsPerPage, tabsPerPage) * tabSize / 2, bounds.y, 0, tabV, widget -> { + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + if (widget.getId() + categoryPages * tabsPerPage == categories.indexOf(selectedCategory)) return false; - } - }); + ClientHelperImpl.getInstance().openRecipeViewingScreen(categoriesMap, categories.get(widget.getId() + categoryPages * tabsPerPage).getIdentifier(), ingredientStackToNotice, resultStackToNotice); + return true; + })); tab.setRenderer(categories.get(j), categories.get(j).getLogo(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * tabsPerPage == categories.indexOf(selectedCategory)); } } @@ -398,7 +399,7 @@ public class RecipeViewingScreen extends Screen implements StackToNoticeScreen { selectedCategory.drawCategoryBackground(bounds, mouseX, mouseY, delta); else { PanelWidget.render(bounds, -1); - if (ScreenHelper.isDarkModeEnabled()) { + if (REIHelper.getInstance().isDarkThemeEnabled()) { fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, 0xFF404040); fill(bounds.x + 17, bounds.y + 19, bounds.x + bounds.width - 17, bounds.y + 30, 0xFF404040); } else { diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index fc9e287b4..7ba09f59d 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.gui; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; @@ -34,6 +33,7 @@ import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.*; import me.shedaniel.rei.gui.entries.RecipeEntry; import me.shedaniel.rei.gui.widget.*; +import me.shedaniel.rei.impl.ClientHelperImpl; import me.shedaniel.rei.impl.ScreenHelper; import me.shedaniel.rei.utils.CollectionUtils; import net.minecraft.client.MinecraftClient; @@ -46,11 +46,12 @@ import net.minecraft.client.resource.language.I18n; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.NarratorManager; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.LiteralText; import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; +import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; @@ -58,50 +59,42 @@ import java.util.Map; import java.util.Optional; @ApiStatus.Internal -public class VillagerRecipeViewingScreen extends Screen implements StackToNoticeScreen { +public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen { private final Map<RecipeCategory<?>, List<RecipeDisplay>> categoryMap; private final List<RecipeCategory<?>> categories; - private final List<Widget> widgets; - private final List<ButtonWidget> buttonWidgets; - private final List<RecipeEntry> recipeRenderers; - private final List<TabWidget> tabs; + private final List<Widget> widgets = Lists.newArrayList(); + private final List<ButtonWidget> buttonWidgets = Lists.newArrayList(); + private final List<RecipeEntry> recipeRenderers = Lists.newArrayList(); + private final List<TabWidget> tabs = Lists.newArrayList(); public Rectangle bounds, scrollListBounds; private int tabsPerPage = 8; - private int selectedCategoryIndex, selectedRecipeIndex; - private double scroll; + private int selectedCategoryIndex = 0; + private int selectedRecipeIndex = 0; + private double scrollAmount = 0; private double target; private long start; private long duration; - private float scrollBarAlpha; - private float scrollBarAlphaFuture; + private float scrollBarAlpha = 0; + private float scrollBarAlphaFuture = 0; private long scrollBarAlphaFutureTime = -1; - private boolean draggingScrollBar; - private int tabsPage; + private boolean draggingScrollBar = false; + private int tabsPage = -1; private EntryStack ingredientStackToNotice = EntryStack.empty(); private EntryStack resultStackToNotice = EntryStack.empty(); - public VillagerRecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> map) { - super(new LiteralText("")); - this.widgets = Lists.newArrayList(); - this.categoryMap = Maps.newLinkedHashMap(); - this.selectedCategoryIndex = 0; - this.selectedRecipeIndex = 0; - this.scrollBarAlpha = 0; - this.scrollBarAlphaFuture = 0; - this.scroll = 0; - this.draggingScrollBar = false; - this.tabsPage = 0; - this.categories = Lists.newArrayList(); - this.buttonWidgets = Lists.newArrayList(); - this.tabs = Lists.newArrayList(); - this.recipeRenderers = Lists.newArrayList(); - RecipeHelper.getInstance().getAllCategories().forEach(category -> { - if (map.containsKey(category)) { - categories.add(category); - categoryMap.put(category, map.get(category)); + public VillagerRecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> categoryMap, @Nullable Ide |
