diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-06-17 21:52:16 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2023-05-29 21:00:06 +0800 |
| commit | 020a705d3947c38c1f27d6d322bade09a17c0853 (patch) | |
| tree | 1132de7c565bf74b47e011627379d94018b34cf4 /api/src/main/java | |
| parent | 50179d6edda37bd7ca2cfca82d6bb0014825b28b (diff) | |
| download | RoughlyEnoughItems-020a705d3947c38c1f27d6d322bade09a17c0853.tar.gz RoughlyEnoughItems-020a705d3947c38c1f27d6d322bade09a17c0853.tar.bz2 RoughlyEnoughItems-020a705d3947c38c1f27d6d322bade09a17c0853.zip | |
Too much docs for today
Diffstat (limited to 'api/src/main/java')
7 files changed, 211 insertions, 13 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 55c481151..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 @@ -101,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 @@ -114,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 @@ -127,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; @@ -152,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 @@ -167,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 fb1985970..f44523e9a 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 @@ -44,6 +44,9 @@ import org.jetbrains.annotations.Nullable; import java.util.Optional; +/** + * The runtime of REI. + */ @Environment(EnvType.CLIENT) public interface REIRuntime extends Reloadable<REIClientPlugin> { /** @@ -53,37 +56,121 @@ 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); + /** + * 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(); @ApiStatus.ScheduledForRemoval @@ -92,7 +179,18 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { return calculateEntryListArea(ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen)); } + /** + * 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/registry/screen/ExclusionZones.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ExclusionZones.java index 19a58c430..ec2bb7bb5 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ExclusionZones.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ExclusionZones.java @@ -30,10 +30,13 @@ import net.minecraft.client.gui.screens.Screen; import java.util.List; +/** + * The registry for querying and registering exclusion zones. + */ @Environment(EnvType.CLIENT) public interface ExclusionZones extends OverlayDecider { /** - * Returns the exclusion zones by the screen class + * Returns the exclusion zones by the screen class. * * @param currentScreenClass the current screen class * @return the list of exclusion zones @@ -45,7 +48,7 @@ public interface ExclusionZones extends OverlayDecider { } /** - * Returns the exclusion zones by the screen class + * Returns the exclusion zones by the screen class. * * @param currentScreenClass the current screen class * @return the list of exclusion zones @@ -55,7 +58,7 @@ public interface ExclusionZones extends OverlayDecider { List<Rectangle> getExclusionZones(Class<?> currentScreenClass, boolean sort); /** - * Returns the exclusion zones by the screen + * Returns the exclusion zones by the screen. * * @param screen the screen * @return the list of exclusion zones @@ -65,17 +68,22 @@ public interface ExclusionZones extends OverlayDecider { } /** - * Returns the exclusion zones by the screen + * Returns the exclusion zones by the screen. * * @param screen the screen * @return the list of exclusion zones */ List<Rectangle> getExclusionZones(Screen screen, boolean sort); + /** + * Returns the number of exclusion zone providers registered. + * + * @return the number of exclusion zone providers registered + */ int getZonesCount(); /** - * Register an exclusion zone + * Register an exclusion zone. * * @param screenClass the screen class * @param provider the exclusion zone provider, returns a collection of exclusion zones diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java index 1f9ab4faa..84798f6c5 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java @@ -38,6 +38,13 @@ import static net.minecraft.world.InteractionResult.PASS; */ @Environment(EnvType.CLIENT) public interface OverlayDecider extends Comparable<OverlayDecider> { + /** + * Returns whether this decider should be used to handle the specified screen. + * + * @param screen the screen + * @param <R> the type of the screen + * @return whether this decider should be used to handle the specified screen + */ <R extends Screen> boolean isHandingScreen(Class<R> screen); @ApiStatus.ScheduledForRemoval @@ -81,6 +88,9 @@ public interface OverlayDecider extends Comparable<OverlayDecider> { return PASS; } + /** + * {@inheritDoc} + */ @Override default int compareTo(OverlayDecider o) { return Double.compare(getPriority(), o.getPriority()); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java index b914a961d..ef932caed 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java @@ -59,6 +59,11 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +/** + * The registry for handling bounds and exclusion details of screens. + * + * @see ScreenRegistry#exclusionZones() for registering exclusion zones. + */ @Environment(EnvType.CLIENT) public interface ScreenRegistry extends Reloadable<REIClientPlugin> { /** @@ -168,8 +173,23 @@ public interface ScreenRegistry extends Reloadable<REIClientPlugin> { */ <T extends Screen> Rectangle getOverlayBounds(DisplayPanelLocation location, T screen); + /** + * Returns the focused stack given the mouse position. + * + * @param screen the screen to check + * @param mouse the mouse position + * @param <T> the type of screen + * @return the focused stack, may be {@code null} if there are no focused stack + * @see ScreenRegistry#registerFocusedStack(FocusedStackProvider) + */ @Nullable <T extends Screen> EntryStack<?> getFocusedStack(T screen, Point mouse); + /** + * Returns the exclusion zones registry for handling + * the registration and query of exclusion zones. + * + * @return the exclusion zones registry + */ ExclusionZones exclusionZones(); /** diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java index 46b11547a..732990437 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java @@ -61,13 +61,33 @@ public interface TransferHandler extends Comparable<TransferHandler> { return 0d; } + /** + * Handles the transfer of the specified display. + * <p> + * If {@link Context#isActuallyCrafting()} returns {@code false}, + * the transfer handler should <b>not</b> instantiate the transfer. + * + * @param context the context + * @return the result of the transfer + */ Result handle(Context context); + /** + * {@inheritDoc} + */ @Override default int compareTo(TransferHandler o) { return Double.compare(getPriority(), o.getPriority()); } + /** + * Returns the error renderer given the context and the error data. + * + * @param context the context + * @param data the error data + * @return the error renderer, or {@code null} + * @deprecated use {@link Result#renderer(TransferHandlerRenderer)} directly instead + */ @Deprecated @Environment(EnvType.CLIENT) @Nullable @@ -167,11 +187,26 @@ public interface TransferHandler extends Comparable<TransferHandler> { @Deprecated Result errorRenderer(Object data); + /** + * Sets the renderer of the transfer, to be used when the mouse hovers the plus button. + */ Result renderer(TransferHandlerRenderer renderer); + /** + * Overrides the tooltip renderer completely. + * + * @param renderer the renderer + * @return the result + */ @ApiStatus.Experimental Result overrideTooltipRenderer(BiConsumer<Point, TooltipSink> renderer); + /** + * Adds a line of tooltip to the result. + * + * @param component the component to add + * @return the result + */ Result tooltip(Component component); /** diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java index cb426d6c1..872b23e14 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java @@ -31,6 +31,9 @@ import me.shedaniel.rei.api.common.registry.Reloadable; import java.util.Collection; public interface Views extends Reloadable<REIClientPlugin> { + /** + * @return the instance of {@link Views} + */ static Views getInstance() { return PluginManager.getClientInstance().get(Views.class); } |
