From 250159221c07f884252a37daf00c74f41cf69d52 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 7 Mar 2020 03:10:43 +0800 Subject: stuff Signed-off-by: shedaniel --- .../me/shedaniel/rei/api/AutoTransferHandler.java | 4 +++ .../me/shedaniel/rei/api/BaseBoundsHandler.java | 1 + .../java/me/shedaniel/rei/api/ClientHelper.java | 1 + .../java/me/shedaniel/rei/api/ConfigManager.java | 7 +++++ .../java/me/shedaniel/rei/api/ConfigObject.java | 3 ++ .../java/me/shedaniel/rei/api/DisplayHelper.java | 7 ++++- .../java/me/shedaniel/rei/api/EntryRegistry.java | 3 ++ .../me/shedaniel/rei/api/LiveRecipeGenerator.java | 3 ++ src/main/java/me/shedaniel/rei/api/REIHelper.java | 9 ++++++ .../java/me/shedaniel/rei/api/REIPluginEntry.java | 12 ++++---- .../java/me/shedaniel/rei/api/RecipeHelper.java | 3 ++ .../shedaniel/rei/api/TransferRecipeDisplay.java | 6 ++++ .../shedaniel/rei/gui/ContainerScreenOverlay.java | 2 +- .../me/shedaniel/rei/gui/OverlaySearchField.java | 4 +-- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 6 ++-- .../rei/gui/VillagerRecipeViewingScreen.java | 6 ++-- .../rei/gui/config/entry/FilteringEntry.java | 4 +-- .../rei/gui/widget/AutoCraftingButtonWidget.java | 6 ++-- .../me/shedaniel/rei/gui/widget/ButtonWidget.java | 5 ++-- .../rei/gui/widget/ClickableLabelWidget.java | 5 ++-- .../shedaniel/rei/gui/widget/DraggableWidget.java | 2 +- .../shedaniel/rei/gui/widget/EntryListWidget.java | 6 ++-- .../me/shedaniel/rei/gui/widget/EntryWidget.java | 6 ++-- .../rei/gui/widget/FavoritesListWidget.java | 6 ++-- .../me/shedaniel/rei/gui/widget/LabelWidget.java | 3 +- .../me/shedaniel/rei/gui/widget/QueuedTooltip.java | 9 ++++-- .../me/shedaniel/rei/gui/widget/TabWidget.java | 5 ++-- .../shedaniel/rei/gui/widget/TextFieldWidget.java | 2 +- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 4 +++ .../java/me/shedaniel/rei/impl/ScreenHelper.java | 14 +++++++++ .../rei/impl/compat/ModelHasDepth1151Compat.java | 35 ---------------------- .../rei/impl/compat/ModelSideLit1152Compat.java | 35 ---------------------- .../plugin/beacon/DefaultBeaconBaseCategory.java | 2 +- .../information/DefaultInformationCategory.java | 2 +- 34 files changed, 111 insertions(+), 117 deletions(-) delete mode 100644 src/main/java/me/shedaniel/rei/impl/compat/ModelHasDepth1151Compat.java delete mode 100644 src/main/java/me/shedaniel/rei/impl/compat/ModelSideLit1152Compat.java (limited to 'src/main/java') diff --git a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java index d240efa91..4b28e239f 100644 --- a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java +++ b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java @@ -30,6 +30,8 @@ import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.ContainerScreen; import net.minecraft.container.Container; +import org.jetbrains.annotations.ApiStatus; +import org.spongepowered.asm.mixin.injection.Inject; import java.util.function.Supplier; @@ -104,6 +106,7 @@ public interface AutoTransferHandler { } } + @ApiStatus.Internal final class ResultImpl implements Result { private boolean successful, applicable; private String errorKey; @@ -155,6 +158,7 @@ public interface AutoTransferHandler { } } + @ApiStatus.Internal final class ContextImpl implements Context { boolean actuallyCrafting; ContainerScreen containerScreen; diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java index 5348d2196..e44e7dd9e 100644 --- a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -31,6 +31,7 @@ import java.util.function.Supplier; public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler { + @SuppressWarnings("deprecation") static BaseBoundsHandler getInstance() { return DisplayHelper.getInstance().getBaseBoundsHandler(); } diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index d0f310649..20577b511 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Map; public interface ClientHelper { + /** * @return the api instance of {@link ClientHelperImpl} */ diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index 03b1d9731..e171ffc3c 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -32,10 +32,17 @@ import java.util.List; public interface ConfigManager { + /** + * @return the api instance of {@link me.shedaniel.rei.impl.ConfigManagerImpl} + */ static ConfigManager getInstance() { return RoughlyEnoughItemsCore.getConfigManager(); } + /** + * @return the list of favourites + * @deprecated {@link ConfigObject#getFavorites()} + */ @ApiStatus.ScheduledForRemoval @Deprecated default List getFavorites() { diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java index 09566c873..56c57125a 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -36,6 +36,9 @@ import java.util.List; public interface ConfigObject { + /** + * @return the api instance of {@link me.shedaniel.rei.impl.ConfigObjectImpl} + */ static ConfigObject getInstance() { return ((ConfigManagerImpl) ConfigManager.getInstance()).getConfig(); } diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 0b6a709a9..246850cc7 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -37,6 +37,9 @@ import static net.minecraft.util.ActionResult.PASS; public interface DisplayHelper { + /** + * @return the api instance of {@link me.shedaniel.rei.impl.DisplayHelperImpl} + */ static DisplayHelper getInstance() { return RoughlyEnoughItemsCore.getDisplayHelper(); } @@ -101,9 +104,11 @@ public interface DisplayHelper { * Gets the base bounds handler api for exclusion zones * * @return the base bounds handler - * @see BaseBoundsHandler#getInstance() + * @deprecated {@link BaseBoundsHandler#getInstance()} */ @ApiStatus.Internal + @Deprecated + @ApiStatus.ScheduledForRemoval BaseBoundsHandler getBaseBoundsHandler(); interface DisplayBoundsHandler extends OverlayDecider { diff --git a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java index ca6fb7172..80f25cbf6 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java @@ -35,6 +35,9 @@ import java.util.List; public interface EntryRegistry { + /** + * @return the api instance of {@link me.shedaniel.rei.impl.EntryRegistryImpl} + */ static EntryRegistry getInstance() { return RoughlyEnoughItemsCore.getEntryRegistry(); } diff --git a/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java b/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java index d48e0e481..4ee36d11c 100644 --- a/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java +++ b/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java @@ -30,6 +30,9 @@ import java.util.Optional; public interface LiveRecipeGenerator { + /** + * @return the identifier of the category the recipes goes to. + */ Identifier getCategoryIdentifier(); default Optional> getRecipeFor(EntryStack entry) { diff --git a/src/main/java/me/shedaniel/rei/api/REIHelper.java b/src/main/java/me/shedaniel/rei/api/REIHelper.java index 99a5e0415..578d3d4bf 100644 --- a/src/main/java/me/shedaniel/rei/api/REIHelper.java +++ b/src/main/java/me/shedaniel/rei/api/REIHelper.java @@ -23,13 +23,19 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.gui.widget.QueuedTooltip; import me.shedaniel.rei.gui.widget.TextFieldWidget; import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.Nullable; import java.util.List; public interface REIHelper { + + /** + * @return the instance of {@link REIHelper} + */ static REIHelper getInstance() { return ScreenHelper.getInstance(); } @@ -39,4 +45,7 @@ public interface REIHelper { TextFieldWidget getSearchTextField(); List getInventoryStacks(); + + void addTooltip(@Nullable QueuedTooltip tooltip); + } diff --git a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java index f7bd91367..220318753 100644 --- a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java +++ b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java @@ -33,6 +33,10 @@ import org.jetbrains.annotations.ApiStatus; */ public interface REIPluginEntry { + /** + * @return the minimum version for the REI plugin to load + * @deprecated deprecated due to the lack of need of this method, please declare conflicts with fabric.mod.json + */ @ApiStatus.ScheduledForRemoval @Deprecated default SemanticVersion getMinimumVersion() throws VersionParsingException { @@ -40,18 +44,14 @@ public interface REIPluginEntry { } /** - * Gets the priority of the plugin. - * - * @return the priority + * @return the priority of the plugin, the smaller the number, the earlier it is called. */ default int getPriority() { return 0; } /** - * Get the identifier of the plugin - * - * @return the identifier + * @return the unique identifier of the plugin. */ Identifier getPluginIdentifier(); diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java index 71fda0d06..9d58d5530 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java @@ -39,6 +39,9 @@ import java.util.function.Predicate; public interface RecipeHelper { + /** + * @return the api instance of {@link me.shedaniel.rei.impl.RecipeHelperImpl} + */ static RecipeHelper getInstance() { return RoughlyEnoughItemsCore.getRecipeHelper(); } diff --git a/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java index b6c9b18a6..900faa39e 100644 --- a/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java @@ -30,8 +30,14 @@ import java.util.List; public interface TransferRecipeDisplay extends RecipeDisplay { + /** + * @return the width of the crafting grid. + */ int getWidth(); + /** + * @return the height of the crafting grid. + */ int getHeight(); List> getOrganisedInputEntries(ContainerInfo containerInfo, Container container); diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index f0ad31a88..46cf478f0 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -503,7 +503,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds { public boolean mouseScrolled(double i, double j, double amount) { if (!ScreenHelper.isOverlayVisible()) return false; - if (isInside(PointHelper.fromMouse())) { + if (isInside(PointHelper.ofMouse())) { if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { if (amount > 0 && leftButton.enabled) leftButton.onPressed(); diff --git a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java index 2e61a9bcc..b33aca3b7 100644 --- a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java +++ b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java @@ -74,7 +74,7 @@ public class OverlaySearchField extends TextFieldWidget { public void laterRender(int int_1, int int_2, float float_1) { RenderSystem.disableDepthTest(); - setEditableColor(isMain && ContainerScreenOverlay.getEntryListWidget().getAllStacks().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching && isMain ? -852212 : (containsMouse(PointHelper.fromMouse()) || isFocused()) ? (REIHelper.getInstance().isDarkThemeEnabled() ? -17587 : -1) : -6250336); + setEditableColor(isMain && ContainerScreenOverlay.getEntryListWidget().getAllStacks().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching && isMain ? -852212 : (containsMouse(PointHelper.ofMouse()) || isFocused()) ? (REIHelper.getInstance().isDarkThemeEnabled() ? -17587 : -1) : -6250336); setSuggestion(!isFocused() && getText().isEmpty() ? I18n.translate("text.rei.search.field.suggestion") : null); super.render(int_1, int_2, float_1); RenderSystem.enableDepthTest(); @@ -82,7 +82,7 @@ public class OverlaySearchField extends TextFieldWidget { @Override protected void renderSuggestion(int x, int y) { - if (containsMouse(PointHelper.fromMouse()) || isFocused()) + if (containsMouse(PointHelper.ofMouse()) || isFocused()) this.font.drawWithShadow(this.font.trimToWidth(this.getSuggestion(), this.getWidth()), x, y, REIHelper.getInstance().isDarkThemeEnabled() ? 0xccddaa3d : 0xddeaeaea); else this.font.drawWithShadow(this.font.trimToWidth(this.getSuggestion(), this.getWidth()), x, y, -6250336); diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index e6e5bccdc..f058ee63a 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -458,7 +458,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { if (export.matchesKey(keyCode, scanCode)) { for (Map.Entry> entry : recipeBounds.entrySet()) { Rectangle bounds = entry.getKey(); - if (bounds.contains(PointHelper.fromMouse())) { + if (bounds.contains(PointHelper.ofMouse())) { RecipeDisplayExporter.exportRecipeDisplay(bounds, entry.getValue()); break; } @@ -507,13 +507,13 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { for (Element listener : children()) if (listener.mouseScrolled(i, j, amount)) return true; - if (getBounds().contains(PointHelper.fromMouse())) { + if (getBounds().contains(PointHelper.ofMouse())) { if (amount > 0 && recipeBack.enabled) recipeBack.onPressed(); else if (amount < 0 && recipeNext.enabled) recipeNext.onPressed(); } - if ((new Rectangle(bounds.x, bounds.y - 28, bounds.width, 28)).contains(PointHelper.fromMouse())) { + if ((new Rectangle(bounds.x, bounds.y - 28, bounds.width, 28)).contains(PointHelper.ofMouse())) { if (amount > 0 && categoryBack.enabled) categoryBack.onPressed(); else if (amount < 0 && categoryNext.enabled) diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index 7ba09f59d..d20000a30 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -327,7 +327,7 @@ public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen for (Element listener : children()) if (listener.mouseScrolled(double_1, double_2, double_3)) return true; - if (bounds.contains(PointHelper.fromMouse())) { + if (bounds.contains(PointHelper.ofMouse())) { if (double_3 < 0 && categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) { selectedRecipeIndex++; if (selectedRecipeIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size()) @@ -392,7 +392,7 @@ public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen if (buttonWidgets.get(i).getBounds().getMaxY() > scrollListBounds.getMinY() && buttonWidgets.get(i).getBounds().getMinY() < scrollListBounds.getMaxY()) { recipeRenderers.get(i).setZ(1); recipeRenderers.get(i).render(buttonWidgets.get(i).getBounds(), mouseX, mouseY, delta); - ScreenHelper.getLastOverlay().addTooltip(recipeRenderers.get(i).getTooltip(mouseX, mouseY)); + REIHelper.getInstance().addTooltip(recipeRenderers.get(i).getTooltip(mouseX, mouseY)); } } double maxScroll = getMaxScrollPosition(); @@ -405,7 +405,7 @@ public class VillagerRecipeViewingScreen extends Screen implements RecipeScreen height = Math.max(10, height); int minY = (int) Math.min(Math.max((int) scrollAmount * (scrollListBounds.height - 2 - height) / getMaxScroll() + scrollListBounds.y + 1, scrollListBounds.y + 1), scrollListBounds.getMaxY() - 1 - height); int scrollbarPositionMinX = scrollListBounds.getMaxX() - 6, scrollbarPositionMaxX = scrollListBounds.getMaxX() - 1; - boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.fromMouse()); + boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.ofMouse()); float bottomC = (hovered ? .67f : .5f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); float topC = (hovered ? .87f : .67f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); RenderSystem.disableTexture(); diff --git a/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java b/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java index 1fbb235fc..29fb33c92 100644 --- a/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java +++ b/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java @@ -223,7 +223,7 @@ public class FilteringEntry extends AbstractConfigListEntry> { if (selectionPoint != null) { Point p = secondPoint; if (p == null) { - p = PointHelper.fromMouse(); + p = PointHelper.ofMouse(); p.translate(0, (int) scroll); } int left = Math.min(p.x, selectionPoint.x); @@ -272,7 +272,7 @@ public class FilteringEntry extends AbstractConfigListEntry> { int scrollbarPositionMinX = getScrollbarMinX(); int scrollbarPositionMaxX = scrollbarPositionMinX + 6; - boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.fromMouse()); + boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.ofMouse()); float bottomC = (hovered ? .67f : .5f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); float topC = (hovered ? .87f : .67f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); 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 90a3ab511..3b1817d18 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java @@ -148,9 +148,9 @@ public class AutoCraftingButtonWidget extends ButtonWidget { if (getTooltips().isPresent()) if (!focused && containsMouse(mouseX, mouseY)) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); else if (focused) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(new Point(x + width / 2, y + height / 2), getTooltips().get().split("\n"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(new Point(x + width / 2, y + height / 2), getTooltips().get().split("\n"))); } @Override @@ -179,7 +179,7 @@ public class AutoCraftingButtonWidget extends ButtonWidget { @Override public boolean keyPressed(int int_1, int int_2, int int_3) { - if (displaySupplier.get().getRecipeLocation().isPresent() && ConfigObject.getInstance().getCopyRecipeIdentifierKeybind().matchesKey(int_1, int_2) && containsMouse(PointHelper.fromMouse())) { + if (displaySupplier.get().getRecipeLocation().isPresent() && ConfigObject.getInstance().getCopyRecipeIdentifierKeybind().matchesKey(int_1, int_2) && containsMouse(PointHelper.ofMouse())) { minecraft.keyboard.setClipboard(displaySupplier.get().getRecipeLocation().get().toString()); 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())); 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 06c80b5cd..0fd86752d 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java @@ -27,7 +27,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.client.gui.Element; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.sound.SoundEvents; @@ -155,9 +154,9 @@ public abstract class ButtonWidget extends WidgetWithBounds { if (getTooltips().isPresent()) if (!focused && containsMouse(mouseX, mouseY)) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); else if (focused) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(new Point(x + width / 2, y + height / 2), getTooltips().get().split("\n"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(new Point(x + width / 2, y + height / 2), getTooltips().get().split("\n"))); } public boolean isHovered(int mouseX, int mouseY) { diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java index 42b0abcc5..ad40fcd1b 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.gui.widget; import me.shedaniel.math.api.Point; import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.impl.ScreenHelper; import org.jetbrains.annotations.ApiStatus; public abstract class ClickableLabelWidget extends LabelWidget { @@ -79,9 +78,9 @@ public abstract class ClickableLabelWidget extends LabelWidget { protected void drawTooltips(int mouseX, int mouseY) { if (isClickable() && getTooltips().isPresent()) if (!focused && containsMouse(mouseX, mouseY)) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); else if (focused) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getPosition(), getTooltips().get().split("\n"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(getPosition(), getTooltips().get().split("\n"))); } public int getHoveredColor() { diff --git a/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java index a09355373..d9e4e04d1 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java @@ -60,7 +60,7 @@ public abstract class DraggableWidget extends WidgetWithBounds { @Override public boolean mouseDragged(double double_1, double double_2, int int_1, double double_3, double double_4) { - Point mouse = PointHelper.fromMouse(); + Point mouse = PointHelper.ofMouse(); if (int_1 == 0) { if (!dragged) { if (getGrabBounds().contains(mouse)) { 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 b10f94158..1a38d5dc7 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -459,7 +459,7 @@ public class EntryListWidget extends WidgetWithBounds { } } if (containsMouse(mouseX, mouseY) && ClientHelper.getInstance().isCheating() && !minecraft.player.inventory.getCursorStack().isEmpty() && RoughlyEnoughItemsCore.hasPermissionToUsePackets()) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(I18n.translate("text.rei.delete_items"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(I18n.translate("text.rei.delete_items"))); } private int getScrollbarMinX() { @@ -500,7 +500,7 @@ public class EntryListWidget extends WidgetWithBounds { int scrollbarPositionMinX = getScrollbarMinX(); int scrollbarPositionMaxX = scrollbarPositionMinX + 6; - boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.fromMouse()); + boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.ofMouse()); float bottomC = (hovered ? .67f : .5f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); float topC = (hovered ? .87f : .67f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); @@ -545,7 +545,7 @@ public class EntryListWidget extends WidgetWithBounds { @Override public boolean keyPressed(int int_1, int int_2, int int_3) { - if (containsMouse(PointHelper.fromMouse())) + if (containsMouse(PointHelper.ofMouse())) for (Widget widget : widgets) if (widget.keyPressed(int_1, int_2, int_3)) return true; diff --git a/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java index 620b1113f..e333ec131 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java @@ -221,7 +221,7 @@ public class EntryWidget extends WidgetWithBounds { else tooltip.getText().addAll(Arrays.asList(I18n.translate("text.rei.favorites_tooltip", name).split("\n"))); } - ScreenHelper.getLastOverlay().addTooltip(tooltip); + REIHelper.getInstance().addTooltip(tooltip); } } @@ -267,8 +267,8 @@ public class EntryWidget extends WidgetWithBounds { public boolean keyPressed(int int_1, int int_2, int int_3) { if (!interactable) return false; - if (containsMouse(PointHelper.fromMouse())) { - if (interactableFavorites && ConfigObject.getInstance().isFavoritesEnabled() && containsMouse(PointHelper.fromMouse()) && !getCurrentEntry().isEmpty()) { + if (containsMouse(PointHelper.ofMouse())) { + if (interactableFavorites && ConfigObject.getInstance().isFavoritesEnabled() && containsMouse(PointHelper.ofMouse()) && !getCurrentEntry().isEmpty()) { ModifierKeyCode keyCode = ConfigObject.getInstance().getFavoriteKeyCode(); EntryStack entry = getCurrentEntry().copy(); entry.setAmount(127); 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 c9557f33b..afd338e77 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java @@ -153,7 +153,7 @@ public class FavoritesListWidget extends WidgetWithBounds { ScissorsHandler.INSTANCE.removeLastScissor(); renderScrollbar(); if (containsMouse(mouseX, mouseY) && ClientHelper.getInstance().isCheating() && !minecraft.player.inventory.getCursorStack().isEmpty() && RoughlyEnoughItemsCore.hasPermissionToUsePackets()) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(I18n.translate("text.rei.delete_items"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(I18n.translate("text.rei.delete_items"))); } private int getScrollbarMinX() { @@ -194,7 +194,7 @@ public class FavoritesListWidget extends WidgetWithBounds { int scrollbarPositionMinX = getScrollbarMinX(); int scrollbarPositionMaxX = scrollbarPositionMinX + 6; - boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.fromMouse()); + boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.ofMouse()); float bottomC = (hovered ? .67f : .5f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); float topC = (hovered ? .87f : .67f) * (REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); @@ -239,7 +239,7 @@ public class FavoritesListWidget extends WidgetWithBounds { @Override public boolean keyPressed(int int_1, int int_2, int int_3) { - if (containsMouse(PointHelper.fromMouse())) + if (containsMouse(PointHelper.ofMouse())) for (Widget widget : children()) if (widget.keyPressed(int_1, int_2, int_3)) 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 f0e9a0edf..a878f45be 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.gui.widget; import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.client.gui.Element; import org.jetbrains.annotations.ApiStatus; @@ -172,6 +171,6 @@ public class LabelWidget extends WidgetWithBounds { protected void drawTooltips(int mouseX, int mouseY) { if (getTooltips().isPresent()) if (containsMouse(mouseX, mouseY)) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(getTooltips().get().split("\n"))); } } diff --git a/src/main/java/me/shedaniel/rei/gui/widget/QueuedTooltip.java b/src/main/java/me/shedaniel/rei/gui/widget/QueuedTooltip.java index 3362bf24e..4951189e8 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/QueuedTooltip.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/QueuedTooltip.java @@ -27,6 +27,7 @@ package me.shedaniel.rei.gui.widget; import com.google.common.collect.Lists; import me.shedaniel.math.api.Point; import me.shedaniel.math.impl.PointHelper; +import me.shedaniel.rei.api.REIHelper; import org.jetbrains.annotations.ApiStatus; import java.util.List; @@ -52,11 +53,11 @@ public class QueuedTooltip { } public static QueuedTooltip create(List text) { - return QueuedTooltip.create(PointHelper.fromMouse(), text); + return QueuedTooltip.create(PointHelper.ofMouse(), text); } public static QueuedTooltip create(String... text) { - return QueuedTooltip.create(PointHelper.fromMouse(), text); + return QueuedTooltip.create(PointHelper.ofMouse(), text); } @ApiStatus.Internal @@ -86,4 +87,8 @@ public class QueuedTooltip { return text; } + public void queue() { + REIHelper.getInstance().addTooltip(this); + } + } diff --git a/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java index de9529937..0f3b35c09 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java @@ -28,7 +28,6 @@ import me.shedaniel.rei.api.ClientHelper; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.RecipeCategory; -import me.shedaniel.rei.impl.ScreenHelper; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import org.jetbrains.annotations.ApiStatus; @@ -117,9 +116,9 @@ public class TabWidget extends WidgetWithBounds { private void drawTooltip() { if (this.minecraft.options.advancedItemTooltips) - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(categoryName, Formatting.DARK_GRAY.toString() + category.getIdentifier().toString(), ClientHelper.getInstance().getFormattedModFromIdentifier(category.getIdentifier()))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(categoryName, Formatting.DARK_GRAY.toString() + category.getIdentifier().toString(), ClientHelper.getInstance().getFormattedModFromIdentifier(category.getIdentifier()))); else - ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(categoryName, ClientHelper.getInstance().getFormattedModFromIdentifier(category.getIdentifier()))); + REIHelper.getInstance().addTooltip(QueuedTooltip.create(categoryName, ClientHelper.getInstance().getFormattedModFromIdentifier(category.getIdentifier()))); } @Override diff --git a/src/main/java/me/shedaniel/rei/gui/widget/TextFieldWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/TextFieldWidget.java index fed7499f9..b199f6539 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/TextFieldWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/TextFieldWidget.java @@ -404,7 +404,7 @@ public class TextFieldWidget extends WidgetWithBounds implements Tickable { public void renderBorder() { if (this.hasBorder()) { - if (containsMouse(PointHelper.fromMouse()) || focused) + if (containsMouse(PointHelper.ofMouse()) || focused) fill(this.bounds.x - 1, this.bounds.y - 1, this.bounds.x + this.bounds.width + 1, this.bounds.y + this.bounds.height + 1, REIHelper.getInstance().isDarkThemeEnabled() ? -17587 : -1); else fill(this.bounds.x - 1, this.bounds.y - 1, this.bounds.x + this.bounds.width + 1, this.bounds.y + this.bounds.height + 1, -6250336); diff --git a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index 6c83db607..f084d3b70 100644 --- a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -89,6 +89,10 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { }); private final Map modNameCache = Maps.newHashMap(); + /** + * @return the instance of {@link ClientHelperImpl} + * @see ClientHelper#getInstance() + */ @ApiStatus.Internal public static ClientHelperImpl getInstance() { return instance; diff --git a/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java b/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java index 6958408fe..31fffbf35 100644 --- a/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java +++ b/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java @@ -33,6 +33,7 @@ import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.OverlaySearchField; import me.shedaniel.rei.gui.RecipeScreen; +import me.shedaniel.rei.gui.widget.QueuedTooltip; import me.shedaniel.rei.gui.widget.TextFieldWidget; import me.shedaniel.rei.listeners.ContainerScreenHooks; import net.fabricmc.api.ClientModInitializer; @@ -45,6 +46,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import org.apache.logging.log4j.util.TriConsumer; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.LinkedHashSet; import java.util.List; @@ -61,10 +63,22 @@ public class ScreenHelper implements ClientModInitializer, REIHelper { private static LinkedHashSet lastRecipeScreen = Sets.newLinkedHashSetWithExpectedSize(5); private static ScreenHelper instance; + /** + * @return the instance of screen helper + * @see REIHelper#getInstance() + */ + @ApiStatus.Internal public static ScreenHelper getInstance() { return instance; } + @Override + public void addTooltip(@Nullable QueuedTooltip tooltip) { + if (overlay != null && tooltip != null) { + overlay.addTooltip(tooltip); + } + } + @Override public TextFieldWidget getSearchTextField() { return searchField; diff --git a/src/main/java/me/shedaniel/rei/impl/compat/ModelHasDepth1151Compat.java b/src/main/java/me/shedaniel/rei/impl/compat/ModelHasDepth1151Compat.java deleted file mode 100644 index 88a553e7d..000000000 --- a/src/main/java/me/shedaniel/rei/impl/compat/ModelHasDepth1151Compat.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.compat; - -import net.minecraft.client.render.model.BakedModel; - -import java.util.function.Predicate; - -public class ModelHasDepth1151Compat implements Predicate { - @Override - public boolean test(BakedModel bakedModel) { - return bakedModel.hasDepth(); - } -} diff --git a/src/main/java/me/shedaniel/rei/impl/compat/ModelSideLit1152Compat.java b/src/main/java/me/shedaniel/rei/impl/compat/ModelSideLit1152Compat.java deleted file mode 100644 index 7dd2a3167..000000000 --- a/src/main/java/me/shedaniel/rei/impl/compat/ModelSideLit1152Compat.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.compat; - -import net.minecraft.client.render.model.BakedModel; - -import java.util.function.Predicate; - -public class ModelSideLit1152Compat implements Predicate { - @Override - public boolean test(BakedModel bakedModel) { - return bakedModel.isSideLit(); - } -} diff --git a/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java b/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java index 369705030..a6ae15169 100644 --- a/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java +++ b/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java @@ -214,7 +214,7 @@ public class DefaultBeaconBaseCategory implements RecipeCategory