diff --git a/Common/src/main/java/mezz/jei/common/config/ClientToggleState.java b/Common/src/main/java/mezz/jei/common/config/ClientToggleState.java index 0b79c8a77..474439206 100644 --- a/Common/src/main/java/mezz/jei/common/config/ClientToggleState.java +++ b/Common/src/main/java/mezz/jei/common/config/ClientToggleState.java @@ -1,6 +1,10 @@ package mezz.jei.common.config; +import mezz.jei.core.util.WeakList; + public class ClientToggleState implements IClientToggleState { + private final WeakList editModeListeners = new WeakList<>(); + private boolean overlayEnabled = true; private boolean cheatItemsEnabled = false; private boolean editModeEnabled = false; @@ -56,5 +60,11 @@ public boolean isEditModeEnabled() { @Override public void toggleEditModeEnabled() { this.editModeEnabled = !this.editModeEnabled; + editModeListeners.forEach(IEditModeListener::onEditModeChanged); + } + + @Override + public void addEditModeToggleListener(IEditModeListener listener) { + editModeListeners.add(listener); } } diff --git a/Common/src/main/java/mezz/jei/common/config/IClientToggleState.java b/Common/src/main/java/mezz/jei/common/config/IClientToggleState.java index 6a6e3f5f8..408c225b5 100644 --- a/Common/src/main/java/mezz/jei/common/config/IClientToggleState.java +++ b/Common/src/main/java/mezz/jei/common/config/IClientToggleState.java @@ -20,4 +20,10 @@ public interface IClientToggleState { void toggleBookmarkEnabled(); void setBookmarkEnabled(boolean value); + + void addEditModeToggleListener(IEditModeListener listener); + + interface IEditModeListener { + void onEditModeChanged(); + } } diff --git a/CommonApi/src/main/java/mezz/jei/api/ingredients/IIngredientHelper.java b/CommonApi/src/main/java/mezz/jei/api/ingredients/IIngredientHelper.java index 4f6fc0347..bea740ed8 100644 --- a/CommonApi/src/main/java/mezz/jei/api/ingredients/IIngredientHelper.java +++ b/CommonApi/src/main/java/mezz/jei/api/ingredients/IIngredientHelper.java @@ -55,6 +55,16 @@ default Object getUid(V ingredient, UidContext context) { return getUniqueId(ingredient, context); } + /** + * Unique ID for use in grouping ingredients together. + * This is used for hiding groups of ingredients together at once. + * + * @since 19.13.0 + */ + default Object getGroupingUid(V ingredient) { + return getWildcardId(ingredient); + } + /** * Return true if the given ingredient can have subtypes. * For example in the vanilla game an enchanted book may have subtypes, but an apple does not. @@ -71,7 +81,10 @@ default boolean hasSubtypes(V ingredient) { * Wildcard ID for use in comparing, blacklisting, and looking up ingredients. * For an example, ItemStack's wildcardId does not include NBT. * For ingredients which do not have a wildcardId, just return the uniqueId here. + * + * @deprecated use {@link #getGroupingUid} instead */ + @Deprecated(since = "19.13.0", forRemoval = true) default String getWildcardId(V ingredient) { return getUniqueId(ingredient, UidContext.Ingredient); } diff --git a/CommonApi/src/main/java/mezz/jei/api/runtime/IEditModeConfig.java b/CommonApi/src/main/java/mezz/jei/api/runtime/IEditModeConfig.java index 95b4ce31f..0a409373b 100644 --- a/CommonApi/src/main/java/mezz/jei/api/runtime/IEditModeConfig.java +++ b/CommonApi/src/main/java/mezz/jei/api/runtime/IEditModeConfig.java @@ -70,7 +70,7 @@ enum HideMode { SINGLE, /** * Hides or shows a single item based on its Wildcard UID. - * See {@link IIngredientHelper#getWildcardId(Object)}. + * See {@link IIngredientHelper#getGroupingUid}. * * @since 11.5.0 */ diff --git a/Gui/src/main/java/mezz/jei/gui/ingredients/IngredientFilter.java b/Gui/src/main/java/mezz/jei/gui/ingredients/IngredientFilter.java index bec44d57c..5fabf4735 100644 --- a/Gui/src/main/java/mezz/jei/gui/ingredients/IngredientFilter.java +++ b/Gui/src/main/java/mezz/jei/gui/ingredients/IngredientFilter.java @@ -10,6 +10,7 @@ import mezz.jei.api.runtime.IIngredientVisibility; import mezz.jei.common.config.DebugConfig; import mezz.jei.common.config.IClientConfig; +import mezz.jei.common.config.IClientToggleState; import mezz.jei.common.config.IIngredientFilterConfig; import mezz.jei.gui.filter.IFilterTextSource; import mezz.jei.gui.overlay.IIngredientGridSource; @@ -37,7 +38,12 @@ import java.util.regex.Pattern; import java.util.stream.Stream; -public class IngredientFilter implements IIngredientGridSource, IIngredientManager.IIngredientListener { +public class IngredientFilter implements + IIngredientGridSource, + IIngredientManager.IIngredientListener, + IIngredientVisibility.IListener, + IClientToggleState.IEditModeListener +{ private static final Logger LOGGER = LogManager.getLogger(); private static final Pattern QUOTE_PATTERN = Pattern.compile("\""); private static final Pattern FILTER_SPLIT_PATTERN = Pattern.compile("(-?\".*?(?:\"|$)|\\S+)"); @@ -65,7 +71,8 @@ public IngredientFilter( List> ingredients, IModIdHelper modIdHelper, IIngredientVisibility ingredientVisibility, - IColorHelper colorHelper + IColorHelper colorHelper, + IClientToggleState clientToggleState ) { this.filterTextSource = filterTextSource; this.clientConfig = clientConfig; @@ -90,6 +97,8 @@ public IngredientFilter( ingredientListCached = null; notifyListenersOfChange(); }); + + clientToggleState.addEditModeToggleListener(this); } private static IElementSearch createElementSearch(IClientConfig clientConfig, ElementPrefixParser elementPrefixParser) { @@ -139,6 +148,11 @@ public Optional> searchForMatchingElement( .findFirst(); } + @Override + public void onEditModeChanged() { + updateHidden(); + } + public void updateHidden() { boolean changed = false; for (IListElement element : this.elementSearch.getAllIngredients()) { @@ -160,6 +174,7 @@ public boolean updateHiddenState(IListElement element) { return false; } + @Override public void onIngredientVisibilityChanged(ITypedIngredient ingredient, boolean visible) { IIngredientType ingredientType = ingredient.getType(); IIngredientHelper ingredientHelper = ingredientManager.getIngredientHelper(ingredientType); diff --git a/Gui/src/main/java/mezz/jei/gui/input/handlers/EditInputHandler.java b/Gui/src/main/java/mezz/jei/gui/input/handlers/EditInputHandler.java index 49d1625a9..10fbe8740 100644 --- a/Gui/src/main/java/mezz/jei/gui/input/handlers/EditInputHandler.java +++ b/Gui/src/main/java/mezz/jei/gui/input/handlers/EditInputHandler.java @@ -11,6 +11,7 @@ import net.minecraft.client.gui.screens.Screen; import java.util.Optional; +import java.util.Set; public class EditInputHandler implements IUserInputHandler { private final CombinedRecipeFocusSource focusSource; @@ -53,7 +54,8 @@ private Optional handle(UserInput input, IInternalKeyMappings private void execute(IClickableIngredientInternal clicked, IEditModeConfig.HideMode hideMode) { ITypedIngredient typedIngredient = clicked.getTypedIngredient(); - if (editModeConfig.isIngredientHiddenUsingConfigFile(typedIngredient)) { + Set hideModes = editModeConfig.getIngredientHiddenUsingConfigFile(typedIngredient); + if (hideModes.contains(hideMode)) { editModeConfig.showIngredientUsingConfigFile(typedIngredient, hideMode); } else { editModeConfig.hideIngredientUsingConfigFile(typedIngredient, hideMode); diff --git a/Gui/src/main/java/mezz/jei/gui/overlay/elements/ElementRenderer.java b/Gui/src/main/java/mezz/jei/gui/overlay/elements/ElementRenderer.java index 3e07c5957..44ba713d9 100644 --- a/Gui/src/main/java/mezz/jei/gui/overlay/elements/ElementRenderer.java +++ b/Gui/src/main/java/mezz/jei/gui/overlay/elements/ElementRenderer.java @@ -15,8 +15,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderType; +import java.util.Set; + public class ElementRenderer implements IElementRenderer { - private static final int BLACKLIST_COLOR = 0xFFFF0000; + private static final int BLACKLIST_COLOR = 0xDDFF0000; + private static final int WILDCARD_BLACKLIST_COLOR = 0xDDFFA500; private final IIngredientRenderer ingredientRenderer; @@ -41,15 +44,28 @@ public void render(GuiGraphics guiGraphics, IElement element, ImmutableRect2i private static void renderEditMode(GuiGraphics guiGraphics, ImmutableRect2i area, int padding, ITypedIngredient typedIngredient) { IEditModeConfig editModeConfig = Internal.getJeiRuntime().getEditModeConfig(); - if (editModeConfig.isIngredientHiddenUsingConfigFile(typedIngredient)) { - guiGraphics.fill( - RenderType.guiOverlay(), - area.getX() + padding, - area.getY() + padding, - area.getX() + 16 + padding, - area.getY() + 16 + padding, - BLACKLIST_COLOR - ); + Set hideModes = editModeConfig.getIngredientHiddenUsingConfigFile(typedIngredient); + if (!hideModes.isEmpty()) { + if (hideModes.contains(IEditModeConfig.HideMode.WILDCARD)) { + guiGraphics.fill( + RenderType.guiOverlay(), + area.getX() + padding, + area.getY() + padding, + area.getX() + 16 + padding, + area.getY() + 16 + padding, + WILDCARD_BLACKLIST_COLOR + ); + } + if (hideModes.contains(IEditModeConfig.HideMode.SINGLE)) { + guiGraphics.fill( + RenderType.guiOverlay(), + area.getX() + padding, + area.getY() + padding, + area.getX() + 16 + padding, + area.getY() + 16 + padding, + BLACKLIST_COLOR + ); + } RenderSystem.setShaderColor(1f, 1f, 1f, 1f); } } diff --git a/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java b/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java index a3a2322f4..f849e438a 100644 --- a/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java +++ b/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java @@ -129,10 +129,11 @@ public static JeiEventHandlers start(IRuntimeRegistration registration) { ingredientList, modIdHelper, ingredientVisibility, - colorHelper + colorHelper, + toggleState ); ingredientManager.registerIngredientListener(ingredientFilter); - ingredientVisibility.registerListener(ingredientFilter::onIngredientVisibilityChanged); + ingredientVisibility.registerListener(ingredientFilter); timer.stop(); IIngredientFilter ingredientFilterApi = new IngredientFilterApi(ingredientFilter, filterTextSource); diff --git a/Library/src/main/java/mezz/jei/library/config/EditModeConfig.java b/Library/src/main/java/mezz/jei/library/config/EditModeConfig.java index 87b70fdf1..1f2f94fd3 100644 --- a/Library/src/main/java/mezz/jei/library/config/EditModeConfig.java +++ b/Library/src/main/java/mezz/jei/library/config/EditModeConfig.java @@ -8,6 +8,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; import com.mojang.serialization.JsonOps; +import com.mojang.serialization.codecs.RecordCodecBuilder; import mezz.jei.api.helpers.ICodecHelper; import mezz.jei.api.ingredients.IIngredientHelper; import mezz.jei.api.ingredients.IIngredientType; @@ -16,21 +17,22 @@ import mezz.jei.api.runtime.IEditModeConfig; import mezz.jei.api.runtime.IIngredientManager; import mezz.jei.common.codecs.EnumCodec; -import mezz.jei.core.util.WeakList; +import mezz.jei.library.ingredients.IngredientVisibility; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.RegistryOps; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; +import java.lang.ref.WeakReference; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; public class EditModeConfig implements IEditModeConfig { private static final Logger LOGGER = LogManager.getLogger(); @@ -38,7 +40,7 @@ public class EditModeConfig implements IEditModeConfig { private final Map>> blacklist = new LinkedHashMap<>(); private final ISerializer serializer; private final IIngredientManager ingredientManager; - private final WeakList listeners = new WeakList<>(); + private WeakReference ingredientVisibilityRef = new WeakReference<>(null); public EditModeConfig(ISerializer serializer, IIngredientManager ingredientManager) { this.ingredientManager = ingredientManager; @@ -107,9 +109,23 @@ public boolean isIngredientOnConfigBlacklist(ITypedIngredient typedIngred } private Set getIngredientOnConfigBlacklist(ITypedIngredient ingredient, IIngredientHelper ingredientHelper) { - return Arrays.stream(HideMode.values()) - .filter(hideMode -> isIngredientOnConfigBlacklist(ingredient, hideMode, ingredientHelper)) - .collect(Collectors.toUnmodifiableSet()); + final Object singleUid = getIngredientUid(ingredient, HideMode.SINGLE, ingredientHelper); + final Object wildcardUid = getIngredientUid(ingredient, HideMode.WILDCARD, ingredientHelper); + if (singleUid.equals(wildcardUid)) { + if (blacklist.containsKey(singleUid)) { + return Set.of(HideMode.SINGLE); + } + return Set.of(); + } + + Set set = new HashSet<>(); + if (blacklist.containsKey(singleUid)) { + set.add(HideMode.SINGLE); + } + if (blacklist.containsKey(wildcardUid)) { + set.add(HideMode.WILDCARD); + } + return Collections.unmodifiableSet(set); } public boolean isIngredientOnConfigBlacklist(ITypedIngredient typedIngredient, HideMode blacklistType, IIngredientHelper ingredientHelper) { @@ -121,7 +137,7 @@ private static Object getIngredientUid(ITypedIngredient typedIngredient, final V ingredient = typedIngredient.getIngredient(); return switch (blacklistType) { case SINGLE -> ingredientHelper.getUid(ingredient, UidContext.Ingredient); - case WILDCARD -> ingredientHelper.getWildcardId(ingredient); + case WILDCARD -> ingredientHelper.getGroupingUid(ingredient); }; } @@ -153,8 +169,8 @@ public void showIngredientUsingConfigFile(ITypedIngredient ingredient, Hi removeIngredientFromConfigBlacklist(ingredient, hideMode, ingredientHelper); } - public void registerListener(IListener listener) { - this.listeners.add(listener); + public void registerListener(IngredientVisibility ingredientVisibility) { + this.ingredientVisibilityRef = new WeakReference<>(ingredientVisibility); } public interface ISerializer { @@ -170,12 +186,17 @@ public static class FileSerializer implements ISerializer { public FileSerializer(Path path, RegistryAccess registryAccess, ICodecHelper codecHelper) { this.path = path; - this.listCodec = Codec.list( - Codec.pair( - EnumCodec.create(HideMode.class, HideMode::valueOf), + Codec>> elementCodec = RecordCodecBuilder.create(builder -> { + return builder.group( + EnumCodec.create(HideMode.class, HideMode::valueOf) + .fieldOf("hide_mode") + .forGetter(Pair::getFirst), codecHelper.getTypedIngredientCodec().codec() - ) - ); + .fieldOf("ingredient") + .forGetter(Pair::getSecond) + ).apply(builder, Pair::new); + }); + this.listCodec = Codec.list(elementCodec); this.registryOps = registryAccess.createSerializationContext(JsonOps.COMPRESSED); } @@ -233,11 +254,10 @@ public void load(EditModeConfig config) { } } - public interface IListener { - void onIngredientVisibilityChanged(ITypedIngredient ingredient, boolean visible); - } - private void notifyListenersOfVisibilityChange(ITypedIngredient ingredient, boolean visible) { - listeners.forEach(listener -> listener.onIngredientVisibilityChanged(ingredient, visible)); + IngredientVisibility ingredientVisibility = this.ingredientVisibilityRef.get(); + if (ingredientVisibility != null) { + ingredientVisibility.notifyListeners(ingredient, visible); + } } } diff --git a/Library/src/main/java/mezz/jei/library/ingredients/IngredientBlacklistInternal.java b/Library/src/main/java/mezz/jei/library/ingredients/IngredientBlacklistInternal.java index 38aa5700a..a87410473 100644 --- a/Library/src/main/java/mezz/jei/library/ingredients/IngredientBlacklistInternal.java +++ b/Library/src/main/java/mezz/jei/library/ingredients/IngredientBlacklistInternal.java @@ -4,19 +4,15 @@ import mezz.jei.api.ingredients.ITypedIngredient; import mezz.jei.api.ingredients.subtypes.UidContext; import mezz.jei.api.runtime.IIngredientManager; -import mezz.jei.core.util.WeakList; +import java.lang.ref.WeakReference; import java.util.Collection; import java.util.HashSet; import java.util.Set; public class IngredientBlacklistInternal implements IIngredientManager.IIngredientListener { - public interface IListener { - void onIngredientVisibilityChanged(ITypedIngredient ingredient, boolean visible); - } - private final Set uidBlacklist = new HashSet<>(); - private final WeakList listeners = new WeakList<>(); + private WeakReference ingredientVisibilityRef = new WeakReference<>(null); public void addIngredientToBlacklist(ITypedIngredient typedIngredient, IIngredientHelper ingredientHelper) { V ingredient = typedIngredient.getIngredient(); @@ -37,7 +33,7 @@ public void removeIngredientFromBlacklist(ITypedIngredient typedIngredien public boolean isIngredientBlacklistedByApi(ITypedIngredient typedIngredient, IIngredientHelper ingredientHelper) { V ingredient = typedIngredient.getIngredient(); Object uid = ingredientHelper.getUid(ingredient, UidContext.Ingredient); - Object uidWild = ingredientHelper.getWildcardId(ingredient); + Object uidWild = ingredientHelper.getGroupingUid(ingredient); if (uid.equals(uidWild)) { return uidBlacklist.contains(uid); @@ -45,8 +41,8 @@ public boolean isIngredientBlacklistedByApi(ITypedIngredient typedIngredi return uidBlacklist.contains(uid) || uidBlacklist.contains(uidWild); } - public void registerListener(IListener listener) { - this.listeners.add(listener); + public void registerListener(IngredientVisibility ingredientVisibility) { + this.ingredientVisibilityRef = new WeakReference<>(ingredientVisibility); } @Override @@ -64,6 +60,9 @@ public void onIngredientsRemoved(IIngredientHelper ingredientHelper, Coll } private void notifyListenersOfVisibilityChange(ITypedIngredient ingredient, boolean visible) { - listeners.forEach(listener -> listener.onIngredientVisibilityChanged(ingredient, visible)); + IngredientVisibility ingredientVisibility = ingredientVisibilityRef.get(); + if (ingredientVisibility != null) { + ingredientVisibility.notifyListeners(ingredient, visible); + } } } diff --git a/Library/src/main/java/mezz/jei/library/ingredients/IngredientManager.java b/Library/src/main/java/mezz/jei/library/ingredients/IngredientManager.java index 6c43767c4..cde058bd4 100644 --- a/Library/src/main/java/mezz/jei/library/ingredients/IngredientManager.java +++ b/Library/src/main/java/mezz/jei/library/ingredients/IngredientManager.java @@ -185,6 +185,7 @@ public ITypedIngredient normalizeTypedIngredient(ITypedIngredient type return TypedIngredient.createUnvalidated(type, normalized); } + @SuppressWarnings("removal") @Override @Deprecated public Optional getIngredientByUid(IIngredientType ingredientType, String ingredientUuid) { diff --git a/Library/src/main/java/mezz/jei/library/ingredients/IngredientVisibility.java b/Library/src/main/java/mezz/jei/library/ingredients/IngredientVisibility.java index 298ec86c3..cfe9346af 100644 --- a/Library/src/main/java/mezz/jei/library/ingredients/IngredientVisibility.java +++ b/Library/src/main/java/mezz/jei/library/ingredients/IngredientVisibility.java @@ -3,7 +3,6 @@ import mezz.jei.api.ingredients.IIngredientHelper; import mezz.jei.api.ingredients.IIngredientType; import mezz.jei.api.ingredients.ITypedIngredient; -import mezz.jei.api.runtime.IEditModeConfig; import mezz.jei.api.runtime.IIngredientManager; import mezz.jei.api.runtime.IIngredientVisibility; import mezz.jei.common.config.IClientToggleState; @@ -13,7 +12,7 @@ public class IngredientVisibility implements IIngredientVisibility { private final IngredientBlacklistInternal blacklist; private final IClientToggleState toggleState; - private final IEditModeConfig editModeConfig; + private final EditModeConfig editModeConfig; private final IIngredientManager ingredientManager; private final WeakList listeners = new WeakList<>(); @@ -28,8 +27,8 @@ public IngredientVisibility( this.editModeConfig = editModeConfig; this.ingredientManager = ingredientManager; - blacklist.registerListener(this::notifyListenersOfVisibilityChange); - editModeConfig.registerListener(this::notifyListenersOfVisibilityChange); + editModeConfig.registerListener(this); + blacklist.registerListener(this); } @Override @@ -62,7 +61,7 @@ public void registerListener(IListener listener) { this.listeners.add(listener); } - private void notifyListenersOfVisibilityChange(ITypedIngredient ingredient, boolean visible) { + public void notifyListeners(ITypedIngredient ingredient, boolean visible) { listeners.forEach(listener -> listener.onIngredientVisibilityChanged(ingredient, visible)); } } diff --git a/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/DebugIngredientHelper.java b/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/DebugIngredientHelper.java index 9f64a0909..b7f76ce8e 100644 --- a/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/DebugIngredientHelper.java +++ b/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/DebugIngredientHelper.java @@ -29,11 +29,17 @@ public Object getUid(DebugIngredient ingredient, UidContext context) { return ingredient.number(); } + @SuppressWarnings("removal") @Override public String getWildcardId(DebugIngredient ingredient) { return "JEI_debug"; } + @Override + public Object getGroupingUid(DebugIngredient ingredient) { + return DebugIngredient.class; + } + @Override public ResourceLocation getResourceLocation(DebugIngredient ingredient) { return ResourceLocation.fromNamespaceAndPath(ModIds.JEI_ID, "debug_" + ingredient.number()); diff --git a/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/ErrorIngredientHelper.java b/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/ErrorIngredientHelper.java index 804d0519f..66e134949 100644 --- a/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/ErrorIngredientHelper.java +++ b/Library/src/main/java/mezz/jei/library/plugins/debug/ingredients/ErrorIngredientHelper.java @@ -36,6 +36,11 @@ public String getWildcardId(ErrorIngredient ingredient) { return "JEI_error"; } + @Override + public Object getGroupingUid(ErrorIngredient ingredient) { + return IIngredientHelper.super.getGroupingUid(ingredient); + } + @Override public ResourceLocation getResourceLocation(ErrorIngredient ingredient) { return ResourceLocation.fromNamespaceAndPath(ModIds.JEI_ID, "error_" + ingredient.crashType().toString().toLowerCase(Locale.ROOT)); diff --git a/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java b/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java index 380a0b6e7..9f3095ba7 100644 --- a/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java +++ b/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java @@ -74,12 +74,18 @@ public Object getUid(ItemStack ingredient, UidContext context) { return stackHelper.getUidForStack(ingredient, context); } + @Override + public Object getGroupingUid(ItemStack ingredient) { + return ingredient.getItem(); + } + @Override public boolean hasSubtypes(ItemStack ingredient) { ErrorUtil.checkNotNull(ingredient, "ingredient"); return stackHelper.hasSubtypes(ingredient); } + @SuppressWarnings("removal") @Override public String getWildcardId(ItemStack ingredient) { ErrorUtil.checkNotEmpty(ingredient); diff --git a/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/fluid/FluidIngredientHelper.java b/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/fluid/FluidIngredientHelper.java index bd04de9cf..d974c76cb 100644 --- a/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/fluid/FluidIngredientHelper.java +++ b/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/fluid/FluidIngredientHelper.java @@ -75,6 +75,12 @@ public String getUniqueId(T ingredient, UidContext context) { return result.toString(); } + @Override + public Object getGroupingUid(T ingredient) { + return fluidType.getBase(ingredient); + } + + @SuppressWarnings("removal") @Override public String getWildcardId(T ingredient) { Fluid fluid = fluidType.getBase(ingredient); diff --git a/NeoForge/src/test/java/mezz/jei/test/IngredientFilterTest.java b/NeoForge/src/test/java/mezz/jei/test/IngredientFilterTest.java index 920e666db..965deef43 100644 --- a/NeoForge/src/test/java/mezz/jei/test/IngredientFilterTest.java +++ b/NeoForge/src/test/java/mezz/jei/test/IngredientFilterTest.java @@ -98,7 +98,7 @@ public void setup() { this.ingredientManager.registerIngredientListener(blacklist); this.ingredientManager.registerIngredientListener(ingredientFilter); - this.ingredientVisibility.registerListener(this.ingredientFilter::onIngredientVisibilityChanged); + this.ingredientVisibility.registerListener(this.ingredientFilter); } @Test diff --git a/NeoForge/src/test/java/mezz/jei/test/lib/TestIngredientHelper.java b/NeoForge/src/test/java/mezz/jei/test/lib/TestIngredientHelper.java index 9caa98bc8..e64c14de4 100644 --- a/NeoForge/src/test/java/mezz/jei/test/lib/TestIngredientHelper.java +++ b/NeoForge/src/test/java/mezz/jei/test/lib/TestIngredientHelper.java @@ -30,11 +30,17 @@ public String getUniqueId(TestIngredient ingredient, UidContext context) { return "Test Ingredient Unique Id " + ingredient; } + @SuppressWarnings("removal") @Override public String getWildcardId(TestIngredient ingredient) { return "Test Ingredient Unique Id"; } + @Override + public Object getGroupingUid(TestIngredient ingredient) { + return TestIngredient.class; + } + @Override public Iterable getColors(TestIngredient ingredient) { return List.of(0xFF000000); diff --git a/gradle.properties b/gradle.properties index b58314db1..41c1c7b21 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.daemon=true # This setting speeds up running single tasks from subprojects by only configuring what's needed. # see https://docs.gradle.org/current/userguide/multi_project_configuration_and_execution.html # Disabled because this breaks ForgeGradle tasks -#org.gradle.configureondemand=true +org.gradle.configureondemand=true org.gradle.caching=true # JEI @@ -60,4 +60,4 @@ curseHomepageUrl=https://www.curseforge.com/minecraft/mc-mods/jei jUnitVersion=5.8.2 # Version -specificationVersion=19.12.0 +specificationVersion=19.13.0