Skip to content

Commit

Permalink
Merge branch '12.x-1.20' into 14.x-1.20.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
#	gradle/wrapper/gradle-wrapper.properties
#	runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java
  • Loading branch information
shedaniel committed Sep 24, 2024
2 parents 20317a9 + 91cc0c4 commit 106896b
Show file tree
Hide file tree
Showing 45 changed files with 2,172 additions and 1,211 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("architectury-plugin") version("3.4-SNAPSHOT")
id("dev.architectury.loom") version("1.4-SNAPSHOT") apply false
id("dev.architectury.loom") version("1.7-SNAPSHOT") apply false
id("org.cadixdev.licenser") version("0.6.1")
id("me.shedaniel.unified-publishing") version("0.1.+")
id("maven-publish")
Expand Down
4 changes: 4 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,9 +38,6 @@ public boolean isClient() {

@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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ unstable=false
supported_version=1.20.4
minecraft_version=1.20.4
platforms=fabric,forge,neoforge
forge_version=49.0.3
forge_version=49.1.10
neoforge_version=20.4.190
fabricloader_version=0.15.1
cloth_config_version=13.0.121
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
4 changes: 4 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,9 +38,6 @@ public boolean isClient() {

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ public static class Functionality {
@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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -398,14 +400,18 @@ public boolean keyReleased(int keyCode, int scanCode, int modifiers) {

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static OptionCategory make(String key) {
OptionCategory ACCESSIBILITY = make("accessibility")
.add(ACCESSIBILITY_DISPLAY)
.add(ACCESSIBILITY_WIDGETS)
.add(ACCESSIBILITY_INVENTORY_SEARCH)
.add(ACCESSIBILITY_FEATURES);
OptionCategory FILTERING = make("filtering")
.add(FILTERING_FILTERING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ static <T> OptionGroup make(String id) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ static <T> CompositeOption<T> make(String id, Function<ConfigObjectImpl, T> bind
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)
Expand Down Expand Up @@ -140,12 +149,18 @@ static <T> CompositeOption<T> make(String id, Function<ConfigObjectImpl, T> bind
.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()),
Expand Down Expand Up @@ -182,7 +197,9 @@ static <T> CompositeOption<T> make(String id, Function<ConfigObjectImpl, T> bind
.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 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Component getOption(T value) {
};
}

static <T> OptionValueEntry<T> options(T... options) {
static <T> OptionValueEntry.Selection<T> options(T... options) {
return new Selection<>() {
@Override
public List<T> getOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
}

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public boolean mouseScrolled(double mouseX, double mouseY, double amountX, doubl
if (Screen.hasControlDown()) {
ConfigObjectImpl config = ConfigManagerImpl.getInstance().getConfig();
scaleIndicator.setAs(10.0D);
if (config.setEntrySize(config.getEntrySize() + amountY * 0.075)) {
if (config.setEntrySize(config.getEntrySize() + Double.compare(amountY, 0) * 0.05)) {
ConfigManager.getInstance().saveConfig();
REIRuntime.getInstance().getOverlay().ifPresent(ScreenOverlay::queueReloadOverlay);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

package me.shedaniel.rei.impl.client.search.collapsed;

import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry;
Expand All @@ -35,9 +34,7 @@

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

public class CollapsedEntriesCache {
private static CollapsedEntriesCache instance = new CollapsedEntriesCache();
Expand Down
Loading

0 comments on commit 106896b

Please sign in to comment.