diff --git a/CHANGELOG.md b/CHANGELOG.md index c4dc024..a82fde6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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 +- updated to JEI 10 as it's no longer alpha + - minimum version 10.2.1.278 + - JEI 9 is not supported anymore since it's not possible with some internals we use +- added config option to completely ignore items from unification and hiding +- improved stone strata detection by making use of `forge:ores_in_ground` tag + ## [0.2.1] - 2022-10-28 ### Added diff --git a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java index 4af6839..bfd5135 100644 --- a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java +++ b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java @@ -1,8 +1,12 @@ package com.almostreliable.unified; import com.almostreliable.unified.recipe.unifier.RecipeHandlerFactory; +import com.almostreliable.unified.utils.UnifyTag; +import net.minecraft.world.item.Item; import java.nio.file.Path; +import java.util.List; +import java.util.Set; public interface AlmostUnifiedPlatform { @@ -37,4 +41,6 @@ public interface AlmostUnifiedPlatform { Path getLogPath(); void bindRecipeHandlers(RecipeHandlerFactory factory); + + Set> getStoneStrataTags(List stoneStrataIds); } diff --git a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedRuntime.java b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedRuntime.java index 8602896..be37a58 100644 --- a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedRuntime.java +++ b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedRuntime.java @@ -1,5 +1,6 @@ package com.almostreliable.unified; +import com.almostreliable.unified.api.StoneStrataHandler; import com.almostreliable.unified.config.Config; import com.almostreliable.unified.config.DebugConfig; import com.almostreliable.unified.config.DuplicationConfig; @@ -24,7 +25,7 @@ import java.util.Objects; public final class AlmostUnifiedRuntime { private final RecipeHandlerFactory recipeHandlerFactory; - private final TagMap tagMap; + private final TagMap filteredTagMap; private final DuplicationConfig dupConfig; private final UnifyConfig unifyConfig; private final DebugConfig debugConfig; @@ -32,11 +33,15 @@ public final class AlmostUnifiedRuntime { private AlmostUnifiedRuntime(RecipeHandlerFactory recipeHandlerFactory, TagMap tagMap, DuplicationConfig dupConfig, UnifyConfig unifyConfig, DebugConfig debugConfig) { this.recipeHandlerFactory = recipeHandlerFactory; - this.tagMap = tagMap; this.dupConfig = dupConfig; this.unifyConfig = unifyConfig; this.debugConfig = debugConfig; - this.replacementMap = new ReplacementMap(this.tagMap, this.unifyConfig); + List> allowedTags = unifyConfig.bakeTags(); + this.filteredTagMap = tagMap.filtered(allowedTags::contains, unifyConfig::includeItem); + StoneStrataHandler stoneStrataHandler = StoneStrataHandler.create(unifyConfig.getStoneStrata(), + AlmostUnifiedPlatform.INSTANCE.getStoneStrataTags(unifyConfig.getStoneStrata()), + tagMap); + this.replacementMap = new ReplacementMap(filteredTagMap, stoneStrataHandler, unifyConfig); } public static AlmostUnifiedRuntime create(TagManager tagManager) { @@ -50,15 +55,22 @@ public final class AlmostUnifiedRuntime { RecipeHandlerFactory factory = new RecipeHandlerFactory(); AlmostUnifiedPlatform.INSTANCE.bindRecipeHandlers(factory); - List> allowedTags = unifyConfig.bakeTags(); - TagMap tagMap = TagMap.create(tagManager, allowedTags::contains); - + TagMap tagMap = TagMap.create(tagManager); return new AlmostUnifiedRuntime(factory, tagMap, dupConfig, unifyConfig, debugConfig); } + private static void createGitIgnoreIfNotExists() { + Path path = AlmostUnifiedPlatform.INSTANCE.getConfigPath(); + if (!(Files.exists(path) && Files.isDirectory(path))) { + FileUtils.write(AlmostUnifiedPlatform.INSTANCE.getConfigPath(), + ".gitignore", + sb -> sb.append(DebugConfig.NAME).append(".json").append("\n")); + } + } + public void run(Map recipes, boolean skipClientTracking) { debugConfig.logRecipes(recipes, "recipes_before_unification.txt"); - debugConfig.logUnifyTagDump(tagMap); + debugConfig.logUnifyTagDump(filteredTagMap); long startTime = System.currentTimeMillis(); RecipeTransformer.Result result = new RecipeTransformer(recipeHandlerFactory, @@ -71,20 +83,11 @@ public final class AlmostUnifiedRuntime { debugConfig.logRecipes(recipes, "recipes_after_unification.txt"); } - public TagMap getTagMap() { - return tagMap; + public TagMap getFilteredTagMap() { + return filteredTagMap; } public ReplacementMap getReplacementMap() { return replacementMap; } - - private static void createGitIgnoreIfNotExists() { - Path path = AlmostUnifiedPlatform.INSTANCE.getConfigPath(); - if (!(Files.exists(path) && Files.isDirectory(path))) { - FileUtils.write(AlmostUnifiedPlatform.INSTANCE.getConfigPath(), - ".gitignore", - sb -> sb.append(DebugConfig.NAME).append(".json").append("\n")); - } - } } diff --git a/Common/src/main/java/com/almostreliable/unified/api/StoneStrataHandler.java b/Common/src/main/java/com/almostreliable/unified/api/StoneStrataHandler.java new file mode 100644 index 0000000..5556d8e --- /dev/null +++ b/Common/src/main/java/com/almostreliable/unified/api/StoneStrataHandler.java @@ -0,0 +1,69 @@ +package com.almostreliable.unified.api; + +import com.almostreliable.unified.AlmostUnifiedPlatform; +import com.almostreliable.unified.utils.TagMap; +import com.almostreliable.unified.utils.UnifyTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; + +import java.util.List; +import java.util.Set; +import java.util.regex.Pattern; + +public class StoneStrataHandler { + + private final List stoneStrata; + private final Pattern tagMatcher; + private final TagMap stoneStrataTagMap; + + private StoneStrataHandler(List stoneStrata, Pattern tagMatcher, TagMap stoneStrataTagMap) { + this.stoneStrata = stoneStrata; + this.tagMatcher = tagMatcher; + this.stoneStrataTagMap = stoneStrataTagMap; + } + + public static StoneStrataHandler create(List stoneStrataIds, Set> stoneStrataTags, TagMap tagMap) { + TagMap stoneStrataTagMap = tagMap.filtered(stoneStrataTags::contains, item -> true); + Pattern tagMatcher = switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) { + case FORGE -> Pattern.compile("forge:ores/.+"); + case FABRIC -> Pattern.compile("(c:ores/.+|c:.+_ore)"); + }; + return new StoneStrataHandler(stoneStrataIds, tagMatcher, stoneStrataTagMap); + } + + /** + * Returns the stone strata from given item. Method works on the requirement that it's an item which has a stone strata. + * Use {@link #isStoneStrataTag(UnifyTag)} to fill this requirement. + * + * @param item The item to get the stone strata from. + * @return The stone strata of the item. Returning empty string means clean-stone strata. + */ + public String getStoneStrata(ResourceLocation item) { + String strata = stoneStrataTagMap + .getTags(item) + .stream() + .findFirst() + .map(UnifyTag::location) + .map(ResourceLocation::toString) + .map(s -> { + int i = s.lastIndexOf('/'); + return i == -1 ? null : s.substring(i + 1); + }) + .orElse(null); + if (strata != null) { + return strata; + } + + for (String stone : stoneStrata) { + if (item.getPath().contains(stone + "_")) { + return stone; + } + } + + return ""; + } + + public boolean isStoneStrataTag(UnifyTag tag) { + return tagMatcher.matcher(tag.location().toString()).matches(); + } +} diff --git a/Common/src/main/java/com/almostreliable/unified/compat/AlmostKube.java b/Common/src/main/java/com/almostreliable/unified/compat/AlmostKube.java index 8f7d4ef..71fb0ea 100644 --- a/Common/src/main/java/com/almostreliable/unified/compat/AlmostKube.java +++ b/Common/src/main/java/com/almostreliable/unified/compat/AlmostKube.java @@ -56,7 +56,7 @@ public class AlmostKube extends KubeJSPlugin { public static Set getTags() { return AlmostUnified .getRuntime() - .getTagMap() + .getFilteredTagMap() .getTags() .stream() .map(tag -> tag.location().toString()) @@ -67,7 +67,7 @@ public class AlmostKube extends KubeJSPlugin { UnifyTag asUnifyTag = UnifyTag.item(tag); return AlmostUnified .getRuntime() - .getTagMap() + .getFilteredTagMap() .getItems(asUnifyTag) .stream() .map(ResourceLocation::toString) 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 47f8eaf..5155e92 100644 --- a/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java +++ b/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java @@ -1,6 +1,8 @@ package com.almostreliable.unified.compat; import com.almostreliable.unified.AlmostUnified; +import com.almostreliable.unified.AlmostUnifiedPlatform; +import com.almostreliable.unified.api.StoneStrataHandler; import com.almostreliable.unified.config.UnifyConfig; import com.almostreliable.unified.utils.ReplacementMap; import com.almostreliable.unified.utils.TagMap; @@ -17,11 +19,12 @@ public class HideHelper { public static Collection createHidingList(UnifyConfig config) { List> unifyTags = config.bakeTags(); - TagMap tagMap = TagMap.create(unifyTags); - ReplacementMap repMap = new ReplacementMap(tagMap, config); + TagMap filteredTagMap = TagMap.create(unifyTags).filtered($ -> true, config::includeItem); + StoneStrataHandler stoneStrataHandler = getStoneStrataHandler(config); + ReplacementMap repMap = new ReplacementMap(filteredTagMap, stoneStrataHandler, config); - return tagMap.getTags().stream().map(unifyTag -> { - Collection itemsByTag = tagMap.getItems(unifyTag); + return filteredTagMap.getTags().stream().map(unifyTag -> { + Collection itemsByTag = filteredTagMap.getItems(unifyTag); if (itemsByTag.size() <= 1) return new ArrayList(); Set replacements = itemsByTag @@ -42,4 +45,10 @@ public class HideHelper { return toHide.stream().flatMap(rl -> Registry.ITEM.getOptional(rl).stream()).map(ItemStack::new).toList(); }).flatMap(Collection::stream).toList(); } + + private static StoneStrataHandler getStoneStrataHandler(UnifyConfig config) { + Set> stoneStrataTags = AlmostUnifiedPlatform.INSTANCE.getStoneStrataTags(config.getStoneStrata()); + TagMap stoneStrataTagMap = TagMap.create(stoneStrataTags); + return StoneStrataHandler.create(config.getStoneStrata(), stoneStrataTags, stoneStrataTagMap); + } } diff --git a/Common/src/main/java/com/almostreliable/unified/config/UnifyConfig.java b/Common/src/main/java/com/almostreliable/unified/config/UnifyConfig.java index 823392f..f4804ca 100644 --- a/Common/src/main/java/com/almostreliable/unified/config/UnifyConfig.java +++ b/Common/src/main/java/com/almostreliable/unified/config/UnifyConfig.java @@ -22,17 +22,19 @@ public class UnifyConfig extends Config { private final List materials; private final Map priorityOverrides; private final Set> ignoredTags; + private final Set ignoredItems; private final Set ignoredRecipeTypes; private final Set ignoredRecipes; private final boolean hideJeiRei; - public UnifyConfig(List modPriorities, List stoneStrata, List unbakedTags, List materials, Map priorityOverrides, Set> ignoredTags, Set ignoredRecipeTypes, Set ignoredRecipes, boolean hideJeiRei) { + public UnifyConfig(List modPriorities, List stoneStrata, List unbakedTags, List materials, Map priorityOverrides, Set> ignoredTags, Set ignoredItems, Set ignoredRecipeTypes, Set ignoredRecipes, boolean hideJeiRei) { this.modPriorities = modPriorities; this.stoneStrata = stoneStrata; this.unbakedTags = unbakedTags; this.materials = materials; this.priorityOverrides = priorityOverrides; this.ignoredTags = ignoredTags; + this.ignoredItems = ignoredItems; this.ignoredRecipeTypes = ignoredRecipeTypes; this.ignoredRecipes = ignoredRecipes; this.hideJeiRei = hideJeiRei; @@ -71,6 +73,10 @@ public class UnifyConfig extends Config { return Collections.unmodifiableMap(priorityOverrides); } + public boolean includeItem(ResourceLocation item) { + return ignoredItems.stream().noneMatch(pattern -> pattern.matcher(item.toString()).matches()); + } + public boolean includeRecipe(ResourceLocation recipe) { return ignoredRecipes.stream().noneMatch(pattern -> pattern.matcher(recipe.toString()).matches()); } @@ -91,6 +97,7 @@ public class UnifyConfig extends Config { public static final String MATERIALS = "materials"; public static final String PRIORITY_OVERRIDES = "priorityOverrides"; public static final String IGNORED_TAGS = "ignoredTags"; + public static final String IGNORED_ITEMS = "ignoredItems"; public static final String IGNORED_RECIPE_TYPES = "ignoredRecipeTypes"; public static final String IGNORED_RECIPES = "ignoredRecipes"; public static final String HIDE_JEI_REI = "itemsHidingJeiRei"; @@ -118,6 +125,7 @@ public class UnifyConfig extends Config { .stream() .map(s -> UnifyTag.item(new ResourceLocation(s))) .collect(Collectors.toSet()), new HashSet<>()); + Set ignoredItems = deserializePatterns(json, IGNORED_ITEMS, List.of()); Set ignoredRecipeTypes = deserializePatterns(json, IGNORED_RECIPE_TYPES, Defaults.getIgnoredRecipeTypes(AlmostUnifiedPlatform.INSTANCE.getPlatform())); @@ -131,6 +139,7 @@ public class UnifyConfig extends Config { materials, priorityOverrides, ignoredTags, + ignoredItems, ignoredRecipeTypes, ignoredRecipes, hideJeiRei @@ -155,6 +164,7 @@ public class UnifyConfig extends Config { .map(UnifyTag::location) .map(ResourceLocation::toString) .toList())); + serializePatterns(json, IGNORED_ITEMS, config.ignoredItems); serializePatterns(json, IGNORED_RECIPE_TYPES, config.ignoredRecipeTypes); serializePatterns(json, IGNORED_RECIPES, config.ignoredRecipes); json.add(HIDE_JEI_REI, new JsonPrimitive(config.hideJeiRei)); diff --git a/Common/src/main/java/com/almostreliable/unified/utils/ReplacementMap.java b/Common/src/main/java/com/almostreliable/unified/utils/ReplacementMap.java index 6c3f631..fa63d14 100644 --- a/Common/src/main/java/com/almostreliable/unified/utils/ReplacementMap.java +++ b/Common/src/main/java/com/almostreliable/unified/utils/ReplacementMap.java @@ -1,7 +1,7 @@ package com.almostreliable.unified.utils; import com.almostreliable.unified.AlmostUnified; -import com.almostreliable.unified.AlmostUnifiedPlatform; +import com.almostreliable.unified.api.StoneStrataHandler; import com.almostreliable.unified.config.UnifyConfig; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; @@ -11,42 +11,17 @@ import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.function.Predicate; -import java.util.regex.Pattern; public class ReplacementMap { - private static final Pattern FABRIC_STRATA_PATTERN = Pattern.compile("(c:ores/.+|c:.+_ore)"); private final TagMap tagMap; private final UnifyConfig unifyConfig; + private final StoneStrataHandler stoneStrataHandler; - public ReplacementMap(TagMap tagMap, UnifyConfig unifyConfig) { + public ReplacementMap(TagMap tagMap, StoneStrataHandler stoneStrataHandler, UnifyConfig unifyConfig) { this.tagMap = tagMap; this.unifyConfig = unifyConfig; - } - - /** - * Returns the stone strata from given item. Method works on the requirement that it's an item which has a stone strata. - * Use {@link #isStoneStrataTag(UnifyTag)} to fill this requirement. - * - * @param item The item to get the stone strata from. - * @return The stone strata of the item. Returning empty string means clean-stone strata. - */ - private String getStoneStrata(ResourceLocation item) { - for (String stone : unifyConfig.getStoneStrata()) { - if (item.getPath().contains(stone + "_")) { - return stone; - } - } - - return ""; - } - - private boolean isStoneStrataTag(UnifyTag tag) { - String tagString = tag.location().toString(); - return switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) { - case FORGE -> tagString.startsWith("forge:ores/"); - case FABRIC -> FABRIC_STRATA_PATTERN.matcher(tagString).matches(); - }; + this.stoneStrataHandler = stoneStrataHandler; } @Nullable @@ -74,9 +49,9 @@ public class ReplacementMap { return null; } - if (isStoneStrataTag(t)) { - String stone = getStoneStrata(item); - return getPreferredItemForTag(t, i -> stone.equals(getStoneStrata(i))); + if (stoneStrataHandler.isStoneStrataTag(t)) { + String stone = stoneStrataHandler.getStoneStrata(item); + return getPreferredItemForTag(t, i -> stone.equals(stoneStrataHandler.getStoneStrata(i))); } return getPreferredItemForTag(t, i -> true); diff --git a/Common/src/main/java/com/almostreliable/unified/utils/TagMap.java b/Common/src/main/java/com/almostreliable/unified/utils/TagMap.java index 8312eaf..7dd4f4c 100644 --- a/Common/src/main/java/com/almostreliable/unified/utils/TagMap.java +++ b/Common/src/main/java/com/almostreliable/unified/utils/TagMap.java @@ -31,13 +31,18 @@ public class TagMap { return tagMap; } - public static TagMap create(TagManager tagManager, Predicate> filter) { + /** + * Creates a {@link TagMap} from a vanilla {@link TagManager}. + * + * @param tagManager The vanilla tag manager. + * @return A new {@link TagMap}. + */ + public static TagMap create(TagManager tagManager) { Objects.requireNonNull(tagManager, "Requires a non-null tag manager"); - var tags = tagManager .getResult() .stream() - .filter(result -> result.key().equals(Registry.ITEM_REGISTRY)) + .filter(result -> result.key() == Registry.ITEM_REGISTRY) .findFirst() .map(TagManager.LoadResult::tags) .orElseThrow(() -> new IllegalStateException("No item tag result found")); @@ -46,12 +51,7 @@ public class TagMap { for (var entry : tags.entrySet()) { UnifyTag tag = UnifyTag.item(entry.getKey()); - if (!filter.test(tag)) { - continue; - } - var holderTag = entry.getValue(); - for (Holder holder : holderTag) { holder .unwrapKey() @@ -60,6 +60,25 @@ public class TagMap { .ifPresent(itemId -> tagMap.put(tag, itemId)); } } + return tagMap; + } + + /** + * Creates a filtered {@link TagMap}. + * + * @param tagFilter A filter to determine which tags to include. + * @param itemFilter A filter to determine which items to include. + * @return A new {@link TagMap}. + */ + public TagMap filtered(Predicate> tagFilter, Predicate itemFilter) { + TagMap tagMap = new TagMap(); + + tagsToItems.forEach((tag, items) -> { + if (!tagFilter.test(tag)) { + return; + } + items.stream().filter(itemFilter).forEach(item -> tagMap.put(tag, item)); + }); return tagMap; } diff --git a/Common/src/test/java/com/almostreliable/unified/TestUtils.java b/Common/src/test/java/com/almostreliable/unified/TestUtils.java index 4b54db1..ba348e4 100644 --- a/Common/src/test/java/com/almostreliable/unified/TestUtils.java +++ b/Common/src/test/java/com/almostreliable/unified/TestUtils.java @@ -1,10 +1,12 @@ package com.almostreliable.unified; +import com.almostreliable.unified.api.StoneStrataHandler; import com.almostreliable.unified.config.Defaults; import com.almostreliable.unified.config.UnifyConfig; import com.almostreliable.unified.recipe.RecipeTransformer; import com.almostreliable.unified.recipe.unifier.RecipeHandlerFactory; import com.almostreliable.unified.utils.ReplacementMap; +import com.almostreliable.unified.utils.TagMap; import com.almostreliable.unified.utils.TagMapTests; import com.almostreliable.unified.utils.UnifyTag; import com.google.gson.Gson; @@ -17,6 +19,7 @@ import net.minecraft.world.item.Item; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.function.Consumer; public class TestUtils { @@ -38,6 +41,7 @@ public class TestUtils { new HashSet<>(), new HashSet<>(), new HashSet<>(), + new HashSet<>(), true); public static final ResourceKey> FAKE_ITEM_REGISTRY = FakeResourceKeyRegistry.create("item"); public static final UnifyTag BRONZE_ORES_TAG = tag("forge:ores/bronze"); @@ -79,8 +83,14 @@ public class TestUtils { return new ResourceLocation(TEST_MOD_5, name); } + public static StoneStrataHandler createTestStrataHandler() { + return StoneStrataHandler.create(List.of(), Set.of(), TagMap.create(List.of())); + } + public static RecipeTransformer basicTransformer(Consumer consumer) { - ReplacementMap map = new ReplacementMap(TagMapTests.testTagMap(), DEFAULT_UNIFY_CONFIG); + ReplacementMap map = new ReplacementMap(TagMapTests.testTagMap(), + createTestStrataHandler(), + DEFAULT_UNIFY_CONFIG); RecipeHandlerFactory factory = new RecipeHandlerFactory(); consumer.accept(factory); return new RecipeTransformer(factory, map, DEFAULT_UNIFY_CONFIG, null); diff --git a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java index 020a061..2a45309 100644 --- a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java +++ b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java @@ -3,11 +3,15 @@ package com.almostreliable.unified; import com.almostreliable.unified.api.ModConstants; import com.almostreliable.unified.compat.AmethystImbuementRecipeUnifier; import com.almostreliable.unified.recipe.unifier.RecipeHandlerFactory; +import com.almostreliable.unified.utils.UnifyTag; import com.google.auto.service.AutoService; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.world.item.Item; import java.nio.file.Path; +import java.util.List; +import java.util.Set; @AutoService(AlmostUnifiedPlatform.class) public class AlmostUnifiedPlatformFabric implements AlmostUnifiedPlatform { @@ -46,4 +50,9 @@ public class AlmostUnifiedPlatformFabric implements AlmostUnifiedPlatform { public void bindRecipeHandlers(RecipeHandlerFactory factory) { factory.registerForMod(ModConstants.AMETHYST_IMBUEMENT, new AmethystImbuementRecipeUnifier()); } + + @Override + public Set> getStoneStrataTags(List stoneStrataIds) { + return Set.of(); + } } diff --git a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java index 6d59451..96b9c4d 100644 --- a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java +++ b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java @@ -3,7 +3,10 @@ package com.almostreliable.unified; import com.almostreliable.unified.api.ModConstants; import com.almostreliable.unified.compat.IERecipeUnifier; import com.almostreliable.unified.recipe.unifier.RecipeHandlerFactory; +import com.almostreliable.unified.utils.UnifyTag; import com.google.auto.service.AutoService; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.FMLLoader; @@ -12,6 +15,9 @@ import net.minecraftforge.fml.loading.LoadingModList; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import java.nio.file.Path; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; @AutoService(AlmostUnifiedPlatform.class) public class AlmostUnifiedPlatformForge implements AlmostUnifiedPlatform { @@ -53,4 +59,13 @@ public class AlmostUnifiedPlatformForge implements AlmostUnifiedPlatform { public void bindRecipeHandlers(RecipeHandlerFactory factory) { factory.registerForMod(ModConstants.IE, new IERecipeUnifier()); } + + @Override + public Set> getStoneStrataTags(List stoneStrataIds) { + return stoneStrataIds + .stream() + .map(id -> new ResourceLocation("forge", "ores_in_ground/" + id)) + .map(UnifyTag::item) + .collect(Collectors.toSet()); + } }