diff options
Diffstat (limited to 'src')
45 files changed, 368 insertions, 302 deletions
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<Identifier, REIPluginEntry> 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<Screen> { /** @@ -19,11 +22,19 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Sc * @param isOnRightSide whether the user has set the overlay to the right * @return the list of exclusion zones */ + @Deprecated default List<Rectangle> getCurrentExclusionZones(Class<?> currentScreenClass, boolean isOnRightSide) { - return getCurrentExclusionZones(currentScreenClass, isOnRightSide, false); + return getExclusionZones(currentScreenClass, false); } - List<Rectangle> getCurrentExclusionZones(Class<?> currentScreenClass, boolean isOnRightSide, boolean sort); + @Deprecated + default List<Rectangle> getCurrentExclusionZones(Class<?> currentScreenClass, boolean isOnRightSide, boolean sort) { + return getExclusionZones(currentScreenClass, sort); + } + + List<Rectangle> getExclusionZones(Class<?> currentScreenClass, boolean sort); + + int supplierSize(); /** * Register an exclusion zone @@ -31,6 +42,16 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Sc * @param screenClass the screen * @param supplier the exclusion zone supplier, isOnRightSide -> the list of exclusion zones */ - void registerExclusionZones(Class<?> screenClass, Function<Boolean, List<Rectangle>> supplier); + @Deprecated + default void registerExclusionZones(Class<?> screenClass, Function<Boolean, List<Rectangle>> supplier) { + RoughlyEnoughItemsCore.LOGGER.warn("[REI] Someone is registering exclusion zones with the deprecated method: " + supplier.getClass().getName()); + registerExclusionZones(screenClass, () -> { + List<Rectangle> zones = Lists.newArrayList(supplier.apply(false)); + zones.addAll(supplier.apply(true)); + return zones; + }); + } + + void registerExclusionZones(Class<?> screenClass, Supplier<List<Rectangle>> 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 @@ -87,16 +87,31 @@ public interface DisplayHelper { /** * 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 + * * @param isOnRightSide whether the user has set the overlay to the right * @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 + * @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<T> { @@ -192,7 +195,8 @@ public interface EntryStack { } public static class Item { - public static final Settings<Supplier<Boolean>> RENDER_OVERLAY = new Settings(TRUE); + public static final Settings<Supplier<Boolean>> RENDER_ENCHANTMENT_GLINT = new Settings(TRUE); + @Deprecated public static final Settings<Supplier<Boolean>> 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<T> { - int intValue(); + @SuppressWarnings("deprecation") + static <T> ObjectHolder<T> 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); } |
