diff --git a/Common/src/main/java/com/almostreliable/unified/compat/AlmostJEI.java b/Common/src/main/java/com/almostreliable/unified/compat/AlmostJEI.java index b990b7d..8b9f77a 100644 --- a/Common/src/main/java/com/almostreliable/unified/compat/AlmostJEI.java +++ b/Common/src/main/java/com/almostreliable/unified/compat/AlmostJEI.java @@ -3,6 +3,8 @@ package com.almostreliable.unified.compat; import com.almostreliable.unified.AlmostUnifiedPlatform; import com.almostreliable.unified.BuildConfig; +import com.almostreliable.unified.config.Config; +import com.almostreliable.unified.config.UnifyConfig; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.VanillaTypes; @@ -26,7 +28,12 @@ public class AlmostJEI implements IModPlugin { return; } - Collection items = HideHelper.createHidingList(); + UnifyConfig config = Config.load(UnifyConfig.NAME, new UnifyConfig.Serializer()); + if(config.reiOrJeiDisabled()) { + return; + } + + Collection items = HideHelper.createHidingList(config); if (!items.isEmpty()) { jei.getIngredientManager().removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, items); } 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 d5d7a1d..da37d55 100644 --- a/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java +++ b/Common/src/main/java/com/almostreliable/unified/compat/HideHelper.java @@ -19,8 +19,7 @@ import java.util.stream.Collectors; public class HideHelper { - public static Collection createHidingList() { - UnifyConfig config = Config.load(UnifyConfig.NAME, new UnifyConfig.Serializer()); + public static Collection createHidingList(UnifyConfig config) { List> unifyTags = config.bakeTags(); TagMap tagMap = TagMap.create(unifyTags); ReplacementMap repMap = new ReplacementMap(tagMap, config); 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 ab12a85..ac953e6 100644 --- a/Common/src/main/java/com/almostreliable/unified/config/UnifyConfig.java +++ b/Common/src/main/java/com/almostreliable/unified/config/UnifyConfig.java @@ -1,10 +1,10 @@ package com.almostreliable.unified.config; import com.almostreliable.unified.AlmostUnified; -import com.almostreliable.unified.BuildConfig; import com.almostreliable.unified.utils.JsonUtils; import com.almostreliable.unified.utils.UnifyTag; import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; @@ -20,8 +20,9 @@ public class UnifyConfig extends Config { private final Set> ignoredTags; private final Set ignoredRecipeTypes; private final Set ignoredRecipes; + private final boolean hideJeiRei; - public UnifyConfig(List stoneStrata, List materials, List unbakedTags, List modPriorities, Set> ignoredTags, Set ignoredRecipeTypes, Set ignoredRecipes) { + public UnifyConfig(List stoneStrata, List materials, List unbakedTags, List modPriorities, Set> ignoredTags, Set ignoredRecipeTypes, Set ignoredRecipes, boolean hideJeiRei) { this.stoneStrata = stoneStrata; this.materials = materials; this.unbakedTags = unbakedTags; @@ -29,6 +30,7 @@ public class UnifyConfig extends Config { this.ignoredTags = ignoredTags; this.ignoredRecipeTypes = ignoredRecipeTypes; this.ignoredRecipes = ignoredRecipes; + this.hideJeiRei = hideJeiRei; } public List getStoneStrata() { @@ -68,6 +70,10 @@ public class UnifyConfig extends Config { return result; } + public boolean reiOrJeiDisabled() { + return !hideJeiRei; + } + public static class Serializer extends Config.Serializer { public static final String STONE_STRATA = "stoneStrata"; @@ -78,6 +84,8 @@ public class UnifyConfig extends Config { public static final String IGNORED_RECIPE_TYPES = "ignoredRecipeTypes"; public static final String IGNORED_RECIPES = "ignoredRecipes"; + public static final String HIDE_JEI_REI = "itemsHidingJeiRei"; + @Override public UnifyConfig deserialize(JsonObject json) { List stoneStrata = safeGet(() -> JsonUtils.toList(json.getAsJsonArray(STONE_STRATA)), @@ -102,8 +110,9 @@ public class UnifyConfig extends Config { .stream() .map(ResourceLocation::new) .collect(Collectors.toSet()), new HashSet<>()); + boolean hideJeiRei = safeGet(() -> json.getAsJsonPrimitive(HIDE_JEI_REI).getAsBoolean(), true); - return new UnifyConfig(stoneStrata, materials, tags, mods, ignoredTags, ignoredRecipeTypes, ignoredRecipes); + return new UnifyConfig(stoneStrata, materials, tags, mods, ignoredTags, ignoredRecipeTypes, ignoredRecipes, hideJeiRei); } @Override @@ -129,6 +138,7 @@ public class UnifyConfig extends Config { .stream() .map(ResourceLocation::toString) .collect(Collectors.toList()))); + json.add(HIDE_JEI_REI, new JsonPrimitive(config.hideJeiRei)); return json; } } diff --git a/Common/src/test/java/com/almostreliable/unified/TestUtils.java b/Common/src/test/java/com/almostreliable/unified/TestUtils.java index c6d103f..bbe406c 100644 --- a/Common/src/test/java/com/almostreliable/unified/TestUtils.java +++ b/Common/src/test/java/com/almostreliable/unified/TestUtils.java @@ -35,7 +35,8 @@ public class TestUtils { TestUtils.TEST_MOD_PRIORITIES, 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"); public static final UnifyTag INVAR_ORES_TAG = tag("forge:ores/invar"); diff --git a/Fabric/src/main/java/com/almostreliable/unified/compat/AlmostREI.java b/Fabric/src/main/java/com/almostreliable/unified/compat/AlmostREI.java index 57a9fe3..5cc609c 100644 --- a/Fabric/src/main/java/com/almostreliable/unified/compat/AlmostREI.java +++ b/Fabric/src/main/java/com/almostreliable/unified/compat/AlmostREI.java @@ -1,6 +1,8 @@ package com.almostreliable.unified.compat; import com.almostreliable.unified.AlmostUnifiedPlatform; +import com.almostreliable.unified.config.Config; +import com.almostreliable.unified.config.UnifyConfig; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.common.util.EntryStacks; @@ -12,6 +14,11 @@ public class AlmostREI implements REIClientPlugin { return; } - HideHelper.createHidingList().stream().map(EntryStacks::of).forEach(registry::removeEntry); + UnifyConfig config = Config.load(UnifyConfig.NAME, new UnifyConfig.Serializer()); + if(config.reiOrJeiDisabled()) { + return; + } + + HideHelper.createHidingList(config).stream().map(EntryStacks::of).forEach(registry::removeEntry); } }