diff options
Diffstat (limited to 'src')
26 files changed, 200 insertions, 97 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 2ca21b884..ef0b78006 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -152,7 +152,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { lastSync.set(System.currentTimeMillis()); } RecipeManager recipeManager = MinecraftClient.getInstance().getNetworkHandler().getRecipeManager(); - if (ConfigManager.getInstance().getConfig().doesRegisterRecipesInAnotherThread()) { + if (ConfigObject.getInstance().doesRegisterRecipesInAnotherThread()) { CompletableFuture.runAsync(() -> ((RecipeHelperImpl) RecipeHelper.getInstance()).recipesLoaded(recipeManager), SYNC_RECIPES); } else { ((RecipeHelperImpl) RecipeHelper.getInstance()).recipesLoaded(recipeManager); @@ -245,7 +245,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { AtomicLong lastSync = new AtomicLong(-1); ClothClientHooks.SYNC_RECIPES.register((minecraftClient, recipeManager, synchronizeRecipesS2CPacket) -> syncRecipes(lastSync)); ClothClientHooks.SCREEN_ADD_BUTTON.register((minecraftClient, screen, abstractButtonWidget) -> { - if (ConfigManager.getInstance().getConfig().doesDisableRecipeBook() && screen instanceof AbstractContainerScreen && abstractButtonWidget instanceof TexturedButtonWidget) + if (ConfigObject.getInstance().doesDisableRecipeBook() && screen instanceof AbstractContainerScreen && abstractButtonWidget instanceof TexturedButtonWidget) if (((RecipeBookButtonWidgetHooks) abstractButtonWidget).rei_getTexture().equals(recipeButtonTex)) return ActionResult.FAIL; return ActionResult.PASS; diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index 75cb0ab1b..aaaab48f1 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -27,8 +27,10 @@ public interface ConfigManager { /** * Gets the config instance * + * @deprecated Use {@link ConfigObject#getInstance()} * @return the config instance */ + @Deprecated ConfigObject getConfig(); /** diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java index 1b9ad64db..3b9f5ca6c 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -18,6 +18,11 @@ import java.lang.annotation.Target; public interface ConfigObject { + @SuppressWarnings("deprecation") + static ConfigObject getInstance() { + return ConfigManager.getInstance().getConfig(); + } + boolean isLighterButtonHover(); void setLighterButtonHover(boolean lighterButtonHover); @@ -84,6 +89,10 @@ public interface ConfigObject { boolean isFavoritesEnabled(); + boolean doDisplayFavoritesTooltip(); + + boolean doDisplayFavoritesOnTheLeft(); + InputUtil.KeyCode getFavoriteKeybind(); @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 165a61b93..05bf4653a 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -118,7 +118,7 @@ public interface DisplayHelper { * @return the item list bounds */ default Rectangle getItemListArea(Rectangle rectangle) { - return new Rectangle(rectangle.x + 1, rectangle.y + 2 + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + (ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled() ? 0 : 22), rectangle.width - 2, rectangle.height - (ConfigManager.getInstance().getConfig().getSearchFieldLocation() != SearchFieldLocation.CENTER ? 27 + 22 : 27) + (!ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled() ? 0 : 22)); + return new Rectangle(rectangle.x + 1, rectangle.y + 2 + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + (ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22), rectangle.width - 2, rectangle.height - (ConfigObject.getInstance().getSearchFieldLocation() != SearchFieldLocation.CENTER ? 27 + 22 : 27) + (!ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22)); } /** diff --git a/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java b/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java index 407cce19a..708bab589 100644 --- a/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java +++ b/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java @@ -9,7 +9,6 @@ import me.shedaniel.rei.api.DisplayHelper; import me.shedaniel.rei.api.EntryRegistry; import me.shedaniel.rei.api.REIPluginEntry; import me.shedaniel.rei.api.RecipeHelper; -import me.shedaniel.rei.api.annotations.ToBeRemoved; public interface REIPluginV0 extends REIPluginEntry { diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 260489abb..61ccee599 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -100,7 +100,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { this.window = MinecraftClient.getInstance().getWindow(); @SuppressWarnings({"RawTypeCanBeGeneric", "rawtypes"}) DisplayHelper.DisplayBoundsHandler boundsHandler = DisplayHelper.getInstance().getResponsibleBoundsHandler(MinecraftClient.getInstance().currentScreen.getClass()); - this.rectangle = ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? boundsHandler.getLeftBounds(MinecraftClient.getInstance().currentScreen) : boundsHandler.getRightBounds(MinecraftClient.getInstance().currentScreen); + this.rectangle = ConfigObject.getInstance().isLeftHandSidePanel() ? boundsHandler.getLeftBounds(MinecraftClient.getInstance().currentScreen) : boundsHandler.getRightBounds(MinecraftClient.getInstance().currentScreen); widgets.add(ENTRY_LIST_WIDGET); ENTRY_LIST_WIDGET.updateArea(boundsHandler, ScreenHelper.getSearchField() == null ? "" : null); if (ScreenHelper.getSearchField() == null) { @@ -111,8 +111,8 @@ public class ContainerScreenOverlay extends WidgetWithBounds { ScreenHelper.getSearchField().setChangedListener(s -> { ENTRY_LIST_WIDGET.updateSearch(s); }); - if (!ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled()) { - widgets.add(buttonLeft = new ButtonWidget(new Rectangle(rectangle.x, rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), I18n.translate("text.rei.left_arrow")) { + if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { + widgets.add(buttonLeft = new ButtonWidget(new Rectangle(rectangle.x, rectangle.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), I18n.translate("text.rei.left_arrow")) { @Override public void onPressed() { ENTRY_LIST_WIDGET.previousPage(); @@ -136,7 +136,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { return isNotInExclusionZones(mouseX, mouseY) && super.containsMouse(mouseX, mouseY); } }); - widgets.add(buttonRight = new ButtonWidget(new Rectangle(rectangle.x + rectangle.width - 18, rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), I18n.translate("text.rei.right_arrow")) { + widgets.add(buttonRight = new ButtonWidget(new Rectangle(rectangle.x + rectangle.width - 18, rectangle.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), I18n.translate("text.rei.right_arrow")) { @Override public void onPressed() { ENTRY_LIST_WIDGET.nextPage(); @@ -162,7 +162,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { }); } - widgets.add(new ButtonWidget(new Rectangle(ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10, 10, 20, 20), "") { + widgets.add(new ButtonWidget(new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10, 10, 20, 20), "") { @Override public void onPressed() { if (Screen.hasShiftDown()) { @@ -213,11 +213,11 @@ public class ContainerScreenOverlay extends WidgetWithBounds { return isNotInExclusionZones(mouseX, mouseY) && super.containsMouse(mouseX, mouseY); } }); - if (ConfigManager.getInstance().getConfig().doesShowUtilsButtons()) { - widgets.add(new ButtonWidget(new Rectangle(ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 55 : 35, 10, 20, 20), "") { + if (ConfigObject.getInstance().doesShowUtilsButtons()) { + widgets.add(new ButtonWidget(new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getScaledWidth() - 55 : 35, 10, 20, 20), "") { @Override public void onPressed() { - MinecraftClient.getInstance().player.sendChatMessage(ConfigManager.getInstance().getConfig().getGamemodeCommand().replaceAll("\\{gamemode}", getNextGameMode(Screen.hasShiftDown()).getName())); + MinecraftClient.getInstance().player.sendChatMessage(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", getNextGameMode(Screen.hasShiftDown()).getName())); } @Override @@ -241,12 +241,12 @@ public class ContainerScreenOverlay extends WidgetWithBounds { return isNotInExclusionZones(mouseX, mouseY) && super.containsMouse(mouseX, mouseY); } }); - int xxx = ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10; + int xxx = ConfigObject.getInstance().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10; for (Weather weather : Weather.values()) { widgets.add(new ButtonWidget(new Rectangle(xxx, 35, 20, 20), "") { @Override public void onPressed() { - MinecraftClient.getInstance().player.sendChatMessage(ConfigManager.getInstance().getConfig().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT))); + MinecraftClient.getInstance().player.sendChatMessage(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT))); } @Override @@ -273,11 +273,11 @@ public class ContainerScreenOverlay extends WidgetWithBounds { return isNotInExclusionZones(mouseX, mouseY) && super.containsMouse(mouseX, mouseY); } }); - xxx += ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? -25 : 25; + xxx += ConfigObject.getInstance().isLeftHandSidePanel() ? -25 : 25; } } - if (!ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled()) { - widgets.add(new ClickableLabelWidget(new Point(rectangle.x + (rectangle.width / 2), rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), "") { + if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { + widgets.add(new ClickableLabelWidget(new Point(rectangle.x + (rectangle.width / 2), rectangle.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), "") { @Override public void render(int mouseX, int mouseY, float delta) { setText(String.format("%s/%s", ENTRY_LIST_WIDGET.getPage() + 1, ENTRY_LIST_WIDGET.getTotalPages())); @@ -303,7 +303,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { }.clickable(ENTRY_LIST_WIDGET.getTotalPages() != 1)); buttonLeft.enabled = buttonRight.enabled = ENTRY_LIST_WIDGET.getTotalPages() != 1; } - if (ConfigManager.getInstance().getConfig().isCraftableFilterEnabled()) + if (ConfigObject.getInstance().isCraftableFilterEnabled()) this.widgets.add(toggleButtonWidget = new CraftableToggleButtonWidget(getCraftableToggleArea()) { @Override public void onPressed() { @@ -377,8 +377,8 @@ public class ContainerScreenOverlay extends WidgetWithBounds { } private Rectangle getTextFieldArea() { - int widthRemoved = ConfigManager.getInstance().getConfig().isCraftableFilterEnabled() ? 22 : 2; - SearchFieldLocation searchFieldLocation = ConfigManager.getInstance().getConfig().getSearchFieldLocation(); + int widthRemoved = ConfigObject.getInstance().isCraftableFilterEnabled() ? 22 : 2; + SearchFieldLocation searchFieldLocation = ConfigObject.getInstance().getSearchFieldLocation(); if (searchFieldLocation == SearchFieldLocation.BOTTOM_SIDE) return new Rectangle(rectangle.x + 2, window.getScaledHeight() - 22, rectangle.width - 6 - widthRemoved, 18); if (searchFieldLocation == SearchFieldLocation.TOP_SIDE) @@ -417,13 +417,13 @@ public class ContainerScreenOverlay extends WidgetWithBounds { init(); else { for (DisplayHelper.DisplayBoundsHandler<?> handler : DisplayHelper.getInstance().getSortedBoundsHandlers(minecraft.currentScreen.getClass())) { - if (handler != null && handler.shouldRecalculateArea(!ConfigManager.getInstance().getConfig().isLeftHandSidePanel(), rectangle)) { + if (handler != null && handler.shouldRecalculateArea(!ConfigObject.getInstance().isLeftHandSidePanel(), rectangle)) { init(); break; } } } - // if (DisplayHelper.getInstance().getBaseBoundsHandler() != null && DisplayHelper.getInstance().getBaseBoundsHandler().shouldRecalculateArea(!ConfigManager.getInstance().getConfig().isLeftHandSidePanel(), rectangle)) + // if (DisplayHelper.getInstance().getBaseBoundsHandler() != null && DisplayHelper.getInstance().getBaseBoundsHandler().shouldRecalculateArea(!ConfigObject.getInstance().isLeftHandSidePanel(), rectangle)) // entryListWidget.updateArea(DisplayHelper.getInstance().getResponsibleBoundsHandler()); // else if (ConfigManager.getInstance().isCraftableOnlyEnabled() && ((currentStacks.size() != ScreenHelper.inventoryStacks.size()) || !hasSameListContent(new LinkedList<>(ScreenHelper.inventoryStacks), currentStacks))) { @@ -445,7 +445,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); DiffuseLighting.disable(); this.renderWidgets(mouseX, mouseY, delta); - if (MinecraftClient.getInstance().currentScreen instanceof AbstractContainerScreen && ConfigManager.getInstance().getConfig().areClickableRecipeArrowsEnabled()) { + if (MinecraftClient.getInstance().currentScreen instanceof AbstractContainerScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) { ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen; for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas()) if (area.getScreenClass().equals(MinecraftClient.getInstance().currentScreen.getClass())) @@ -503,7 +503,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { public void renderWidgets(int int_1, int int_2, float float_1) { if (!ScreenHelper.isOverlayVisible()) return; - if (!ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled()) + if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) buttonLeft.enabled = buttonRight.enabled = ENTRY_LIST_WIDGET.getTotalPages() != 1; widgets.forEach(widget -> { DiffuseLighting.disable(); @@ -517,7 +517,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { if (!ScreenHelper.isOverlayVisible()) return false; if (isInside(PointHelper.fromMouse())) { - if (!ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled()) { + if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { if (amount > 0 && buttonLeft.enabled) buttonLeft.onPressed(); else if (amount < 0 && buttonRight.enabled) @@ -586,7 +586,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { public boolean mouseClicked(double double_1, double double_2, int int_1) { if (!ScreenHelper.isOverlayVisible()) return false; - if (MinecraftClient.getInstance().currentScreen instanceof AbstractContainerScreen && ConfigManager.getInstance().getConfig().areClickableRecipeArrowsEnabled()) { + if (MinecraftClient.getInstance().currentScreen instanceof AbstractContainerScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) { ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen; for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas()) if (area.getScreenClass().equals(MinecraftClient.getInstance().currentScreen.getClass())) @@ -617,7 +617,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { if (!rectangle.contains(mouseX, mouseY)) return false; for (DisplayHelper.DisplayBoundsHandler<?> handler : DisplayHelper.getInstance().getSortedBoundsHandlers(MinecraftClient.getInstance().currentScreen.getClass())) { - ActionResult in = handler.isInZone(!ConfigManager.getInstance().getConfig().isLeftHandSidePanel(), mouseX, mouseY); + ActionResult in = handler.isInZone(!ConfigObject.getInstance().isLeftHandSidePanel(), mouseX, mouseY); if (in != ActionResult.PASS) return in == ActionResult.SUCCESS; } diff --git a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java index b6bb8600c..7667e5cb5 100644 --- a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java +++ b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java @@ -5,8 +5,10 @@ package me.shedaniel.rei.gui; +import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.impl.PointHelper; +import me.shedaniel.rei.api.annotations.Internal; import me.shedaniel.rei.gui.widget.TextFieldWidget; import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.client.MinecraftClient; @@ -16,18 +18,37 @@ import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.InputUtil; import net.minecraft.sound.SoundEvents; +import java.util.List; + public class OverlaySearchField extends TextFieldWidget { public static boolean isSearching = false; public long keybindFocusTime = -1; public int keybindFocusKey = -1; protected long lastClickedTime = -1; + private List<String> history = Lists.newArrayListWithCapacity(100); OverlaySearchField(int x, int y, int width, int height) { super(x, y, width, height); setMaxLength(10000); } + @Override + public void setFocused(boolean boolean_1) { + if (isFocused() != boolean_1) addToHistory(getText()); + super.setFocused(boolean_1); + } + + @Deprecated + @Internal + public void addToHistory(String text) { + if (!text.isEmpty()) { + history.removeIf(str -> str.equalsIgnoreCase(text)); + history.add(text); + if (history.size() > 100) history.remove(0); + } + } + @SuppressWarnings("deprecation") public void laterRender(int int_1, int int_2, float float_1) { DiffuseLighting.disable(); @@ -70,8 +91,26 @@ public class OverlaySearchField extends TextFieldWidget { public boolean keyPressed(int int_1, int int_2, int int_3) { if (this.isVisible() && this.isFocused()) if (int_1 == 257 || int_1 == 335) { + addToHistory(getText()); setFocused(false); return true; + } else if (int_1 == 265) { + int i = history.indexOf(getText()) - 1; + if (i < -1 && getText().isEmpty()) i = history.size() - 1; + else if (i < -1) { + addToHistory(getText()); + i = history.size() - 2; + } + if (i >= 0) { + setText(history.get(i)); + return true; + } + } else if (int_1 == 264) { + int i = history.indexOf(getText()) + 1; + if (i > 0) { + setText(i < history.size() ? history.get(i) : ""); + return true; + } } return super.keyPressed(int_1, int_2, int_3); } diff --git a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java index 9becf4d21..01efcca98 100644 --- a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java @@ -7,10 +7,7 @@ package me.shedaniel.rei.gui; import com.google.common.collect.Lists; import me.shedaniel.math.api.Rectangle; -import me.shedaniel.rei.api.ClientHelper; -import me.shedaniel.rei.api.ConfigManager; -import me.shedaniel.rei.api.RecipeCategory; -import me.shedaniel.rei.api.RecipeDisplay; +import me.shedaniel.rei.api.*; import me.shedaniel.rei.gui.config.RecipeScreenType; import me.shedaniel.rei.gui.widget.ButtonWidget; import me.shedaniel.rei.gui.widget.Widget; @@ -52,7 +49,7 @@ public class PreRecipeViewingScreen extends Screen { this.widgets.add(new ButtonWidget(new Rectangle(width / 2 - 100, height - 40, 200, 20), I18n.translate("text.rei.select")) { @Override public void onPressed() { - ConfigManager.getInstance().getConfig().setRecipeScreenType(original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER); + ConfigObject.getInstance().setRecipeScreenType(original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER); ConfigManager.getInstance().saveConfig(); ClientHelper.getInstance().openRecipeViewingScreen(map); } diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 1b42f991b..f2309588b 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -61,10 +61,10 @@ public class RecipeViewingScreen extends Screen { this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, 176, 186); this.categoriesMap = categoriesMap; this.categories = Lists.newArrayList(); - RecipeHelper.getInstance().getAllCategories().forEach(category -> { + for (RecipeCategory<?> category : RecipeHelper.getInstance().getAllCategories()) { if (categoriesMap.containsKey(category)) categories.add(category); - }); + } this.selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(0); this.tabs = new ArrayList<>(); this.choosePageActivated = false; @@ -361,12 +361,12 @@ public class RecipeViewingScreen extends Screen { if (selectedCategory.getFixedRecipesPerPage() > 0) return selectedCategory.getFixedRecipesPerPage() - 1; int height = selectedCategory.getDisplayHeight(); - return MathHelper.clamp(MathHelper.floor(((double) largestHeight - 40d) / ((double) height + 7d)) - 1, 0, Math.min(ConfigManager.getInstance().getConfig().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1)); + return MathHelper.clamp(MathHelper.floor(((double) largestHeight - 40d) / ((double) height + 7d)) - 1, 0, Math.min(ConfigObject.getInstance().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1)); } private int getRecipesPerPageByHeight() { int height = selectedCategory.getDisplayHeight(); - return MathHelper.clamp(MathHelper.floor(((double) guiHeight - 40d) / ((double) height + 7d)), 0, Math.min(ConfigManager.getInstance().getConfig().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1)); + return MathHelper.clamp(MathHelper.floor(((double) guiHeight - 40d) / ((double) height + 7d)), 0, Math.min(ConfigObject.getInstance().getMaxRecipePerPage() - 1, selectedCategory.getMaximumRecipePerPage() - 1)); } @Override diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index d8e3094b3..c23493b23 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -324,7 +324,7 @@ public class VillagerRecipeViewingScreen extends Screen { @Override public void render(int mouseX, int mouseY, float delta) { - if (ConfigManager.getInstance().getConfig().doesVillagerScreenHavePermanentScrollBar()) { + if (ConfigObject.getInstance().doesVillagerScreenHavePermanentScrollBar()) { scrollBarAlphaFutureTime = System.currentTimeMillis(); scrollBarAlphaFuture = 0; scrollBarAlpha = 1; diff --git a/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java index 6853d0934..a1cb25d16 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java @@ -146,7 +146,7 @@ public class AutoCraftingButtonWidget extends ButtonWidget { @Override protected int getTextureId(boolean boolean_1) { - return !visible ? 0 : boolean_1 && enabled ? (ConfigManager.getInstance().getConfig().isLighterButtonHover() ? 4 : 3) : 1; + return !visible ? 0 : boolean_1 && enabled ? (ConfigObject.getInstance().isLighterButtonHover() ? 4 : 3) : 1; } @Override @@ -171,7 +171,7 @@ public class AutoCraftingButtonWidget extends ButtonWidget { public boolean keyPressed(int int_1, int int_2, int int_3) { if (displaySupplier.get().getRecipeLocation().isPresent() && ClientHelper.getInstance().getCopyRecipeIdentifierKeyBinding().matchesKey(int_1, int_2) && containsMouse(PointHelper.fromMouse())) { minecraft.keyboard.setClipboard(displaySupplier.get().getRecipeLocation().get().toString()); - if (ConfigManager.getInstance().getConfig().isToastDisplayedOnCopyIdentifier()) { + if (ConfigObject.getInstance().isToastDisplayedOnCopyIdentifier()) { CopyRecipeIdentifierToast.addToast(I18n.translate("msg.rei.copied_recipe_id"), I18n.translate("msg.rei.recipe_id_details", displaySupplier.get().getRecipeLocation().get().toString())); } return true; diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java index e542ec26b..315f272a6 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java @@ -8,7 +8,7 @@ package me.shedaniel.rei.gui.widget; import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; -import me.shedaniel.rei.api.ConfigManager; +import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.client.gui.Element; import net.minecraft.client.sound.PositionedSoundInstance; @@ -58,7 +58,7 @@ public abstract class ButtonWidget extends WidgetWithBounds { if (!this.enabled) { int_1 = 0; } else if (boolean_1) { - int_1 = ConfigManager.getInstance().getConfig().isLighterButtonHover() ? 4 : 3; // 2 is the old blue highlight, 3 is the 1.15 outline, 4 is the 1.15 online + light hover + int_1 = ConfigObject.getInstance().isLighterButtonHover() ? 4 : 3; // 2 is the old blue highlight, 3 is the 1.15 outline, 4 is the 1.15 online + light hover } return int_1; diff --git a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java index 9804cabc5..64862a4e3 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -26,8 +26,10 @@ import net.minecraft.client.render.DiffuseLighting; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexFormats; import net.minecraft.client.resource.language.I18n; +import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.InputUtil; import net.minecraft.item.ItemGroup; +import net.minecraft.sound.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -42,7 +44,7 @@ public class EntryListWidget extends WidgetWithBounds { private static final boolean LAZY = true; private static final String SPACE = " ", EMPTY = ""; - private static final Supplier<Boolean> RENDER_EXTRA_CONFIG = Con |
