From b2d0af7a9fb0d16f14b294802f6718ac315d0de8 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 20 Dec 2019 17:31:30 +0800 Subject: 3.2.27 --- .../me/shedaniel/rei/RoughlyEnoughItemsCore.java | 13 ++-- .../me/shedaniel/rei/api/BaseBoundsHandler.java | 27 +++++++- .../java/me/shedaniel/rei/api/ConfigManager.java | 2 +- .../java/me/shedaniel/rei/api/ConfigObject.java | 16 +++-- .../java/me/shedaniel/rei/api/DisplayHelper.java | 36 ++++++++-- src/main/java/me/shedaniel/rei/api/EntryStack.java | 8 ++- .../rei/api/ItemStackRenderOverlayHook.java | 2 +- .../java/me/shedaniel/rei/api/ObjectHolder.java | 37 ++++++++-- .../rei/api/annotations/Experimental.java | 3 +- .../me/shedaniel/rei/api/annotations/Internal.java | 3 +- .../shedaniel/rei/api/annotations/ToBeRemoved.java | 3 +- .../shedaniel/rei/gui/ContainerScreenOverlay.java | 38 ++++------ .../me/shedaniel/rei/gui/OverlaySearchField.java | 9 ++- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 8 +-- .../rei/gui/VillagerRecipeViewingScreen.java | 3 +- .../rei/gui/config/SearchFieldLocation.java | 4 +- .../me/shedaniel/rei/gui/entries/RecipeEntry.java | 3 +- .../rei/gui/widget/AutoCraftingButtonWidget.java | 3 +- .../shedaniel/rei/gui/widget/EntryListWidget.java | 55 +++++++-------- .../rei/gui/widget/FavoritesListWidget.java | 14 ++-- .../me/shedaniel/rei/gui/widget/LabelWidget.java | 6 +- .../me/shedaniel/rei/impl/AbstractEntryStack.java | 4 +- .../shedaniel/rei/impl/BaseBoundsHandlerImpl.java | 45 +++++++----- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 4 +- .../me/shedaniel/rei/impl/ConfigManagerImpl.java | 15 ++-- .../me/shedaniel/rei/impl/ConfigObjectImpl.java | 81 ++++++++-------------- .../me/shedaniel/rei/impl/EmptyEntryStack.java | 41 ++++++++++- .../me/shedaniel/rei/impl/FluidEntryStack.java | 4 +- .../java/me/shedaniel/rei/impl/ItemEntryStack.java | 17 ++--- .../me/shedaniel/rei/impl/ObjectHolderImpl.java | 30 -------- .../me/shedaniel/rei/impl/RecipeHelperImpl.java | 46 ++++++------ .../java/me/shedaniel/rei/impl/ScreenHelper.java | 3 +- .../java/me/shedaniel/rei/impl/SearchArgument.java | 6 +- .../rei/mixin/MixinBrewingRecipeRegistry.java | 9 +-- .../me/shedaniel/rei/mixin/MixinItemStack.java | 2 +- .../me/shedaniel/rei/plugin/DefaultPlugin.java | 8 ++- .../plugin/DefaultPotionEffectExclusionZones.java | 8 +-- .../plugin/DefaultRecipeBookExclusionZones.java | 8 +-- .../autocrafting/DefaultCategoryHandler.java | 11 +-- .../plugin/crafting/DefaultCraftingCategory.java | 14 +++- .../plugin/crafting/DefaultCraftingDisplay.java | 3 +- .../shedaniel/rei/server/ContainerInfoHandler.java | 9 ++- .../me/shedaniel/rei/server/InputSlotCrafter.java | 3 +- .../me/shedaniel/rei/utils/CollectionUtils.java | 3 +- 44 files changed, 366 insertions(+), 301 deletions(-) (limited to 'src/main/java/me') diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index a93092bd5..416c6818d 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -8,7 +8,6 @@ package me.shedaniel.rei; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import me.shedaniel.cloth.hooks.ClothClientHooks; -import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.*; import me.shedaniel.rei.api.annotations.Internal; import me.shedaniel.rei.api.plugins.REIPluginV0; @@ -58,14 +57,10 @@ import java.util.concurrent.atomic.AtomicLong; @Internal public class RoughlyEnoughItemsCore implements ClientModInitializer { - @Internal - public static final Logger LOGGER; - @SuppressWarnings("deprecation") - private static final RecipeHelper RECIPE_HELPER = new RecipeHelperImpl(); - @SuppressWarnings("deprecation") - private static final EntryRegistry ENTRY_REGISTRY = new EntryRegistryImpl(); - @SuppressWarnings("deprecation") - private static final DisplayHelper DISPLAY_HELPER = new DisplayHelperImpl(); + @Internal public static final Logger LOGGER; + @SuppressWarnings("deprecation") private static final RecipeHelper RECIPE_HELPER = new RecipeHelperImpl(); + @SuppressWarnings("deprecation") private static final EntryRegistry ENTRY_REGISTRY = new EntryRegistryImpl(); + @SuppressWarnings("deprecation") private static final DisplayHelper DISPLAY_HELPER = new DisplayHelperImpl(); private static final Map plugins = Maps.newHashMap(); private static final ExecutorService SYNC_RECIPES = Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "REI-SyncRecipes")); private static ConfigManager configManager; diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java index 9bc6d1430..84b8574a6 100644 --- a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -5,11 +5,14 @@ package me.shedaniel.rei.api; +import com.google.common.collect.Lists; import me.shedaniel.math.api.Rectangle; +import me.shedaniel.rei.RoughlyEnoughItemsCore; import net.minecraft.client.gui.screen.Screen; import java.util.List; import java.util.function.Function; +import java.util.function.Supplier; public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler { /** @@ -19,11 +22,19 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler getCurrentExclusionZones(Class currentScreenClass, boolean isOnRightSide) { - return getCurrentExclusionZones(currentScreenClass, isOnRightSide, false); + return getExclusionZones(currentScreenClass, false); } - List getCurrentExclusionZones(Class currentScreenClass, boolean isOnRightSide, boolean sort); + @Deprecated + default List getCurrentExclusionZones(Class currentScreenClass, boolean isOnRightSide, boolean sort) { + return getExclusionZones(currentScreenClass, sort); + } + + List getExclusionZones(Class currentScreenClass, boolean sort); + + int supplierSize(); /** * Register an exclusion zone @@ -31,6 +42,16 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler the list of exclusion zones */ - void registerExclusionZones(Class screenClass, Function> supplier); + @Deprecated + default void registerExclusionZones(Class screenClass, Function> supplier) { + RoughlyEnoughItemsCore.LOGGER.warn("[REI] Someone is registering exclusion zones with the deprecated method: " + supplier.getClass().getName()); + registerExclusionZones(screenClass, () -> { + List zones = Lists.newArrayList(supplier.apply(false)); + zones.addAll(supplier.apply(true)); + return zones; + }); + } + + void registerExclusionZones(Class screenClass, Supplier> supplier); } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index aaaab48f1..ca11825ba 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -27,8 +27,8 @@ public interface ConfigManager { /** * Gets the config instance * - * @deprecated Use {@link ConfigObject#getInstance()} * @return the config instance + * @deprecated Use {@link ConfigObject#getInstance()} */ @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 3b9f5ca6c..2c9b9bed2 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -43,7 +43,12 @@ public interface ConfigObject { boolean isToastDisplayedOnCopyIdentifier(); - boolean doesRenderEntryExtraOverlay(); + @Deprecated + default boolean doesRenderEntryExtraOverlay() { + return doesRenderEntryEnchantmentGlint(); + } + + boolean doesRenderEntryEnchantmentGlint(); boolean isEntryListWidgetScrolled(); @@ -97,17 +102,14 @@ public interface ConfigObject { @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface AddInFrontKeyCode { - } + public @interface AddInFrontKeyCode {} @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface DontApplyFieldName { - } + public @interface DontApplyFieldName {} @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface UseEnumSelectorInstead { - } + public @interface UseEnumSelectorInstead {} } diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index e2a152488..1589ae43d 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -84,6 +84,20 @@ public interface DisplayHelper { */ Rectangle getRightBounds(T screen); + /** + * Checks if item slot can fit the screen + * + * @param left the left x coordinates of the stack + * @param top the top y coordinates for the stack + * @param screen the current screen + * @param fullBounds the current bounds + * @return whether the item slot can fit + * @see BaseBoundsHandler#registerExclusionZones(Class, BaseBoundsHandler.ExclusionZoneSupplier) for easier api + */ + default ActionResult canItemSlotWidgetFit(int left, int top, T screen, Rectangle fullBounds) { + return PASS; + } + /** * Checks if item slot can fit the screen * @@ -93,10 +107,11 @@ public interface DisplayHelper { * @param screen the current screen * @param fullBounds the current bounds * @return whether the item slot can fit - * @see BaseBoundsHandler#registerExclusionZones(Class, BaseBoundsHandler.ExclusionZoneSupplier) for easier api + * @deprecated use {@link #canItemSlotWidgetFit(int, int, Object, Rectangle)} */ + @Deprecated default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) { - return PASS; + return canItemSlotWidgetFit(left, top, screen, fullBounds); } /** @@ -106,8 +121,21 @@ public interface DisplayHelper { * @param mouseX mouse's x coordinates * @param mouseY mouse's y coordinates * @return whether mouse is inside the overlay + * @deprecated use {@link #isInZone(double, double)} */ + @Deprecated default ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) { + return isInZone(mouseX, mouseY); + } + + /** + * Checks if mouse is inside the overlay + * + * @param mouseX mouse's x coordinates + * @param mouseY mouse's y coordinates + * @return whether mouse is inside the overlay + */ + default ActionResult isInZone(double mouseX, double mouseY) { return PASS; } @@ -120,10 +148,10 @@ public interface DisplayHelper { default Rectangle getItemListArea(Rectangle rectangle) { 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)); } - + default Rectangle getFavoritesListArea(Rectangle rectangle) { int offset = 31 + (ConfigObject.getInstance().doesShowUtilsButtons() ? 25 : 0); - return new Rectangle(rectangle.x + 1, rectangle.y + 2 + offset, rectangle.width - 2, rectangle.height - 5- offset); + return new Rectangle(rectangle.x + 1, rectangle.y + 2 + offset, rectangle.width - 2, rectangle.height - 5 - offset); } /** diff --git a/src/main/java/me/shedaniel/rei/api/EntryStack.java b/src/main/java/me/shedaniel/rei/api/EntryStack.java index 3727a56b0..a7e03bc1e 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryStack.java +++ b/src/main/java/me/shedaniel/rei/api/EntryStack.java @@ -167,7 +167,10 @@ public interface EntryStack { void render(Rectangle bounds, int mouseX, int mouseY, float delta); public static enum Type { - ITEM, FLUID, EMPTY, RENDER + ITEM, + FLUID, + EMPTY, + RENDER } public static class Settings { @@ -192,7 +195,8 @@ public interface EntryStack { } public static class Item { - public static final Settings> RENDER_OVERLAY = new Settings(TRUE); + public static final Settings> RENDER_ENCHANTMENT_GLINT = new Settings(TRUE); + @Deprecated public static final Settings> RENDER_OVERLAY = RENDER_ENCHANTMENT_GLINT; private Item() { } diff --git a/src/main/java/me/shedaniel/rei/api/ItemStackRenderOverlayHook.java b/src/main/java/me/shedaniel/rei/api/ItemStackRenderOverlayHook.java index f4a9b71e1..2bdf92a4e 100644 --- a/src/main/java/me/shedaniel/rei/api/ItemStackRenderOverlayHook.java +++ b/src/main/java/me/shedaniel/rei/api/ItemStackRenderOverlayHook.java @@ -6,5 +6,5 @@ package me.shedaniel.rei.api; public interface ItemStackRenderOverlayHook { - void rei_setRenderOverlay(boolean b); + void rei_setRenderEnchantmentGlint(boolean b); } diff --git a/src/main/java/me/shedaniel/rei/api/ObjectHolder.java b/src/main/java/me/shedaniel/rei/api/ObjectHolder.java index d3b6189b1..bf1dd3b5d 100644 --- a/src/main/java/me/shedaniel/rei/api/ObjectHolder.java +++ b/src/main/java/me/shedaniel/rei/api/ObjectHolder.java @@ -5,18 +5,43 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.impl.ObjectHolderImpl; + public interface ObjectHolder { - int intValue(); + @SuppressWarnings("deprecation") + static ObjectHolder of(T o) { + return new ObjectHolderImpl<>(o); + } + + @Deprecated + default int intValue() { + return (int) (Object) value(); + } - long longValue(); + @Deprecated + default long longValue() { + return (long) (Object) value(); + } - boolean booleanValue(); + @Deprecated + default boolean booleanValue() { + return (boolean) (Object) value(); + } - float floatValue(); + @Deprecated + default float floatValue() { + return (float) (Object) value(); + } - double doubleValue(); + @Deprecated + default double doubleValue() { + return (double) (Object) value(); + } - String stringValue(); + @Deprecated + default String stringValue() { + return (String) value(); + } T value(); } \ No newline at end of file diff --git a/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java b/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java index 043b0daae..e1c3f73f4 100644 --- a/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java +++ b/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java @@ -13,5 +13,4 @@ import static java.lang.annotation.ElementType.*; @Retention(RetentionPolicy.RUNTIME) @Target(value = {CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) -public @interface Experimental { -} +public @interface Experimental {} diff --git a/src/main/java/me/shedaniel/rei/api/annotations/Internal.java b/src/main/java/me/shedaniel/rei/api/annotations/Internal.java index 4b120c1de..137286971 100644 --- a/src/main/java/me/shedaniel/rei/api/annotations/Internal.java +++ b/src/main/java/me/shedaniel/rei/api/annotations/Internal.java @@ -13,5 +13,4 @@ import static java.lang.annotation.ElementType.*; @Retention(RetentionPolicy.RUNTIME) @Target(value = {CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) -public @interface Internal { -} +public @interface Internal {} diff --git a/src/main/java/me/shedaniel/rei/api/annotations/ToBeRemoved.java b/src/main/java/me/shedaniel/rei/api/annotations/ToBeRemoved.java index cb026533b..88be1932e 100644 --- a/src/main/java/me/shedaniel/rei/api/annotations/ToBeRemoved.java +++ b/src/main/java/me/shedaniel/rei/api/annotations/ToBeRemoved.java @@ -13,5 +13,4 @@ import static java.lang.annotation.ElementType.*; @Retention(RetentionPolicy.RUNTIME) @Target(value = {CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) -public @interface ToBeRemoved { -} +public @interface ToBeRemoved {} diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index ae9151f63..70e284cdf 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -71,7 +71,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); matrixStack_1.translate(0.0D, 0.0D, getBlitOffset()); Matrix4f matrix4f_1 = matrixStack_1.peek().getModel(); - for(int lineIndex = 0; lineIndex < tooltipLines.size(); lineIndex++) { + for (int lineIndex = 0; lineIndex < tooltipLines.size(); lineIndex++) { font.draw(tooltipLines.get(lineIndex), x, currentY, -1, true, matrix4f_1, immediate, false, 0, 15728880); currentY += lineIndex == 0 ? 12 : 10; } @@ -253,7 +253,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { } }); int xxx = ConfigObject.getInstance().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10; - for(Weather weather : Weather.values()) { + for (Weather weather : Weather.values()) { widgets.add(new ButtonWidget(new Rectangle(xxx, 35, 20, 20), "") { @Override public void onPressed() { @@ -427,7 +427,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { if (shouldReInit) init(); else { - for(DisplayHelper.DisplayBoundsHandler handler : DisplayHelper.getInstance().getSortedBoundsHandlers(minecraft.currentScreen.getClass())) { + for (DisplayHelper.DisplayBoundsHandler handler : DisplayHelper.getInstance().getSortedBoundsHandlers(minecraft.currentScreen.getClass())) { if (handler != null && handler.shouldRecalculateArea(!ConfigObject.getInstance().isLeftHandSidePanel(), rectangle)) { init(); break; @@ -444,7 +444,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { if (MinecraftClient.getInstance().currentScreen instanceof AbstractContainerScreen) { ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen; int left = hooks.rei_getContainerLeft(), top = hooks.rei_getContainerTop(); - for(Slot slot : ((AbstractContainerScreen) MinecraftClient.getInstance().currentScreen).getContainer().slotList) + for (Slot slot : ((AbstractContainerScreen) MinecraftClient.getInstance().currentScreen).getContainer().slotList) if (!slot.hasStack() || !ENTRY_LIST_WIDGET.canLastSearchTermsBeAppliedTo(EntryStack.create(slot.getStack()))) fillGradient(left + slot.xPosition, top + slot.yPosition, left + slot.xPosition + 16, top + slot.yPosition + 16, -601874400, -601874400); } @@ -455,7 +455,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { this.renderWidgets(mouseX, mouseY, delta); if (MinecraftClient.getInstance().currentScreen instanceof AbstractContainerScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) { ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen; - for(RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas()) + for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas()) if (area.getScreenClass().equals(MinecraftClient.getInstance().currentScreen.getClass())) if (area.getRectangle().contains(mouseX - hooks.rei_getContainerLeft(), mouseY - hooks.rei_getContainerTop())) { String collect = CollectionUtils.mapAndJoinToString(area.getCategories(), identifier -> RecipeHelper.getInstance().getCategory(identifier).getCategoryName(), ", "); @@ -473,7 +473,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { } Screen currentScreen = MinecraftClient.getInstance().currentScreen; if (!(currentScreen instanceof RecipeViewingScreen) || !((RecipeViewingScreen) currentScreen).choosePageActivated) - for(QueuedTooltip queuedTooltip : QUEUED_TOOLTIPS) { + for (QueuedTooltip queuedTooltip : QUEUED_TOOLTIPS) { if (queuedTooltip != null) renderTooltip(queuedTooltip); } @@ -540,7 +540,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { if (favoritesListWidget != null && favoritesListWidget.mouseScrolled(i, j, amount)) return true; } - for(Widget widget : widgets) + for (Widget widget : widgets) if (widget != ENTRY_LIST_WIDGET && (favoritesListWidget == null || widget != favoritesListWidget) && widget.mouseScrolled(i, j, amount)) return true; return false; @@ -551,7 +551,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { if (ScreenHelper.isOverlayVisible()) { if (ScreenHelper.getSearchField().keyPressed(int_1, int_2, int_3)) return true; - for(Element listener : widgets) + for (Element listener : widgets) if (listener != ScreenHelper.getSearchField() && listener.keyPressed(int_1, int_2, int_3)) return true; } @@ -587,7 +587,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { return false; if (ScreenHelper.getSearchField().charTyped(char_1, int_1)) return true; - for(Element listener : widgets) + for (Element listener : widgets) if (listener != ScreenHelper.getSearchField() && listener.charTyped(char_1, int_1)) return true; return false; @@ -604,7 +604,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { return false; if (MinecraftClient.getInstance().currentScreen instanceof AbstractContainerScreen && ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) { ContainerScreenHooks hooks = (ContainerScreenHooks) MinecraftClient.getInstance().currentScreen; - for(RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas()) + for (RecipeHelper.ScreenClickArea area : RecipeHelper.getInstance().getScreenClickAreas()) if (area.getScreenClass().equals(MinecraftClient.getInstance().currentScreen.getClass())) if (area.getRectangle().contains(double_1 - hooks.rei_getContainerLeft(), double_2 - hooks.rei_getContainerTop())) { ClientHelper.getInstance().executeViewAllRecipesFromCategories(Arrays.asList(area.getCategories())); @@ -612,7 +612,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { return true; } } - for(Element element : widgets) + for (Element element : widgets) if (element.mouseClicked(double_1, double_2, int_1)) { this.setFocused(element); if (int_1 == 0) @@ -630,22 +630,12 @@ public class ContainerScreenOverlay extends WidgetWithBounds { } public boolean isInside(double mouseX, double mouseY) { - if (!rectangle.contains(mouseX, mouseY)) - return false; - for(DisplayHelper.DisplayBoundsHandler handler : DisplayHelper.getInstance().getSortedBoundsHandlers(MinecraftClient.getInstance().currentScreen.getClass())) { - ActionResult in = handler.isInZone(!ConfigObject.getInstance().isLeftHandSidePanel(), mouseX, mouseY); - if (in != ActionResult.PASS) - return in == ActionResult.SUCCESS; - } - return true; + return rectangle.contains(mouseX, mouseY) && isNotInExclusionZones(mouseX, mouseY); } public boolean isNotInExclusionZones(double mouseX, double mouseY) { - for(DisplayHelper.DisplayBoundsHandler handler : DisplayHelper.getInstance().getSortedBoundsHandlers(MinecraftClient.getInstance().currentScreen.getClass())) { - ActionResult in = handler.isInZone(true, mouseX, mouseY); - if (in != ActionResult.PASS) - return in == ActionResult.SUCCESS; - in = handler.isInZone(false, mouseX, mouseY); + for (DisplayHelper.DisplayBoundsHandler handler : DisplayHelper.getInstance().getSortedBoundsHandlers(MinecraftClient.getInstance().currentScreen.getClass())) { + ActionResult in = handler.isInZone(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 7667e5cb5..cecb6d9d4 100644 --- a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java +++ b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java @@ -35,7 +35,8 @@ public class OverlaySearchField extends TextFieldWidget { @Override public void setFocused(boolean boolean_1) { - if (isFocused() != boolean_1) addToHistory(getText()); + if (isFocused() != boolean_1) + addToHistory(getText()); super.setFocused(boolean_1); } @@ -45,7 +46,8 @@ public class OverlaySearchField extends TextFieldWidget { if (!text.isEmpty()) { history.removeIf(str -> str.equalsIgnoreCase(text)); history.add(text); - if (history.size() > 100) history.remove(0); + if (history.size() > 100) + history.remove(0); } } @@ -96,7 +98,8 @@ public class OverlaySearchField extends TextFieldWidget { return true; } else if (int_1 == 265) { int i = history.indexOf(getText()) - 1; - if (i < -1 && getText().isEmpty()) i = history.size() - 1; + if (i < -1 && getText().isEmpty()) + i = history.size() - 1; else if (i < -1) { addToHistory(getText()); i = history.size() - 2; diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index f2309588b..fee376855 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -47,8 +47,7 @@ public class RecipeViewingScreen extends Screen { public boolean choosePageActivated; public RecipeChoosePageWidget recipeChoosePageWidget; private Rectangle bounds; - @Nullable - private CategoryBaseWidget workingStationsBaseWidget; + @Nullable private CategoryBaseWidget workingStationsBaseWidget; private RecipeCategory selectedCategory; private ButtonWidget recipeBack, recipeNext, categoryBack, categoryNext; @@ -110,7 +109,8 @@ public class RecipeViewingScreen extends Screen { if (int_1 == 259) { if (ScreenHelper.hasLastRecipeScreen()) minecraft.openScreen(ScreenHelper.getLastRecipeScreen()); - else minecraft.openScreen(ScreenHelper.getLastContainerScreen()); + else + minecraft.openScreen(ScreenHelper.getLastContainerScreen()); return true; } return super.keyPressed(int_1, int_2, int_3); @@ -300,7 +300,7 @@ public class RecipeViewingScreen extends Screen { recipeChoosePageWidget = new RecipeChoosePageWidget(this, page, getTotalPages(selectedCategory)); else recipeChoosePageWidget = null; - + workingStationsBaseWidget = null; List> workingStations = RecipeHelper.getInstance().getWorkingStations(selectedCategory.getIdentifier()); if (!workingStations.isEmpty()) { diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index c23493b23..cc5d26802 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -483,7 +483,8 @@ public class VillagerRecipeViewingScreen extends Screen { if (int_1 == 259) { if (ScreenHelper.hasLastRecipeScreen()) minecraft.openScreen(ScreenHelper.getLastRecipeScreen()); - else minecraft.openScreen(ScreenHelper.getLastContainerScreen()); + else + minecraft.openScreen(ScreenHelper.getLastContainerScreen()); return true; } return super.keyPressed(int_1, int_2, int_3); diff --git a/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java b/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java index 37bc7a0b9..bf914a8de 100644 --- a/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java +++ b/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java @@ -10,7 +10,9 @@ import net.minecraft.client.resource.language.I18n; import java.util.Locale; public enum SearchFieldLocation { - CENTER, BOTTOM_SIDE, TOP_SIDE; + CENTER, + BOTTOM_SIDE, + TOP_SIDE; @Override public String toString() { diff --git a/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java b/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java index c0ff3bf53..97f5b7401 100644 --- a/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java +++ b/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java @@ -7,7 +7,6 @@ package me.shedaniel.rei.gui.entries; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.ObjectHolder; -import me.shedaniel.rei.impl.ObjectHolderImpl; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.util.Identifier; @@ -107,7 +106,7 @@ public abstract class RecipeEntry extends DrawableHelper implements EntryStack { @SuppressWarnings("deprecation") @Override public ObjectHolder getSetting(Settings settings) { - return new ObjectHolderImpl<>(settings.getDefaultValue()); + return ObjectHolder.of(settings.getDefaultValue()); } public abstract int getHeight(); 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 216cd6ee0..a71ff972d 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java @@ -156,7 +156,8 @@ public class AutoCraftingButtonWidget extends ButtonWidget { if (errorTooltip == null) { if (IS_YOG.get()) str += I18n.translate("text.auto_craft.move_items.yog"); - else str += I18n.translate("text.auto_craft.move_items"); + else + str += I18n.translate("text.auto_craft.move_items"); } else { if (errorTooltip.size() > 1) str += Formatting.RED.toString() + I18n.translate("error.rei.multi.errors") + "\n"; 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 b103cfaed..37276747a 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -44,7 +44,7 @@ import java.util.stream.Collectors; public class EntryListWidget extends WidgetWithBounds { - static final Supplier RENDER_EXTRA_CONFIG = ConfigObject.getInstance()::doesRenderEntryExtraOverlay; + static final Supplier RENDER_ENCHANTMENT_GLINT = ConfigObject.getInstance()::doesRenderEntryEnchantmentGlint; @SuppressWarnings("deprecation") static final Comparator ENTRY_NAME_COMPARER = Comparator.comparing(SearchArgument::tryGetEntryStackName); static final Comparator ENTRY_GROUP_COMPARER = Comparator.comparingInt(stack -> { @@ -75,11 +75,8 @@ public class EntryListWidget extends WidgetWithBounds { @SuppressWarnings("rawtypes") static boolean notSteppingOnExclusionZones(int left, int top, Rectangle listArea) { MinecraftClient instance = MinecraftClient.getInstance(); - for(DisplayHelper.DisplayBoundsHandler sortedBoundsHandler : DisplayHelper.getInstance().getSortedBoundsHandlers(instance.currentScreen.getClass())) { - ActionResult fit = sortedBoundsHandler.canItemSlotWidgetFit(!ConfigObject.getInstance().isLeftHandSidePanel(), left, top, instance.currentScreen, listArea); - if (fit != ActionResult.PASS) - return fit == ActionResult.SUCCESS; - fit = sortedBoundsHandler.canItemSlotWidgetFit(ConfigObject.getInstance().isLeftHandSidePanel(), left, top, instance.currentScreen, listArea); + for (DisplayHelper.DisplayBoundsHandler sortedBoundsHandler : DisplayHelper.getInstance().getSortedBoundsHandlers(instance.currentScreen.getClass())) { + ActionResult fit = sortedBoundsHandler.canItemSlotWidgetFit(left, top, instance.currentScreen, listArea); if (fit != ActionResult.PASS) return fit == ActionResult.SUCCESS; } @@ -191,7 +188,7 @@ public class EntryListWidget extends WidgetWithBounds { @Override public void render(int mouseX, int mouseY, float delta) { if (ConfigObject.getInstance().isEntryListWidgetScrolled()) { - for(EntryListEntry entry : entries) + for (EntryListEntry entry : entries) entry.clearStacks(); ScissorsHandler.INSTANCE.scissor(bounds); int sizeForFavorites = getSlotsHeightNumberForFavorites(); @@ -202,7 +199,7 @@ public class EntryListWidget extends WidgetWithBounds { if (sizeForFavorites > 0) { drawString(font, I18n.translate("text.rei.favorites"), innerBounds.x + 2, (int) (innerBounds.y + 8 - scroll), -1); nextIndex += innerBounds.width / 18; - for(int i1 = 0; i1 < favorites.size(); i1++) { + for (int i1 = 0; i1 < favorites.size(); i1++) { EntryStack stack = favorites.get(i1); back1: while (true) { @@ -226,7 +223,7 @@ public class EntryListWidget extends WidgetWithBounds { } int offset = sizeForFavorites > 0 ? -12 : 0; back: - for(; i < allStacks.size(); i++) { + for (; i < allStacks.size(); i++) { EntryStack stack = allStacks.get(i); while (true) { EntryListEntry entry = entries.get(nextIndex); @@ -249,10 +246,10 @@ public class EntryListWidget extends WidgetWithBounds { ScissorsHandler.INSTANCE.removeLastScissor(); renderScrollbar(); } else { - for(EntryListEntry widget : entries) { + for (EntryListEntry widget : entries) { widget.render(mouseX, mouseY, delta); } - for(Widget widget : widgets) { + for (Widget widget : widgets) { widget.render(mouseX, mouseY, delta); } } @@ -349,7 +346,7 @@ public class EntryListWidget extends WidgetWithBounds { @Override public boolean keyPressed(int int_1, int int_2, int int_3) { if (containsMouse(PointHelper.fromMouse())) - for(Widget widget : widgets) + for (Widget widget : widgets) if (widget.keyPressed(int_1, int_2, int_3)) return true; return false; @@ -375,8 +372,8 @@ public class EntryListWidget extends WidgetWithBounds { List entries = Lists.newLinkedList(); int width = innerBounds.width / 18; int height = innerBounds.height / 18; - for(int currentY = 0; currentY < height; currentY++) { - for(int currentX = 0; currentX < width; currentX++) { + for (int currentY = 0; currentY < height; currentY++) { + for (int currentX = 0; currentX < width; currentX++) { if (notSteppingOnExclusionZones(currentX * 18 + innerBounds.x, currentY * 18 + innerBounds.y, innerBounds)) { entries.add((EntryListEntry) new EntryListEntry(currentX * 18 + innerBounds.x, currentY * 18 + innerBounds.y).noBackground()); } @@ -385,7 +382,7 @@ public class EntryListWidget extends WidgetWithBounds { page = Math.max(Math.min(page, getTotalPages() - 1), 0); int numberForFavorites = getScrollNumberForFavorites(); List subList = allStacks.stream().skip(Math.max(0, page * entries.size() - numberForFavorites)).limit(Math.max(0, entries.size() - Math.max(0, numberForFavorites - page * entries.size()))).collect(Collectors.toList()); - for(int i = 0; i < subList.size(); i++) { + for (int i = 0; i < subList.size(); i++) { EntryStack stack = subList.get(i); entries.get(i + Math.max(0, numberForFavorites - page * entries.size())).clearStacks().entry(stack); entries.get(i + Math.max(0, numberForFavorites - page * entries.size())).isFavorites = false; @@ -400,7 +397,7 @@ public class EntryListWidget extends WidgetWithBounds { j += width; } List subFavoritesList = favorites.stream().skip(skippedFavorites).limit(Math.max(0, entries.size() - width)).collect(Collectors.toList()); - for(int i = 0; i < subFavoritesList.size(); i++) { + for (int i = 0; i < subFavoritesList.size(); i++) { EntryStack stack = subFavoritesList.get(i); entries.get(j).clearStacks().entry(stack); entries.get(j).isFavorites = true; @@ -416,7 +413,7 @@ public class EntryListWidget extends WidgetWithBounds { int currentX = 0; int currentY = 0; List entries = Lists.newLinkedList(); - for(int i = 0; i < slotsToPrepare; i++) { + for (int i = 0; i < slotsToPrepare; i++) { int xPos = currentX * 18 + innerBounds.x; int yPos = currentY * 18 + innerBounds.y; entries.add((EntryListEntry) new EntryListEntry(xPos, yPos).noBackground()); @@ -446,11 +443,11 @@ public class EntryListWidget extends WidgetWithBounds { List list = Lists.newLinkedList(); boolean checkCraftable = ConfigManager.getInstance().isCraftableOnlyEnabled() && !ScreenHelper.inventoryStacks.isEmpty(); List workingItems = checkCraftable ? RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create)) : null; - for(EntryStack stack : EntryRegistry.getInstance().getStacksList()) { + for (EntryStack stack : EntryRegistry.getInstance().getStacksList()) { if (canLastSearchTermsBeAppliedTo(stack)) { if (workingItems != null && CollectionUtils.findFirstOrNullEquals(workingItems, stack) == null) continue; - list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_OVERLAY, RENDER_EXTRA_CONFIG)); + list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_ENCHANTMENT_GLINT, RENDER_ENCHANTMENT_GLINT)); } } ItemListOrdering ordering = ConfigObject.getInstance().getItemListOrdering(); @@ -466,11 +463,11 @@ public class EntryListWidget extends WidgetWithBounds { List list = Lists.newLinkedList(); boolean checkCraftable = ConfigManager.getInstance().isCraftableOnlyEnabled() && !ScreenHelper.inventoryStacks.isEmpty(); List workingItems = checkCraftable ? RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create)) : null; - for(EntryStack stack : ConfigManager.getInstance().getFavorites()) { + for (EntryStack stack : ConfigManager.getInstance().getFavorites()) { if (canLastSearchTermsBeAppliedTo(stack)) { if (workingItems != null && CollectionUtils.findFirstOrNullEquals(workingItems, stack) == null) continue; - list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_OVERLAY, RENDER_EXTRA_CONFIG)); + list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_ENCHANTMENT_GLINT, RENDER_ENCHANTMENT_GLINT)); } } ItemListOrdering ordering = ConfigObject.getInstance().getItemListOrdering(); @@ -499,9 +496,9 @@ public class EntryListWidget extends WidgetWithBounds { if (searchArguments.isEmpty()) return true; String mod = null, name = null, tooltip = null, tags[] = null; - for(SearchArgument.SearchArguments arguments : searchArguments) { + for (SearchArgument.SearchArguments arguments : searchArguments) { boolean applicable = true; - for(SearchArgument argument : arguments.getArguments()) { + for (SearchArgument argument : arguments.getArguments()) { if (argument.getArgumentType() == SearchArgument.ArgumentType.ALWAYS) return true; else if (argument.getArgumentType() == SearchArgument.ArgumentType.MOD) { @@ -530,19 +527,19 @@ public class EntryListWidget extends WidgetWithBounds { if (stack.getType() == EntryStack.Type.ITEM) { Identifier[] tagsFor = minecraft.getNetworkHandler().getTagManager().items().getTagsFor(stack.getItem()).toArray(new Identifier[0]); tags = new String[tagsFor.length]; - for(int i = 0; i < tagsFor.length; i++) + for (int i = 0; i < tagsFor.length; i++) tags[i] = tagsFor[i].toString(); } else if (stack.getType() == EntryStack.Type.FLUID) { Identifier[] tagsFor = minecraft.getNetworkHandler().getTagManager().fluids().getTagsFor(stack.getFluid()).toArray(new Identifier[0]); tags = new String[tagsFor.length]; - for(int i = 0; i < tagsFor.length; i++) + for (int i = 0; i < tagsFor.length; i++) tags[i] = tagsFor[i].toString(); } else tags = new String[0]; } if (tags != null && tags.length > 0) { boolean a = false; - for(String tag : tags) + for (String tag : tags) if (argument.getFunction(argument.isInclude()).apply(tag)) a = true; if (!a) { @@ -564,13 +561,13 @@ public class EntryListWidget extends WidgetWithBounds { @SuppressWarnings("deprecation") private List processSearchTerm(String searchTerm) { List searchArguments = Lists.newArrayList(); - for(String split : StringUtils.splitByWholeSeparatorPreserveAllTokens(searchTerm.toLowerCase(Locale.ROOT), "|")) { + for (String split : StringUtils.splitByWholeSeparatorPreserveAllTokens(searchTerm.toLowerCase(Locale.ROOT), "|")) { String[] terms = StringUtils.split(split); if (terms.length == 0) searchArguments.add(SearchArgument.SearchArguments.ALWAYS); else { SearchArgument[] arguments = new SearchArgument[terms.length]; - for(int i = 0; i < terms.length; i++) { + for (int i = 0; i < terms.length; i++) { String term = terms[i]; if (term.startsWith("-@") || term.startsWith("@-")) { arguments[i] = new SearchArgument(SearchArgument.ArgumentType.MOD, term.substring(2), false); @@ -622,7 +619,7 @@ public class EntryListWidget extends WidgetWithBounds { } if (!player.inventory.getCursorStack().isEmpty() && RoughlyEnoughItemsCore.hasPermissionToUsePackets()) return false; - for(Widget widget : children()) + for (Widget widget : children()) if (widget.mouseClicked(double_1, double_2, int_1)) return true; } diff --git a/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java index 142e0d3e1..672d007c3 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java @@ -107,7 +107,7 @@ public class FavoritesListWidget extends WidgetWithBounds { @Override public void render(int mouseX, int mouseY, float delta) { - for(EntryListEntry entry : entries) + for (EntryListEntry entry : entries) entry.clearStacks(); ScissorsHandler.INSTANCE.scissor(bounds); int skip = Math.max(0, MathHelper.floor(scroll / 18f)); @@ -115,7 +115,7 @@ public class FavoritesListWidget extends WidgetWithBounds { int i = nextIndex; blockedCount = 0; back: - for(; i < favorites.size(); i++) { + for (; i < favorites.size(); i++) { EntryStack stack = favorites.get(i); while (true) { EntryListEntry entry = entries.get(nextIndex); @@ -229,7 +229,7 @@ public class FavoritesListWidget extends WidgetWithBounds { @Override public boolean keyPressed(int int_1, int int_2, int int_3) { if (containsMouse(PointHelper.fromMouse())) - for(Widget widget : children()) + for (Widget widget : children()) if (widget.keyPressed(int_1, int_2, int_3)) return true; return false; @@ -246,11 +246,11 @@ public class FavoritesListWidget extends WidgetWithBounds { List list = Lists.newLinkedList(); boolean checkCraftable = ConfigManager.getInstance().isCraftableOnlyEnabled() && !ScreenHelper.inventoryStacks.isEmpty(); List workingItems = checkCraftable ? RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create)) : null; - for(EntryStack stack : ConfigManager.getInstance().getFavorites()) { + for (EntryStack stack : ConfigManager.getInstance().getFavorites()) { if (listWidget.canLastSearchTermsBeAppliedTo(stack)) { if (workingItems != null && CollectionUtils.findFirstOrNullEquals(workingItems, stack) == null) continue; - list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_OVERLAY, RENDER_EXTRA_CONFIG)); + list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_ENCHANTMENT_GLINT, RENDER_ENCHANTMENT_GLINT)); } } ItemListOrdering ordering = ConfigObject.getInstance().getItemListOrdering(); @@ -273,7 +273,7 @@ public class FavoritesListWidget extends WidgetWithBounds { int currentX = 0; int currentY = 0; List entries = Lists.newLinkedList(); - for(int i = 0; i < slotsToPrepare; i++) { + for (int i = 0; i < slotsToPrepare; i++) { int xPos = currentX * 18 + innerBounds.x; int yPos = currentY * 18 + innerBounds.y; entries.add((EntryListEntry) new EntryListEntry(xPos, yPos).noBackground()); @@ -312,7 +312,7 @@ public class FavoritesListWidget extends WidgetWithBounds { } if (!player.inventory.getCursorStack().isEmpty() && RoughlyEnoughItemsCore.hasPermissionToUsePackets()) return false; - for(Widget widget : children()) + for (Widget widget : children()) if (widget.mouseClicked(double_1, double_2, int_1)) return true; } diff --git a/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java index b2a92b95c..ac6815d3d 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java @@ -115,11 +115,13 @@ public class LabelWidget extends WidgetWithBounds { if (isCentered()) { if (hasShadows) font.drawWithShadow(text, pos.x - width / 2, pos.y, defaultColor); - else font.draw(text, pos.x - width / 2, pos.y, defaultColor); + else + font.draw(text, pos.x - width / 2, pos.y, defaultColor); } else { if (hasShadows) font.drawWithShadow(text, pos.x, pos.y, defaultColor); - else font.draw(text, pos.x, pos.y, defaultColor); + else + font.draw(text, pos.x, pos.y, defaultColor); } } diff --git a/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java b/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java index 01d84623e..cdbbfdccd 100644 --- a/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java +++ b/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java @@ -42,8 +42,8 @@ public abstract class AbstractEntryStack extends DrawableHelper implements Entry public ObjectHolder getSetting(Settings settings) { Object o = this.settings.get(settings); if (o == null) - return new ObjectHolderImpl(settings.getDefaultValue()); - return new ObjectHolderImpl(o); + return ObjectHolder.of(settings.getDefaultValue()); + return ObjectHolder.of((T) o); } @Override diff --git a/src/main/java/me/shedaniel/rei/impl/BaseBoundsHandlerImpl.java b/src/main/java/me/shedaniel/rei/impl/BaseBoundsHandlerImpl.java index b47064f6e..ae4cb24df 100644 --- a/src/main/java/me/shedaniel/rei/impl/BaseBoundsHandlerImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/BaseBoundsHandlerImpl.java @@ -17,7 +17,7 @@ import net.minecraft.util.Pair; import java.util.Comparator; import java.util.List; -import java.util.function.Function; +import java.util.function.Supplier; @Deprecated @Internal @@ -26,7 +26,7 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { private static final Comparator RECTANGLE_COMPARER = Comparator.comparingLong(Rectangle::hashCode); private long lastArea = -1; - private List, Float>, Function>>> list = Lists.newArrayList(); + private List, Float>, Supplier>>> list = Lists.newArrayList(); @Override public Class getBaseSupportedClass() { @@ -49,10 +49,14 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { } @Override - public ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) { - for (Rectangle zone : getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide, false)) - if (zone.contains(mouseX, mouseY)) - return ActionResult.FAIL; + public ActionResult isInZone(double mouseX, double mouseY) { + Class screenClass = MinecraftClient.getInstance().currentScreen.getClass(); + for (Pair, Float>, Supplier>> pair : list) { + if (pair.getLeft().getLeft().isAssignableFrom(screenClass)) + for (Rectangle zone : pair.getRight().get()) + if (zone.contains(mouseX, mouseY)) + return ActionResult.FAIL; + } return ActionResult.PASS; } @@ -67,23 +71,28 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { private long currentHashCode(boolean isOnRightSide) { DisplayHelper.DisplayBoundsHandler handler = DisplayHelper.getInstance().getResponsibleBoundsHandler(MinecraftClient.getInstance().currentScreen.getClass()); - return areasHashCode(isOnRightSide ? handler.getRightBounds(MinecraftClient.getInstance().currentScreen) : handler.getLeftBounds(MinecraftClient.getInstance().currentScreen), getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide, false)); + return areasHashCode(isOnRightSide ? handler.getRightBounds(MinecraftClient.getInstance().currentScreen) : handler.getLeftBounds(MinecraftClient.getInstance().currentScreen), getExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), false)); } @Override - public ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, Screen screen, Rectangle fullBounds) { - for (Rectangle currentExclusionZone : getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide, false)) - if (left + 18 >= currentExclusionZone.x && top + 18 >= currentExclusionZone.y && left <= currentExclusionZone.x + currentExclusionZone.width && top <= currentExclusionZone.y + currentExclusionZone.height) - return ActionResult.FAIL; + public ActionResult canItemSlotWidgetFit(int left, int top, Screen screen, Rectangle fullBounds) { + Class screenClass = screen.getClass(); + for (Pair, Float>, Supplier>> pair : list) { + if (pair.getLeft().getLeft().isAssignableFrom(screenClass)) + for (Rectangle zone : pair.getRight().get()) { + if (left + 18 >= zone.x && top + 18 >= zone.y && left <= zone.getMaxX() && top <= zone.getMaxY()) + return ActionResult.FAIL; + } + } return ActionResult.PASS; } @Override - public List getCurrentExclusionZones(Class currentScreenClass, boolean isOnRightSide, boolean sort) { + public List getExclusionZones(Class currentScreenClass, boolean sort) { List rectangles = Lists.newArrayList(); - for (Pair, Float>, Function>> pair : list) { + for (Pair, Float>, Supplier>> pair : list) { if (pair.getLeft().getLeft().isAssignableFrom(currentScreenClass)) - rectangles.addAll(pair.getRight().apply(isOnRightSide)); + rectangles.addAll(pair.getRight().get()); } if (sort) rectangles.sort(RECTANGLE_COMPARER); @@ -91,7 +100,12 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { } @Override - public void registerExclusionZones(Class screenClass, Function> supplier) { + public int supplierSize() { + return list.size(); + } + + @Override + public void registerExclusionZones(Class screenClass, Supplier> supplier) { list.add(new Pair<>(new Pair<>(screenClass, 0f), supplier)); } @@ -99,7 +113,6 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { int hashCode = 31 + (rectangle == null ? 0 : rectangle.hashCode()); for (Rectangle e : exclusionZones) hashCode = 31 * hashCode + (e == null ? 0 : e.hashCode()); - // hashCode -= (e == null ? 0 : e.hashCode()); return hashCode; } diff --git a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index a87e7b0a6..1bf445944 100644 --- a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -76,9 +76,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { @Override public FabricKeyBinding[] getREIKeyBindings() { - return new FabricKeyBinding[]{ - recipe, usage, hide, previousPage, nextPage, focusSearchField, copyRecipeIdentifier - }; + return new FabricKeyBinding[]{recipe, usage, hide, previousPage, nextPage, focusSearchField, copyRecipeIdentifier}; } @Override diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java index 6e423c0a6..7df8fa668 100644 --- a/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java @@ -13,9 +13,7 @@ import me.sargunvohra.mcmods.autoconfig1u.gui.ConfigScreenProvider; import me.sargunvohra.mcmods.autoconfig1u.gui.registry.GuiRegistry; import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer; import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Jankson; -import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.JsonObject; import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.JsonPrimitive; -import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.impl.SyntaxError; import me.shedaniel.cloth.hooks.ScreenHooks; import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; @@ -62,7 +60,7 @@ public class ConfigManagerImpl implements ConfigManager { loadFavoredEntries(); guiRegistry.registerAnnotationProvider((i13n, field, config, defaults, guiProvider) -> { @SuppressWarnings("rawtypes") List entries = new ArrayList<>(); - for(FabricKeyBinding binding : ClientHelper.getInstance().getREIKeyBindings()) { + for (FabricKeyBinding binding : ClientHelper.getInstance().getREIKeyBindings()) { entries.add(ConfigEntryBuilder.create().fillKeybindingField(I18n.translate(binding.getId()) + ":", binding).build()); } KeyCodeEntry entry = ConfigEntryBuilder.create().startKeyCodeField(i13n, getUnsafely(field, config, InputUtil.UNKNOWN_KEYCODE)).setDefaultValue(() -> getUnsafely(field, defaults)).setSaveConsumer(newValue -> setUnsafely(field, config, newValue)).build(); @@ -89,7 +87,8 @@ public class ConfigManagerImpl implements ConfigManager { Gson gson = new GsonBuilder().create(); for (String entry : ((ConfigObjectImpl) getConfig()).general.favorites) { EntryStack stack = EntryStack.readFromJson(gson.fromJson(entry, JsonElement.class)); - if (!stack.isEmpty()) favorites.add(stack); + if (!stack.isEmpty()) + favorites.add(stack); } saveConfig(); } @@ -101,7 +100,8 @@ public class ConfigManagerImpl implements ConfigManager { object.general.favorites.clear(); for (EntryStack stack : favorites) { JsonElement element = stack.toJson(); - if (element != null) object.general.favorites.add(gson.toJson(element)); + if (element != null) + object.general.favorites.add(gson.toJson(element)); } ((me.sargunvohra.mcmods.autoconfig1u.ConfigManager) AutoConfig.getConfigHolder(ConfigObjectImpl.class)).save(); } @@ -156,7 +156,8 @@ public class ConfigManagerImpl implements ConfigManager { }); }).setSavingRunnable(() -> { saveConfig(); - ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText()); + if (ScreenHelper.getSearchField() != null) + ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText()); }).build(); }); return provider.get(); @@ -169,7 +170,7 @@ public class ConfigManagerImpl implements ConfigManager { renderDirtBackground(0); List list = minecraft.textRenderer.wrapStringToWidthAsList(I18n.translate("text.rei.config_api_failed"), width - 100); int y = (int) (height / 2 - minecraft.textRenderer.fontHeight * 1.3f / 2 * list.size()); - for(int i = 0; i < list.size(); i++) { + for (int i = 0; i < list.size(); i++) { String s = list.get(i); drawCenteredString(minecraft.textRenderer, s, width / 2, y, -1); y += minecraft.textRenderer.fontHeight; diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index 52cb791e5..ec0293d58 100644 --- a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -22,22 +22,16 @@ import java.util.List; @Config(name = "roughlyenoughitems/config") public class ConfigObjectImpl implements ConfigObject, ConfigData { - @ConfigEntry.Category("!general") - @ConfigEntry.Gui.TransitiveObject - @DontApplyFieldName + @ConfigEntry.Category("!general") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName public General general = new General(); - @ConfigEntry.Category("appearance") - @ConfigEntry.Gui.TransitiveObject - @DontApplyFieldName + @ConfigEntry.Category("appearance") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Appearance appearance = new Appearance(); - @ConfigEntry.Category("modules") - @ConfigEntry.Gui.TransitiveObject - @DontApplyFieldName + @ConfigEntry.Category("modules") @ConfigEntry.Gui.TransitiveObject @DontApplyFieldName private Modules modules = new Modules(); - @ConfigEntry.Category("technical") - @ConfigEntry.Gui.TransitiveObject - @DontApplyFieldName + @ConfigEnt