diff options
Diffstat (limited to 'api')
65 files changed, 1601 insertions, 269 deletions
diff --git a/api/build.gradle b/api/build.gradle deleted file mode 100644 index 23ee2975c..000000000 --- a/api/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -import net.fabricmc.loom.task.RemapJarTask - -archivesBaseName = rootProject.name + "-" + project.name - -dependencies { - modCompileOnly("net.fabricmc:fabric-loader:${project.fabricloader_version}") - modApi("me.shedaniel.cloth:cloth-config:${cloth_config_version}") - modApi("dev.architectury:architectury:${architectury_version}") -} - -architectury { - common(forgeEnabled.toBoolean()) -} - -remapJar { - classifier "raw" -} - -task fakeJar(type: Jar, dependsOn: remapJar) { - from remapJar.archiveFile.map { zipTree(it) } - from(rootProject.file("fake/fabric.mod.json")) { - into "" - } - classifier null -} - -task fakeForgeJar(type: Jar, dependsOn: jar) { - from jar.archiveFile.map { zipTree(it) } - from(rootProject.file("fake/mods.toml")) { - into "META-INF" - } - ["REIPlugin", "REIPluginClient", "REIPluginCommon", "REIPluginDedicatedServer", - "REIPluginLoader", "REIPluginLoaderClient", "REIPluginLoaderCommon", "REIPluginLoaderDedicatedServer"].each { - from(rootProject.file("fake/$it.class")) { - into "me/shedaniel/rei/forge" - } - } - classifier "fake-forge" -} - -artifacts { - apiElements(fakeJar) - runtimeElements(fakeJar) -} - -afterEvaluate { - configurations.apiElements.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(tasks.remapJar) } - configurations.runtimeElements.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(tasks.remapJar) } -} - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.name + "-" + project.name - from components.java - } - } -} 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 2e1be6030..5eb95053b 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 @@ -24,11 +24,14 @@ package me.shedaniel.rei.api.client; import me.shedaniel.rei.api.client.config.ConfigManager; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.networking.NetworkModule; +import me.shedaniel.rei.api.common.networking.NetworkingHelper; import me.shedaniel.rei.api.common.util.FormattingUtils; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.client.ClientInternals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; @@ -56,7 +59,9 @@ public interface ClientHelper { * * @return whether cheating is enabled */ - boolean isCheating(); + default boolean isCheating() { + return ConfigObject.getInstance().isCheating(); + } /** * Sets current cheating mode @@ -64,7 +69,10 @@ public interface ClientHelper { * * @param cheating the new cheating mode */ - void setCheating(boolean cheating); + default void setCheating(boolean cheating) { + ConfigObject.getInstance().setCheating(cheating); + ConfigManager.getInstance().saveConfig(); + } /** * Tries to cheat stack using either packets or commands. @@ -200,5 +208,8 @@ public interface ClientHelper { * * @return whether the client can use move items packets */ - boolean canUseMovePackets(); + @Deprecated(forRemoval = true) + default boolean canUseMovePackets() { + return NetworkingHelper.getInstance().canUse(NetworkModule.TRANSFER); + } } 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 a17751703..41e0870d3 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,10 +24,12 @@ package me.shedaniel.rei.api.client; import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.config.ConfigManager; 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; +import me.shedaniel.rei.api.client.gui.widgets.TooltipQueue; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.plugins.PluginManager; @@ -60,12 +62,17 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { * * @return whether the overlay is visible */ - boolean isOverlayVisible(); + default boolean isOverlayVisible() { + return ConfigObject.getInstance().isOverlayVisible(); + } /** * Toggles the visibility of the overlay. */ - void toggleOverlayVisible(); + default void toggleOverlayVisible() { + ConfigObject.getInstance().setOverlayVisible(!ConfigObject.getInstance().isOverlayVisible()); + ConfigManager.getInstance().saveConfig(); + } /** * Returns the screen overlay of REI, if available and constructed. @@ -126,7 +133,9 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { * @return whether dark mode is enabled * @see ConfigObject#isUsingDarkTheme() */ - boolean isDarkThemeEnabled(); + default boolean isDarkThemeEnabled() { + return ConfigObject.getInstance().isUsingDarkTheme(); + } /** * Returns the text field used for searching, if constructed. @@ -134,7 +143,9 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { * @return the text field used for searching, or {@code null} if none */ @Nullable - TextField getSearchTextField(); + default TextField getSearchTextField() { + return getOverlay().map(ScreenOverlay::getSearchField).orElse(null); + } /** * Queues a tooltip to be displayed. @@ -142,7 +153,11 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { * @param tooltip the tooltip to display, or {@code null} * @see Tooltip#queue() */ - void queueTooltip(@Nullable Tooltip tooltip); + default void queueTooltip(@Nullable Tooltip tooltip) { + if (getOverlay(false, false).isEmpty()) { + TooltipQueue.getInstance().queue(tooltip); + } + } /** * Clear all queued tooltips. @@ -151,7 +166,11 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { * @since 8.3 */ @ApiStatus.Experimental - void clearTooltips(); + default void clearTooltips() { + if (getOverlay(false, false).isEmpty()) { + TooltipQueue.getInstance().clear(); + } + } /** * Returns the texture location of the default display background. @@ -160,7 +179,9 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { * * @return the texture location of the default display background */ - ResourceLocation getDefaultDisplayTexture(); + default ResourceLocation getDefaultDisplayTexture() { + return getDefaultDisplayTexture(isDarkThemeEnabled()); + } /** * Returns the texture location of the default display background. diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringResult.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringResult.java index 4d4392ae9..d523a650f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringResult.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringResult.java @@ -24,13 +24,10 @@ package me.shedaniel.rei.api.client.entry.filtering; import me.shedaniel.rei.api.common.entry.EntryStack; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import org.jetbrains.annotations.ApiStatus; import java.util.Collection; -@Environment(EnvType.CLIENT) @ApiStatus.Experimental public interface FilteringResult { FilteringResult hide(EntryStack<?> stack); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java index 1f3cb5b50..67fa66b0c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRule.java @@ -63,4 +63,4 @@ public interface FilteringRule<Cache> { * @return the result of the processing */ FilteringResult processFilteredStacks(FilteringContext context, FilteringResultFactory resultFactory, Cache cache, boolean async); -}
\ No newline at end of file +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRuleTypeRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRuleTypeRegistry.java index 16638a828..781b31f88 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRuleTypeRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/filtering/FilteringRuleTypeRegistry.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.api.client.entry.filtering; import me.shedaniel.rei.api.client.entry.filtering.base.BasicFilteringRule; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.client.ClientInternals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.resources.ResourceLocation; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java index c51309603..2aa203aa9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java @@ -29,7 +29,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.api.common.entry.type.BuiltinEntryTypes; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import org.jetbrains.annotations.ApiStatus; @@ -46,7 +46,7 @@ import org.jetbrains.annotations.Nullable; @Environment(EnvType.CLIENT) public interface EntryRenderer<T> extends EntryRendererProvider<T> { static <T> EntryRenderer<T> empty() { - return ClientInternals.getEmptyEntryRenderer(); + return (EntryRenderer<T>) BuiltinEntryTypes.EMPTY.getDefinition().getRenderer(); } @Environment(EnvType.CLIENT) diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java index 6c5415910..e1f18684d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java @@ -29,7 +29,7 @@ import me.shedaniel.rei.api.client.entry.region.RegionEntry; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.util.ClientEntryStacks; import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.client.ClientInternals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.nbt.CompoundTag; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java index 35a5e8f96..d80c567b0 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java @@ -80,7 +80,7 @@ public interface FavoriteEntryType<T extends FavoriteEntry> { default void add(FavoriteEntry... entries) { add(false, entries); } - + @ApiStatus.Experimental void add(boolean defaultFavorited, FavoriteEntry... entries); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java index 92646aa0d..2270a8ab9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java @@ -66,9 +66,9 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold protected Slot |
