diff options
Diffstat (limited to 'api/src/main')
64 files changed, 1601 insertions, 211 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 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 createSlot(EntryIngredient ingredient) { return Widgets.createSlot(new Point(0, 0)) .entries(CollectionUtils.filterToList(ingredient, stack -> !stack.isEmpty())) - .disableBackground() - .disableHighlight() - .disableTooltips(); + .noBackground() + .noHighlight() + .noTooltips(); } public static List<EntryIngredient> simplify(List<EntryIngredient> original) { @@ -123,10 +123,10 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold int xx = bounds.x + 4, yy = bounds.y + 2; int j = 0; int itemsPerLine = getItemsPerLine(); - for (Slot entryWidget : inputWidgets) { - entryWidget.setZ(getZ() + 50); - entryWidget.getBounds().setLocation(xx, yy); - entryWidget.render(matrices, mouseX, mouseY, delta); + for (Slot slot : inputWidgets) { + slot.setZ(getZ() + 50); + slot.getBounds().setLocation(xx, yy); + slot.render(matrices, mouseX, mouseY, delta); xx += 18; j++; if (j >= getItemsPerLine() - 2) { diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/BatchedSlots.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/BatchedSlots.java new file mode 100644 index 000000000..6cead07dd --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/BatchedSlots.java @@ -0,0 +1,40 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * |
