aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me/shedaniel
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-17 21:52:16 +0800
committershedaniel <daniel@shedaniel.me>2022-06-28 03:21:12 +0800
commit7e790c08686fbf920af81c62115970dbde44ac9c (patch)
tree59ef3c5e302bed3f476ad23062735f88e62ecacf /api/src/main/java/me/shedaniel
parent0f9bfd885ca75a930d012309266df228a954a9d4 (diff)
downloadRoughlyEnoughItems-7e790c08686fbf920af81c62115970dbde44ac9c.tar.gz
RoughlyEnoughItems-7e790c08686fbf920af81c62115970dbde44ac9c.tar.bz2
RoughlyEnoughItems-7e790c08686fbf920af81c62115970dbde44ac9c.zip
Too much docs for today
Diffstat (limited to 'api/src/main/java/me/shedaniel')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java40
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java99
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ExclusionZones.java18
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java10
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/screen/ScreenRegistry.java20
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java27
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/view/Views.java3
7 files changed, 204 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 88808268a..7ce6d1b1d 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
@@ -100,7 +100,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
@@ -113,7 +113,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
@@ -126,18 +126,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 Component.literal(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;
@@ -151,10 +158,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
@@ -166,14 +179,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..8c3d68d4f 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;
@@ -40,6 +41,9 @@ import org.jetbrains.annotations.Nullable;
import java.util.Optional;
+/**
+ * The runtime of REI.
+ */
@Environment(EnvType.CLIENT)
public interface REIRuntime extends Reloadable<REIClientPlugin> {
/**
@@ -49,40 +53,135 @@ 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();
+ /**
+ * 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 92da6b563..dbab5912d 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> {
/**
@@ -160,8 +165,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 55f50e2b3..a32474290 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
@@ -59,8 +59,20 @@ 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());
@@ -125,11 +137,26 @@ public interface TransferHandler extends Comparable<TransferHandler> {
*/
Result color(int color);
+ /**
+ * 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 0baa9d3d4..407e4dfde 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
@@ -33,6 +33,9 @@ import org.jetbrains.annotations.Nullable;
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);
}