aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-28 01:36:29 +0800
committerGitHub <noreply@github.com>2022-06-28 01:36:29 +0800
commit0f4b089286eb0349f5b1b1c1b6f9ebd861fa0ba4 (patch)
treeeb623bddf5045f83909eba930ee48058859b5ab7 /api/src/main/java/me
parent85ecd54de2309184b1cbc0153236b67426c17cb7 (diff)
parent8e69d8f9a5101b7518aecd2d4576688653c884bb (diff)
downloadRoughlyEnoughItems-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/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java49
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java109
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java14
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java142
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/addon/ConfigAddon.java59
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/addon/ConfigAddonRegistry.java56
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java45
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/region/RegionEntry.java3
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/favorites/SystemFavoriteEntryProvider.java3
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java1
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java22
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/CloseableScissors.java35
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java46
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Tooltip.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TooltipContext.java12
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widget.java28
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java47
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java12
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java23
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/category/ButtonArea.java9
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java121
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/category/extension/CategoryExtensionProvider.java8
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/category/visibility/CategoryVisibilityPredicate.java17
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java59
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategoryView.java45
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java17
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DynamicDisplayGenerator.java30
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/visibility/DisplayVisibilityPredicate.java16
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntryRegistry.java100
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java33
-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.java85
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerRenderer.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java79
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/view/Views.java3
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/category/CategoryIdentifier.java48
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/Display.java22
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/DisplayMerger.java21
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializer.java13
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java22
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/SimpleDisplaySerializer.java27
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/SimpleGridMenuDisplay.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/basic/BasicDisplay.java106
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java113
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntrySerializer.java23
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java343
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/InputIngredient.java42
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java30
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java37
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java10
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java10
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java36
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryType.java27
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/registry/RecipeManagerContext.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/EntryIngredients.java47
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java6
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/TextRepresentable.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java19
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);
+ /**