diff --git a/src/main/java/ru/betterend/config/Configs.java b/src/main/java/ru/betterend/config/Configs.java index d6a32724..0e0590ad 100644 --- a/src/main/java/ru/betterend/config/Configs.java +++ b/src/main/java/ru/betterend/config/Configs.java @@ -10,6 +10,7 @@ public class Configs { public static final PathConfig ITEM_CONFIG = new PathConfig("items"); public static final IdConfig BIOME_CONFIG = new EntryConfig("biomes"); public static final PathConfig GENERATOR_CONFIG = new PathConfig("generator"); + public static final PathConfig RECIPE_CONFIG = new PathConfig("recipes"); @Environment(value = EnvType.CLIENT) public static final PathConfig CLENT_CONFIG = new PathConfig("client"); @@ -20,6 +21,7 @@ public class Configs { BIOME_CONFIG.saveChanges(); ITEM_CONFIG.saveChanges(); GENERATOR_CONFIG.saveChanges(); + RECIPE_CONFIG.saveChanges(); if (BetterEnd.isClient()) { CLENT_CONFIG.saveChanges(); diff --git a/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java b/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java index e139ac16..6a18f458 100644 --- a/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java @@ -20,6 +20,7 @@ import net.minecraft.util.JsonHelper; import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import ru.betterend.BetterEnd; +import ru.betterend.config.Configs; import ru.betterend.recipe.EndRecipeManager; import ru.betterend.registry.EndBlocks; import ru.betterend.util.ItemUtil; @@ -118,6 +119,7 @@ public class AlloyingRecipe implements Recipe { public static class Builder { private final static Builder INSTANCE = new Builder(); + private static boolean exist; public static Builder create(Identifier id) { INSTANCE.id = id; @@ -127,6 +129,7 @@ public class AlloyingRecipe implements Recipe { INSTANCE.output = null; INSTANCE.experience = 0.0F; INSTANCE.smeltTime = 350; + exist = Configs.RECIPE_CONFIG.getBoolean("alloying", id.getPath(), true); return INSTANCE; } @@ -206,27 +209,29 @@ public class AlloyingRecipe implements Recipe { } public void build() { - if (primaryInput == null) { - BetterEnd.LOGGER.warning("Primary input for Alloying recipe can't be 'null', recipe {} will be ignored!", id); - return; + if (exist) { + if (primaryInput == null) { + BetterEnd.LOGGER.warning("Primary input for Alloying recipe can't be 'null', recipe {} will be ignored!", id); + return; + } + if(secondaryInput == null) { + BetterEnd.LOGGER.warning("Secondary input for Alloying can't be 'null', recipe {} will be ignored!", id); + return; + } + if(output == null) { + BetterEnd.LOGGER.warning("Output for Alloying can't be 'null', recipe {} will be ignored!", id); + return; + } + if (EndRecipeManager.getRecipe(TYPE, id) != null) { + BetterEnd.LOGGER.warning("Can't add Alloying recipe! Id {} already exists!", id); + return; + } + if (!alright) { + BetterEnd.LOGGER.debug("Can't add Alloying recipe {}! Ingeredient or output not exists.", id); + return; + } + EndRecipeManager.addRecipe(TYPE, new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime)); } - if(secondaryInput == null) { - BetterEnd.LOGGER.warning("Secondary input for Alloying can't be 'null', recipe {} will be ignored!", id); - return; - } - if(output == null) { - BetterEnd.LOGGER.warning("Output for Alloying can't be 'null', recipe {} will be ignored!", id); - return; - } - if (EndRecipeManager.getRecipe(TYPE, id) != null) { - BetterEnd.LOGGER.warning("Can't add Alloying recipe! Id {} already exists!", id); - return; - } - if (!alright) { - BetterEnd.LOGGER.debug("Can't add Alloying recipe {}! Ingeredient or output not exists.", id); - return; - } - EndRecipeManager.addRecipe(TYPE, new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime)); } } diff --git a/src/main/java/ru/betterend/recipe/builders/AnvilSmithingRecipe.java b/src/main/java/ru/betterend/recipe/builders/AnvilSmithingRecipe.java index fb07983d..fc32a204 100644 --- a/src/main/java/ru/betterend/recipe/builders/AnvilSmithingRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/AnvilSmithingRecipe.java @@ -21,6 +21,7 @@ import net.minecraft.util.JsonHelper; import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import ru.betterend.BetterEnd; +import ru.betterend.config.Configs; import ru.betterend.recipe.EndRecipeManager; import ru.betterend.registry.EndTags; import ru.betterend.util.ItemUtil; @@ -126,6 +127,7 @@ public class AnvilSmithingRecipe implements Recipe { public static class Builder { private final static Builder INSTANCE = new Builder(); + private static boolean exist; public static Builder create(String id) { return create(BetterEnd.makeID(id)); @@ -137,6 +139,7 @@ public class AnvilSmithingRecipe implements Recipe { INSTANCE.output = null; INSTANCE.level = 1; INSTANCE.damage = 1; + exist = Configs.RECIPE_CONFIG.getBoolean("anvil", id.getPath(), true); return INSTANCE; } @@ -185,23 +188,25 @@ public class AnvilSmithingRecipe implements Recipe { } public void build() { - if (input == null) { - BetterEnd.LOGGER.warning("Input for Smithing recipe can't be 'null', recipe {} will be ignored!", id); - return; + if (exist) { + if (input == null) { + BetterEnd.LOGGER.warning("Input for Smithing recipe can't be 'null', recipe {} will be ignored!", id); + return; + } + if(output == null) { + BetterEnd.LOGGER.warning("Output for Smithing recipe can't be 'null', recipe {} will be ignored!", id); + return; + } + if (EndRecipeManager.getRecipe(TYPE, id) != null) { + BetterEnd.LOGGER.warning("Can't add Smithing recipe! Id {} already exists!", id); + return; + } + if (!alright) { + BetterEnd.LOGGER.debug("Can't add Smithing recipe {}! Ingeredient or output not exists.", id); + return; + } + EndRecipeManager.addRecipe(TYPE, new AnvilSmithingRecipe(id, input, output, level, damage)); } - if(output == null) { - BetterEnd.LOGGER.warning("Output for Smithing recipe can't be 'null', recipe {} will be ignored!", id); - return; - } - if (EndRecipeManager.getRecipe(TYPE, id) != null) { - BetterEnd.LOGGER.warning("Can't add Smithing recipe! Id {} already exists!", id); - return; - } - if (!alright) { - BetterEnd.LOGGER.debug("Can't add Smithing recipe {}! Ingeredient or output not exists.", id); - return; - } - EndRecipeManager.addRecipe(TYPE, new AnvilSmithingRecipe(id, input, output, level, damage)); } } diff --git a/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java b/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java index 455cbb64..474466f6 100644 --- a/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java @@ -7,6 +7,7 @@ import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.SmeltingRecipe; import net.minecraft.util.Identifier; import ru.betterend.BetterEnd; +import ru.betterend.config.Configs; import ru.betterend.recipe.EndRecipeManager; import ru.betterend.util.RecipeHelper; @@ -15,7 +16,7 @@ public class FurnaceRecipe { private ItemConvertible input; private ItemConvertible output; - private boolean exist = true; + private boolean exist; private String group; private String name; private int count; @@ -32,7 +33,7 @@ public class FurnaceRecipe { INSTANCE.count = 1; INSTANCE.time = 200; INSTANCE.xp = 0; - INSTANCE.exist = RecipeHelper.exists(output) && RecipeHelper.exists(input); + INSTANCE.exist = Configs.RECIPE_CONFIG.getBoolean("furnace", name, true) && RecipeHelper.exists(output) && RecipeHelper.exists(input); return INSTANCE; } diff --git a/src/main/java/ru/betterend/recipe/builders/GridRecipe.java b/src/main/java/ru/betterend/recipe/builders/GridRecipe.java index e449d596..3aa19988 100644 --- a/src/main/java/ru/betterend/recipe/builders/GridRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/GridRecipe.java @@ -17,6 +17,7 @@ import net.minecraft.tag.Tag; import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; import ru.betterend.BetterEnd; +import ru.betterend.config.Configs; import ru.betterend.recipe.EndRecipeManager; import ru.betterend.util.RecipeHelper; @@ -47,7 +48,7 @@ public class GridRecipe { INSTANCE.materialKeys.clear(); INSTANCE.count = 1; - INSTANCE.exist = RecipeHelper.exists(output); + INSTANCE.exist = Configs.RECIPE_CONFIG.getBoolean("grid", name, true) && RecipeHelper.exists(output); return INSTANCE; } diff --git a/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java b/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java index 9e9db019..7504abc9 100644 --- a/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java @@ -19,6 +19,7 @@ import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import ru.betterend.BetterEnd; +import ru.betterend.config.Configs; import ru.betterend.recipe.EndRecipeManager; import ru.betterend.rituals.InfusionRitual; import ru.betterend.util.ItemUtil; @@ -110,6 +111,7 @@ public class InfusionRecipe implements Recipe { public static class Builder { private final static Builder INSTANCE = new Builder(); + private static boolean exist; public static Builder create(String id) { return create(BetterEnd.makeID(id)); @@ -120,6 +122,7 @@ public class InfusionRecipe implements Recipe { INSTANCE.input = null; INSTANCE.output = null; INSTANCE.time = 1; + exist = Configs.RECIPE_CONFIG.getBoolean("infusion", id.getPath(), true); Arrays.fill(INSTANCE.catalysts, Ingredient.EMPTY); @@ -171,27 +174,29 @@ public class InfusionRecipe implements Recipe { } public void build() { - if (input == null) { - BetterEnd.LOGGER.warning("Input for Infusion recipe can't be 'null', recipe {} will be ignored!", id); - return; + if (exist) { + if (input == null) { + BetterEnd.LOGGER.warning("Input for Infusion recipe can't be 'null', recipe {} will be ignored!", id); + return; + } + if (output == null) { + BetterEnd.LOGGER.warning("Output for Infusion recipe can't be 'null', recipe {} will be ignored!", id); + return; + } + InfusionRecipe recipe = new InfusionRecipe(id, input, output); + recipe.group = group != null ? group : GROUP; + recipe.time = time; + int empty = 0; + for (int i = 0; i < catalysts.length; i++) { + if (catalysts[i].isEmpty()) empty++; + else recipe.catalysts[i] = catalysts[i]; + } + if (empty == catalysts.length) { + BetterEnd.LOGGER.warning("At least one catalyst must be non empty, recipe {} will be ignored!", id); + return; + } + EndRecipeManager.addRecipe(TYPE, recipe); } - if (output == null) { - BetterEnd.LOGGER.warning("Output for Infusion recipe can't be 'null', recipe {} will be ignored!", id); - return; - } - InfusionRecipe recipe = new InfusionRecipe(id, input, output); - recipe.group = group != null ? group : GROUP; - recipe.time = time; - int empty = 0; - for (int i = 0; i < catalysts.length; i++) { - if (catalysts[i].isEmpty()) empty++; - else recipe.catalysts[i] = catalysts[i]; - } - if (empty == catalysts.length) { - BetterEnd.LOGGER.warning("At least one catalyst must be non empty, recipe {} will be ignored!", id); - return; - } - EndRecipeManager.addRecipe(TYPE, recipe); } }