diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf9ead..ababb1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning]. +## Unreleased + +### Fixed +- fixed automatic hiding of stone strata variants (bug introduced in 0.9.0) +- fixed a bug where stone stratas were not correctly identified (Fabric only) + ## [0.9.1] - 2024-03-17 ### Added diff --git a/Common/src/main/java/com/almostreliable/unified/api/StoneStrataHandler.java b/Common/src/main/java/com/almostreliable/unified/api/StoneStrataHandler.java index 8d7df6a..eeab9bb 100644 --- a/Common/src/main/java/com/almostreliable/unified/api/StoneStrataHandler.java +++ b/Common/src/main/java/com/almostreliable/unified/api/StoneStrataHandler.java @@ -45,7 +45,7 @@ public final class StoneStrataHandler { var stoneStrataTagMap = tagMap.filtered(stoneStrataTags::contains, item -> true); Pattern tagMatcher = Pattern.compile(switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) { case FORGE -> "forge:ores/.+"; - case FABRIC -> "(c:ores/.+|c:.+_ores)"; + case FABRIC -> "(c:ores/.+|(minecraft|c):.+_ores)"; }); return new StoneStrataHandler(stoneStrataIds, tagMatcher, stoneStrataTagMap); } diff --git a/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java b/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java index c36e7fd..84c10e5 100644 --- a/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java +++ b/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java @@ -38,25 +38,32 @@ public final class HideHelper { var itemsByTag = tagMap.getEntriesByTag(unifyTag); if (Utils.allSameNamespace(itemsByTag)) continue; - ResourceLocation preferredItem = repMap.getPreferredItemForTag(unifyTag, $ -> true); - if (preferredItem == null) continue; + // it's not enough to exclude the preferred item from hiding because it would hide stone stratas + Set replacements = new HashSet<>(); + for (ResourceLocation item : itemsByTag) { + ResourceLocation replacement = repMap.getReplacementForItem(item); + replacements.add(replacement == null ? item : replacement); + } - Set itemsToHide = getItemsToHide(unifyTag, itemsByTag, preferredItem); - if (itemsToHide == null) continue; - hidingMap.putAll(unifyTag, itemsToHide); + Set itemsToHide = getItemsToHide(unifyTag, itemsByTag, replacements); + if (itemsToHide != null) { + hidingMap.putAll(unifyTag, itemsToHide); + } - Set refItemsToHide = getRefItemsToHide(unifyTag, ownerships, preferredItem); - hidingMap.putAll(unifyTag, refItemsToHide); + Set refItemsToHide = getRefItemsToHide(unifyTag, ownerships, replacements); + if (!refItemsToHide.isEmpty()) { + hidingMap.putAll(unifyTag, refItemsToHide); + } } return hidingMap; } @Nullable - private static Set getItemsToHide(UnifyTag unifyTag, Set itemsByTag, ResourceLocation preferredItem) { + private static Set getItemsToHide(UnifyTag unifyTag, Set itemsByTag, Set replacements) { Set itemsToHide = new HashSet<>(); for (ResourceLocation item : itemsByTag) { - if (!item.equals(preferredItem)) { + if (!replacements.contains(item)) { itemsToHide.add(item); } } @@ -73,7 +80,7 @@ public final class HideHelper { return itemsToHide; } - private static Set getRefItemsToHide(UnifyTag unifyTag, TagOwnerships ownerships, ResourceLocation preferredItem) { + private static Set getRefItemsToHide(UnifyTag unifyTag, TagOwnerships ownerships, Set replacements) { var refTags = ownerships.getRefsByOwner(unifyTag); Set refItemsToHide = new HashSet<>(); @@ -82,7 +89,7 @@ public final class HideHelper { BuiltInRegistries.ITEM.getTagOrEmpty(asTagKey).forEach(holder -> { ResourceLocation item = BuiltInRegistries.ITEM.getKey(holder.value()); - if (item.equals(preferredItem)) return; + if (replacements.contains(item)) return; refItemsToHide.add(item); }); diff --git a/Common/src/main/java/com/almostreliable/unified/config/Defaults.java b/Common/src/main/java/com/almostreliable/unified/config/Defaults.java index 18483a2..ca2338c 100644 --- a/Common/src/main/java/com/almostreliable/unified/config/Defaults.java +++ b/Common/src/main/java/com/almostreliable/unified/config/Defaults.java @@ -130,9 +130,7 @@ public final class Defaults { } public static List getIgnoredRecipeTypes(AlmostUnifiedPlatform.Platform platform) { - return switch (platform) { - default -> List.of("cucumber:shaped_tag"); - }; + return List.of("cucumber:shaped_tag"); } public static JsonCompare.CompareSettings getDefaultDuplicateRules(AlmostUnifiedPlatform.Platform platform) {