diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-06-28 01:36:29 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-28 01:36:29 +0800 |
| commit | 0f4b089286eb0349f5b1b1c1b6f9ebd861fa0ba4 (patch) | |
| tree | eb623bddf5045f83909eba930ee48058859b5ab7 /api/src/main/java | |
| parent | 85ecd54de2309184b1cbc0153236b67426c17cb7 (diff) | |
| parent | 8e69d8f9a5101b7518aecd2d4576688653c884bb (diff) | |
| download | RoughlyEnoughItems-0f4b089286eb0349f5b1b1c1b6f9ebd861fa0ba4.tar.gz RoughlyEnoughItems-0f4b089286eb0349f5b1b1c1b6f9ebd861fa0ba4.tar.bz2 RoughlyEnoughItems-0f4b089286eb0349f5b1b1c1b6f9ebd861fa0ba4.zip | |
Merge pull request #931 from shedaniel/feature/rei_8.3
REI 8.3
Diffstat (limited to 'api/src/main/java')
60 files changed, 2238 insertions, 156 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java b/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java index d9f0eae23..2e1be6030 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java @@ -75,6 +75,15 @@ public interface ClientHelper { boolean tryCheatingEntry(EntryStack<?> stack); /** + * Tries to cheat stack into the given slot. + * + * @param stack the stack to cheat in + * @param hotbarSlotId the hotbar slot id + * @return whether it failed + */ + boolean tryCheatingEntryTo(EntryStack<?> stack, int hotbarSlotId); + + /** * Gets the mod from an item * * @param item the item to find @@ -92,7 +101,7 @@ public interface ClientHelper { void sendDeletePacket(); /** - * Gets the formatted mod from an item + * Returns the formatted mod from an item * * @param item the item to find * @return the mod name with blue and italic formatting @@ -105,7 +114,7 @@ public interface ClientHelper { } /** - * Gets the formatted mod from an identifier + * Returns the formatted mod from an identifier * * @param identifier the identifier to find * @return the mod name with blue and italic formatting @@ -118,18 +127,25 @@ public interface ClientHelper { } /** - * Gets the mod from a modid + * Returns the mod from a modid * - * @param modid the modid of the mod + * @param modId the modid of the mod * @return the mod name with blue and italic formatting */ - default Component getFormattedModFromModId(String modid) { - String mod = getModFromModId(modid); + default Component getFormattedModFromModId(String modId) { + String mod = getModFromModId(modId); if (mod.isEmpty()) return NarratorChatListener.NO_TITLE; return new TextComponent(mod).withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC); } + /** + * Appends the formatted mod to the list of tooltip components. + * + * @param components the list of tooltip components + * @param modId the modid of the mod + * @return the list of tooltip components + */ default List<Component> appendModIdToTooltips(List<Component> components, String modId) { final String modName = ClientHelper.getInstance().getModFromModId(modId); boolean alreadyHasMod = false; @@ -143,10 +159,16 @@ public interface ClientHelper { return components; } + /** + * Appends the formatted mod to the tooltip. + * + * @param components the tooltip + * @param modId the modid of the mod + */ void appendModIdToTooltips(Tooltip components, String modId); /** - * Gets the mod from an identifier + * Returns the mod from an identifier * * @param identifier the identifier to find * @return the mod name @@ -158,14 +180,25 @@ public interface ClientHelper { } /** - * Gets the mod from a modid + * Returns the mod from a modid * * @param modId the modid of the mod * @return the mod name */ String getModFromModId(String modId); + /** + * Opens the view after the search is complete. + * + * @param builder the view search builder + * @return whether the view was opened + */ boolean openView(ViewSearchBuilder builder); + /** + * Returns whether the client can use move items packets. + * + * @return whether the client can use move items packets + */ boolean canUseMovePackets(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java b/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java index 6edf223e6..a17751703 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.api.client; import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation; import me.shedaniel.rei.api.client.gui.widgets.TextField; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; @@ -36,10 +37,14 @@ import net.fabricmc.api.Environment; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import java.util.Optional; +/** + * The runtime of REI. + */ @Environment(EnvType.CLIENT) public interface REIRuntime extends Reloadable<REIClientPlugin> { /** @@ -49,40 +54,144 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { return PluginManager.getClientInstance().get(REIRuntime.class); } + /** + * Returns whether the overlay is visible, this is usually toggled by + * the user with a keybind. + * + * @return whether the overlay is visible + */ boolean isOverlayVisible(); + /** + * Toggles the visibility of the overlay. + */ void toggleOverlayVisible(); + /** + * Returns the screen overlay of REI, if available and constructed. + * + * @return the screen overlay + */ default Optional<ScreenOverlay> getOverlay() { return getOverlay(false, false); } + /** + * Returns the screen overlay of REI. + * <p> + * if {@param reset} is {@code true}, the overlay will be reset, + * and the returned value <b>must</b> not be {@code null}. + * + * @param reset whether to reset the overlay + * @return the screen overlay + */ default Optional<ScreenOverlay> getOverlay(boolean reset) { return getOverlay(reset, true); } + /** + * Returns the screen overlay of REI. + * <p> + * If {@param reset} is {@code true}, the overlay will be reset, + * and the returned value <b>must</b> not be {@code null}. + * <p> + * If the overlay has not been constructed yet, and {@param init} is {@code true}, + * the overlay will be constructed, and the returned value <b>must</b> not be {@code null}. + * + * @param reset whether to reset the overlay + * @param init whether to init the overlay if it has not been constructed yet + * @return the screen overlay + */ Optional<ScreenOverlay> getOverlay(boolean reset, boolean init); + /** + * Returns the previous opened container screen, if available. + * + * @return the previous opened container screen, or {@code null} if none + */ @Nullable AbstractContainerScreen<?> getPreviousContainerScreen(); + /** + * Returns the previous opened screen, if available. + * + * @return the previous opened screen, or {@code null} if none + */ @Nullable Screen getPreviousScreen(); + /** + * Returns whether dark mode is enabled. + * + * @return whether dark mode is enabled + * @see ConfigObject#isUsingDarkTheme() + */ boolean isDarkThemeEnabled(); + /** + * Returns the text field used for searching, if constructed. + * + * @return the text field used for searching, or {@code null} if none + */ @Nullable TextField getSearchTextField(); + /** + * Queues a tooltip to be displayed. + * + * @param tooltip the tooltip to display, or {@code null} + * @see Tooltip#queue() + */ void queueTooltip(@Nullable Tooltip tooltip); + /** + * Clear all queued tooltips. + * + * @see Tooltip#queue() + * @since 8.3 + */ + @ApiStatus.Experimental + void clearTooltips(); + + /** + * Returns the texture location of the default display background. + * <p> + * This is different depending on whether dark mode is enabled. + * + * @return the texture location of the default display background + */ ResourceLocation getDefaultDisplayTexture(); + /** + * Returns the texture location of the default display background. + * + * @param darkTheme whether dark mode is enabled + * @return the texture location of the default display background + */ ResourceLocation getDefaultDisplayTexture(boolean darkTheme); + /** + * Returns the location of the search field, according to the current screen. + * <p> + * If the config location is center, and the current screen is too small to display + * the search field at the bottom center, the location returned will be the side. + * + * @return the location of the search field + */ SearchFieldLocation getContextualSearchFieldLocation(); + /** + * Calculates the area of the entry list, given the bounds of the overlay. + * + * @param bounds the bounds of the overlay + * @return the area of the entry list + */ Rectangle calculateEntryListArea(Rectangle bounds); + /** + * Calculates the area of the favorites list. + * + * @return the area of the favorites list + */ Rectangle calculateFavoritesListArea(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java index b65b54f54..2d898d524 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java @@ -46,19 +46,19 @@ public interface ConfigManager extends Reloadable<REIClientPlugin> { void saveConfig(); /** - * Gets if craftable only filter is enabled + * Returns whether the craftable only filter is enabled. * * @return whether craftable only filter is enabled */ boolean isCraftableOnlyEnabled(); /** - * Toggles the craftable only filter + * Toggles the craftable only filter. */ void toggleCraftableOnly(); /** - * Opens the config screen + * Opens the config screen. * * @param parent the screen shown before */ @@ -67,12 +67,18 @@ public interface ConfigManager extends Reloadable<REIClientPlugin> { } /** - * Gets the config screen + * Returns the config screen. * * @param parent the screen shown before * @return the config screen */ Screen getConfigScreen(Screen parent); + /** + * Returns the config object. + * + * @return the config object + * @see ConfigObject#getInstance() + */ ConfigObject getConfig(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index efbe5aca1..b8ce1656c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.api.client.config; import me.shedaniel.clothconfig2.api.ModifierKeyCode; +import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.entry.EntryStackProvider; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.config.*; @@ -42,57 +43,196 @@ public interface ConfigObject { return ConfigManager.getInstance().getConfig(); } + /** + * Returns whether the overlay is visible. + * + * @return whether the overlay is visible + */ boolean isOverlayVisible(); + /** + * Sets whether the overlay is visible. + * + * @param overlayVisible whether the overlay should be visible + */ void setOverlayVisible(boolean overlayVisible); + /** + * Returns whether cheating is enabled. This method may return + * the contextual cheating state if cheat mode is set to Creative Only. + * + * @return whether cheating is enabled + * @see #getCheatingMode() + */ boolean isCheating(); + /** + * Sets whether cheating is enabled. + * + * @param cheating whether cheating should be enabled + */ void setCheating(boolean cheating); + /** + * Returns the cheating mode. + * + * @return the cheating mode + * @see #isCheating() |
