diff options
44 files changed, 2171 insertions, 1210 deletions
diff --git a/fabric/build.gradle b/fabric/build.gradle index 9ce45f7d5..39157c8cb 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -106,6 +106,10 @@ publishing { builtBy remapSourcesJarTask classifier "sources" } + + // Hack to inherit the dependencies without inheriting the artifacts + publication.setArtifacts(publication.artifacts) + from components.java } } } diff --git a/forge/build.gradle b/forge/build.gradle index 33df86eb4..811d03a71 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -215,6 +215,10 @@ publishing { builtBy remapSrgSourcesJar classifier "sources" } + + // Hack to inherit the dependencies without inheriting the artifacts + publication.setArtifacts(publication.artifacts) + from components.java } } } diff --git a/forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java index e69855315..d4db2f068 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.forge; -import me.shedaniel.rei.RoughlyEnoughItemsState; import me.shedaniel.rei.impl.init.PrimitivePlatformAdapter; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.ModList; @@ -39,9 +38,6 @@ public class PrimitivePlatformAdapterImpl implements PrimitivePlatformAdapter { @Override public void checkMods() { - if (ModList.get().isLoaded("moreoverlays")) { - RoughlyEnoughItemsState.error("REI is not compatible with MoreOverlays, and actually contains Builtin Inventory Highlighting, other features can be installed via different mods!"); - } } @Override diff --git a/gradle.properties b/gradle.properties index bb1af7a0e..38be3f309 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ unstable=false supported_version=1.21(.1) minecraft_version=1.21 platforms=fabric,neoforge -forge_version=49.0.3 +forge_version=49.1.10 neoforge_version=21.0.167 neoforge_pr= fabricloader_version=0.16.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c747c1bd8..0b2225055 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 44f81780c..23750177d 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -152,6 +152,10 @@ publishing { builtBy remapMojangSourcesJar classifier "sources" } + + // Hack to inherit the dependencies without inheriting the artifacts + publication.setArtifacts(publication.artifacts) + from components.java } } } diff --git a/neoforge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java b/neoforge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java index 01491ecb5..6174b100c 100644 --- a/neoforge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java +++ b/neoforge/src/main/java/me/shedaniel/rei/forge/PrimitivePlatformAdapterImpl.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.forge; -import me.shedaniel.rei.RoughlyEnoughItemsState; import me.shedaniel.rei.impl.init.PrimitivePlatformAdapter; import net.neoforged.api.distmarker.Dist; import net.neoforged.fml.ModList; @@ -39,9 +38,6 @@ public class PrimitivePlatformAdapterImpl implements PrimitivePlatformAdapter { @Override public void checkMods() { - if (ModList.get().isLoaded("moreoverlays")) { - RoughlyEnoughItemsState.error("REI is not compatible with MoreOverlays, and actually contains Builtin Inventory Highlighting, other features can be installed via different mods!"); - } } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java index 7840fa6cd..41e91b7c9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java @@ -658,6 +658,8 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Comment("Declares whether subsets is enabled.") public boolean isSubsetsEnabled = false; public boolean allowInventoryHighlighting = true; + public double inventoryHighlightingDarkenOpacity = 0.85; + public double inventoryHighlightingOpacity = 1.0; public ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java index 5f95d3417..5abce4d44 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java @@ -82,6 +82,8 @@ public class REIConfigScreen extends Screen implements ConfigAccess { @Nullable private Menu menu; @Nullable + private Widget menuWidget; + @Nullable private CompositeOption<ModifierKeyCode> focusedKeycodeOption = null; private ModifierKeyCode partialKeycode = null; @@ -397,14 +399,18 @@ public class REIConfigScreen extends Screen implements ConfigAccess { @Override public void openMenu(Menu menu) { + if (this.menu != null) { + this.widgets.remove(this.menuWidget); + } this.menu = menu; - this.widgets.add(menu); + this.widgets.add(this.menuWidget = Widgets.withTranslate(menu, 0, 0, 300)); } @Override public void closeMenu() { - this.widgets.remove(menu); + this.widgets.remove(this.menuWidget); this.menu = null; + this.menuWidget = null; } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java index 9f2b659d1..0204516e8 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigCategories.java @@ -51,6 +51,7 @@ public interface AllREIConfigCategories { OptionCategory ACCESSIBILITY = make("accessibility") .add(ACCESSIBILITY_DISPLAY) .add(ACCESSIBILITY_WIDGETS) + .add(ACCESSIBILITY_INVENTORY_SEARCH) .add(ACCESSIBILITY_FEATURES); OptionCategory FILTERING = make("filtering") .add(FILTERING_FILTERING) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java index b206fd6e5..474132b8e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java @@ -68,10 +68,13 @@ public interface AllREIConfigGroups { OptionGroup ACCESSIBILITY_WIDGETS = make("accessibility.widgets") .add(SCROLLBAR_VISIBILITY) .add(CLICKABLE_RECIPE_ARROWS); + OptionGroup ACCESSIBILITY_INVENTORY_SEARCH = make("accessibility.inventory_search") + .add(INVENTORY_SEARCH_MODE) + .add(INVENTORY_SEARCH_DARKEN_OPACITY) + .add(INVENTORY_SEARCH_OPACITY); OptionGroup ACCESSIBILITY_FEATURES = make("accessibility.features") .add(VANILLA_RECIPE_BOOK) - .add(STATUS_EFFECTS_LOCATION) - .add(INVENTORY_SEARCH); + .add(STATUS_EFFECTS_LOCATION); OptionGroup FILTERING_FILTERING = make("filtering.filtering") .add(CATEGORIES) .add(CUSTOMIZED_FILTERING); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java index 97119df2e..30a673e38 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java @@ -60,6 +60,15 @@ public interface AllREIConfigOptions { translatable("config.rei.options." + id + ".desc"), bind, save); } + static ComparableValue<Double>[] doubleRange(double start, double end, double step) { + int length = (int) Math.ceil((end - start) / step + 1); + ComparableValue<Double>[] result = new ComparableValue[length]; + for (int i = 0; i < length; i++) { + result[i] = ComparableValue.ofDouble(Math.min(start + i * step, end)); + } + return result; + } + CompositeOption<AppearanceTheme> THEME = make("appearance.theme", i -> i.appearance.theme, (i, v) -> i.appearance.theme = v) .enumOptions(); CompositeOption<RecipeBorderType> RECIPE_BORDER = make("appearance.recipe_border", i -> i.appearance.recipeBorder, (i, v) -> i.appearance.recipeBorder = v) @@ -140,12 +149,18 @@ public interface AllREIConfigOptions { .ofBoolean(translatable("config.rei.value.accessibility.scrollbar_visibility.when_scrolling"), translatable("config.rei.value.accessibility.scrollbar_visibility.always")); CompositeOption<Boolean> CLICKABLE_RECIPE_ARROWS = make("accessibility.clickable_recipe_arrows", i -> i.advanced.miscellaneous.clickableRecipeArrows, (i, v) -> i.advanced.miscellaneous.clickableRecipeArrows = v) .enabledDisabled(); + CompositeOption<Boolean> INVENTORY_SEARCH_MODE = make("accessibility.inventory_search_mode", i -> i.functionality.allowInventoryHighlighting, (i, v) -> i.functionality.allowInventoryHighlighting = v) + .enabledDisabled(); + CompositeOption<ComparableValue<Double>> INVENTORY_SEARCH_DARKEN_OPACITY = make("accessibility.inventory_search_darken_opacity", i -> ComparableValue.ofDouble(i.functionality.inventoryHighlightingDarkenOpacity), (i, v) -> i.functionality.inventoryHighlightingDarkenOpacity = v.value()) + .entry(OptionValueEntry.options(doubleRange(0.0, 1.0, 0.05)) + .overrideText(d -> literal("%.0f%%".formatted(d.value() * 100)))); + CompositeOption<ComparableValue<Double>> INVENTORY_SEARCH_OPACITY = make("accessibility.inventory_search_opacity", i -> ComparableValue.ofDouble(i.functionality.inventoryHighlightingOpacity), (i, v) -> i.functionality.inventoryHighlightingOpacity = v.value()) + .entry(OptionValueEntry.options(doubleRange(0.0, 1.0, 0.05)) + .overrideText(d -> literal("%.0f%%".formatted(d.value() * 100)))); CompositeOption<Boolean> VANILLA_RECIPE_BOOK = make("accessibility.vanilla_recipe_book", i -> !i.functionality.disableRecipeBook, (i, v) -> i.functionality.disableRecipeBook = !v) .enabledDisabled(); CompositeOption<Boolean> STATUS_EFFECTS_LOCATION = make("accessibility.status_effects_location", i -> i.functionality.leftSideMobEffects, (i, v) -> i.functionality.leftSideMobEffects = v) .ofBoolean(translatable("config.rei.value.accessibility.status_effects_location.right"), translatable("config.rei.value.accessibility.status_effects_location.left")); - CompositeOption<Boolean> INVENTORY_SEARCH = make("accessibility.inventory_search", i -> i.functionality.allowInventoryHighlighting, (i, v) -> i.functionality.allowInventoryHighlighting = v) - .enabledDisabled(); CompositeOption<ConfigureCategoriesScreen> CATEGORIES = make("filtering.categories", i -> { return new ConfigureCategoriesScreen( new HashMap<>(i.getFilteringQuickCraftCategories()), @@ -182,7 +197,9 @@ public interface AllREIConfigOptions { .ofBoolean(translatable("config.rei.value.list.display_mode.paginated"), translatable("config.rei.value.list.display_mode.scrolled")); CompositeOption<EntryPanelOrderingConfig> ORDERING = make("list.ordering", i -> i.advanced.layout.entryPanelOrdering, (i, v) -> i.advanced.layout.entryPanelOrdering = v) .enumOptions(); - CompositeOption<Double> ZOOM = make("list.zoom", i -> i.advanced.accessibility.entrySize, (i, v) -> i.advanced.accessibility.entrySize = v); + CompositeOption<ComparableValue<Double>> ZOOM = make("list.zoom", i -> ComparableValue.ofDouble(i.advanced.accessibility.entrySize), (i, v) -> i.advanced.accessibility.entrySize = v.value()) + .entry(OptionValueEntry.options(doubleRange(0.25, 4.0, 0.25)) + .overrideText(d -> literal("%.0f%%".formatted(d.value() * 100)))); CompositeOption<Boolean> FOCUS_MODE = make("list.focus_mode", i -> i.appearance.isFocusModeZoomed, (i, v) -> i.appearance.isFocusModeZoomed = v) .ofBoolean(translatable("config.rei.value.list.focus_mode.highlighted"), translatable("config.rei.value.list.focus_mode.zoomed")); CompositeOption<CollapsibleConfigManager.CollapsibleConfigObject> COLLAPSIBLE_ENTRIES = make("list.collapsible_entries", i -> { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ComparableValue.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ComparableValue.java new file mode 100644 index 000000000..d3cea57a3 --- /dev/null +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ComparableValue.java @@ -0,0 +1,70 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.impl.client.gui.config.options; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.Objects; +import java.util.function.BiPredicate; + +@ApiStatus.Internal +public final class ComparableValue<T> { + private final T value; + private final BiPredicate<T, Object> equals; + + private ComparableValue(T value, BiPredicate<T, Object> equals) { + this.value = value; + this.equals = equals; + } + + public static <T> ComparableValue<T> of(T value, BiPredicate<T, Object> equals) { + return new ComparableValue<>(value, equals); + } + + public static ComparableValue<Float> ofFloat(float value) { + return of(value, (a, b) -> b instanceof Float f && Math.abs(a - f) <= 0.001F); + } + + public static ComparableValue<Double> ofDouble(double value) { + return of(value, (a, b) -> b instanceof Double d && Math.abs(a - d) <= 0.001D); + } + + public T value() { + return value; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof ComparableValue) { + return equals.test(value, ((ComparableValue<?>) obj).value); + } + + return false; + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } +} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java index d1ef77787..fa058a1d9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/OptionValueEntry.java @@ -82,7 +82,7 @@ public interface OptionValueEntry<T> { }; } - static <T> OptionValueEntry<T> options(T... options) { + static <T> OptionValueEntry.Selection<T> options(T... options) { return new Selection<>() { @Override public List<T> getOptions() { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java index 38c259e8c..b90ca9a37 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/configure/PanelBoundariesConfiguration.java @@ -308,7 +308,7 @@ public enum PanelBoundariesConfiguration implements OptionValueEntry.Configurato } private void renderPreview(GuiGraphics graphics, Rectangle panelBounds, float delta) { - int entrySize = Mth.ceil(18 * access.get(AllREIConfigOptions.ZOOM)); + int entrySize = Mth.ceil(18 * access.get(AllREIConfigOptions.ZOOM).value()); Rectangle overlayBounds; DisplayPanelLocation location = access.get(AllREIConfigOptions.LOCATION); PanelBoundary boundary = access.get(option); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java index 72e579ade..be711e98c 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryHighlighter.java @@ -24,34 +24,39 @@ package me.shedaniel.rei.impl.client.gui.widget; import com.mojang.blaze3d.systems.RenderSystem; +import me.shedaniel.math.Color; import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListSearchManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.RenderType; import net.minecraft.world.inventory.Slot; public class EntryHighlighter { public static void render(GuiGraphics graphics) { + float dimOpacity = (float) ConfigManagerImpl.getInstance().getConfig().functionality.inventoryHighlightingDarkenOpacity; + float opacity = (float) ConfigManagerImpl.getInstance().getConfig().functionality.inventoryHighlightingOpacity; + int dimColor = Color.ofRGBA(20 / 255F, 20 / 255F, 20 / 255F, dimOpacity).getColor(); + int borderColor = Color.ofRGBA(0x5f / 255F, 0xff / 255F, 0x3b / 255F, opacity).getColor(); + int color = Color.ofRGBA(0x5f / 255F, 0xff / 255F, 0x3b / 255F, opacity * 0x34 / 255F).getColor(); RenderSystem.disableDepthTest(); RenderSystem.colorMask(true, true, true, false); if (Minecraft.getInstance().screen instanceof AbstractContainerScreen<?> containerScreen) { int x = containerScreen.leftPos, y = containerScreen.topPos; for (Slot slot : containerScreen.getMenu().slots) { if (!slot.hasItem() || !EntryListSearchManager.INSTANCE.matches(EntryStacks.of(slot.getItem()))) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 500f); - graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, 0xdc202020, 0xdc202020); - graphics.pose().popPose(); + graphics.fillGradient(RenderType.guiOverlay(), x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, dimColor, dimColor, 0); } else { graphics.pose().pushPose(); graphics.pose().translate(0, 0, 200f); - graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, 0x345fff3b, 0x345fff3b); - - graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b); - graphics.fillGradient(x + slot.x + 16, y + slot.y - 1, x + slot.x + 16 + 1, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b); - graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x + 16, y + slot.y, 0xff5fff3b, 0xff5fff3b); - graphics.fillGradient(x + slot.x - 1, y + slot.y + 16, x + slot.x + 16, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b); + graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, color, color); + + graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x, y + slot.y + 16 + 1, borderColor, borderColor); + graphics.fillGradient(x + slot.x + 16, y + slot.y - 1, x + slot.x + 16 + 1, y + slot.y + 16 + 1, borderColor, borderColor); + graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x + 16, y + slot.y, borderColor, borderColor); + graphics.fillGradient(x + slot.x - 1, y + slot.y + 16, x + slot.x + 16, y + slot.y + 16 + 1, borderColor, borderColor); graphics.pose().popPose(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/ |
