From d8928070fdf939a4a07cb49b057310630634f75f Mon Sep 17 00:00:00 2001 From: yueh Date: Thu, 25 Jun 2020 21:33:41 +0200 Subject: [PATCH] Removed superfluous conditional recipes (#4433) If needed, a global flag to disable all AE2 recipes will be added later. --- src/main/java/appeng/core/Registration.java | 3 - .../providers/recipes/SlabStairRecipes.java | 39 ++---- .../recipes/conditions/FeaturesEnabled.java | 112 ------------------ .../recipes/materials/advancedcard.json | 6 - .../recipes/materials/annihilationcore.json | 6 - .../recipes/materials/basiccard.json | 6 - .../recipes/materials/cardcapacity.json | 6 - .../recipes/materials/cardcrafting.json | 6 - .../recipes/materials/cardfuzzy.json | 6 - .../recipes/materials/cardinverter.json | 6 - .../recipes/materials/cardredstone.json | 6 - .../recipes/materials/cardspeed.json | 6 - .../recipes/materials/formationcore.json | 6 - .../recipes/misc/grindstone_woodengear.json | 6 - .../recipes/special/disassemble.json | 6 - .../recipes/special/facade.json | 6 - 16 files changed, 12 insertions(+), 220 deletions(-) delete mode 100644 src/main/java/appeng/recipes/conditions/FeaturesEnabled.java diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index dbe10693a..2f0dc473e 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -100,7 +100,6 @@ import appeng.fluids.container.*; import appeng.fluids.registries.BasicFluidCellGuiHandler; import appeng.items.parts.FacadeItem; import appeng.me.cache.*; -import appeng.recipes.conditions.FeaturesEnabled; import appeng.recipes.game.DisassembleRecipe; import appeng.recipes.game.FacadeRecipe; import appeng.recipes.handlers.GrinderRecipe; @@ -343,8 +342,6 @@ final class Registration { r.registerAll(DisassembleRecipe.SERIALIZER, GrinderRecipeSerializer.INSTANCE, InscriberRecipeSerializer.INSTANCE, FacadeRecipe.getSerializer(facadeItem), DisassembleRecipe.SERIALIZER); - - CraftingHelper.register(FeaturesEnabled.Serializer.INSTANCE); } public void registerEntities(RegistryEvent.Register> event) { diff --git a/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java b/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java index 0e87735a6..1077b6311 100644 --- a/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java +++ b/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java @@ -4,8 +4,6 @@ import java.util.function.Consumer; import javax.annotation.Nonnull; -import com.google.common.collect.Sets; - import net.minecraft.block.Block; import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; @@ -19,7 +17,6 @@ import net.minecraftforge.common.crafting.ConditionalRecipe; import appeng.api.definitions.IBlockDefinition; import appeng.core.AppEng; import appeng.forge.data.providers.IAE2DataProvider; -import appeng.recipes.conditions.FeaturesEnabled; public class SlabStairRecipes extends RecipeProvider implements IAE2DataProvider { @@ -48,38 +45,26 @@ public class SlabStairRecipes extends RecipeProvider implements IAE2DataProvider Block inputBlock = block.block(); Block outputBlock = slabs.block(); - FeaturesEnabled condition = new FeaturesEnabled(Sets.union(block.features(), slabs.features())); - ConditionalRecipe.builder().addCondition(condition) - .addRecipe(ShapedRecipeBuilder.shapedRecipe(slabs.block(), 6).patternLine("###").key('#', inputBlock) - .addCriterion(criterionName(block), hasItem(inputBlock))::build) - .build(consumer, AppEng.MOD_ID, "slabs/" + block.identifier()); - - ConditionalRecipe.builder().addCondition(condition) - .addRecipe(c -> SingleItemRecipeBuilder - .stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock, 2) - .addCriterion(criterionName(block), hasItem(inputBlock)) - .build(c, new ResourceLocation(AppEng.MOD_ID, slabs.identifier()))) - .build(consumer, AppEng.MOD_ID, "slabs/block_cutter/" + block.identifier()); + ShapedRecipeBuilder.shapedRecipe(slabs.block(), 6).patternLine("###").key('#', inputBlock) + .addCriterion(criterionName(block), hasItem(inputBlock)) + .build(consumer, new ResourceLocation(AppEng.MOD_ID, "shaped/slabs/" + block.identifier())); + SingleItemRecipeBuilder.stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock, 2) + .addCriterion(criterionName(block), hasItem(inputBlock)) + .build(consumer, new ResourceLocation(AppEng.MOD_ID, "block_cutter/slabs/" + slabs.identifier())); } private void stairRecipe(Consumer consumer, IBlockDefinition block, IBlockDefinition stairs) { Block inputBlock = block.block(); Block outputBlock = stairs.block(); - FeaturesEnabled condition = new FeaturesEnabled(Sets.union(block.features(), stairs.features())); - ConditionalRecipe.builder().addCondition(condition) - .addRecipe(ShapedRecipeBuilder.shapedRecipe(outputBlock, 4).patternLine("# ").patternLine("## ") - .patternLine("###").key('#', inputBlock) - .addCriterion(criterionName(block), hasItem(inputBlock))::build) - .build(consumer, AppEng.MOD_ID, "stairs/" + block.identifier()); + ShapedRecipeBuilder.shapedRecipe(outputBlock, 4).patternLine("# ").patternLine("## ").patternLine("###") + .key('#', inputBlock).addCriterion(criterionName(block), hasItem(inputBlock)) + .build(consumer, new ResourceLocation(AppEng.MOD_ID, "shaped/stairs/" + block.identifier())); - ConditionalRecipe.builder().addCondition(condition) - .addRecipe( - c -> SingleItemRecipeBuilder.stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock) - .addCriterion(criterionName(block), hasItem(inputBlock)) - .build(c, new ResourceLocation(AppEng.MOD_ID, stairs.identifier()))) - .build(consumer, AppEng.MOD_ID, "stairs/block_cutter/" + block.identifier()); + SingleItemRecipeBuilder.stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock) + .addCriterion(criterionName(block), hasItem(inputBlock)) + .build(consumer, new ResourceLocation(AppEng.MOD_ID, "block_cutter/stairs/" + stairs.identifier())); } diff --git a/src/main/java/appeng/recipes/conditions/FeaturesEnabled.java b/src/main/java/appeng/recipes/conditions/FeaturesEnabled.java deleted file mode 100644 index a62964b03..000000000 --- a/src/main/java/appeng/recipes/conditions/FeaturesEnabled.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.recipes.conditions; - -import java.util.Arrays; -import java.util.Locale; -import java.util.Set; -import java.util.stream.StreamSupport; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.crafting.conditions.ICondition; -import net.minecraftforge.common.crafting.conditions.IConditionSerializer; - -import appeng.api.features.AEFeature; -import appeng.core.AEConfig; -import appeng.core.AppEng; - -public class FeaturesEnabled implements ICondition { - private static final ResourceLocation NAME = new ResourceLocation(AppEng.MOD_ID, "feature"); - private final AEFeature[] features; - - public FeaturesEnabled(AEFeature... features) { - this.features = features; - } - - public FeaturesEnabled(Set features) { - this(features.toArray(new AEFeature[0])); - } - - @Override - public ResourceLocation getID() { - return NAME; - } - - @Override - public boolean test() { - for (AEFeature feature : features) { - if (!AEConfig.instance().isFeatureEnabled(feature)) { - return false; - } - } - - return true; - } - - public static class Serializer implements IConditionSerializer { - private static final String JSON_FEATURES_KEY = "features"; - - public static final Serializer INSTANCE = new Serializer(); - - private Serializer() { - } - - @Override - public void write(JsonObject json, FeaturesEnabled value) { - json.add(JSON_FEATURES_KEY, Arrays.stream(value.features).map(AEFeature::toString).reduce(new JsonArray(), - (JsonArray array, String string) -> { - array.add(string); - return array; - }, (a, b) -> b)); - } - - @Override - public FeaturesEnabled read(JsonObject jsonObject) { - AEFeature[] features; - - if (JSONUtils.isJsonArray(jsonObject, JSON_FEATURES_KEY)) { - final JsonArray featuresArray = JSONUtils.getJsonArray(jsonObject, JSON_FEATURES_KEY); - - features = StreamSupport.stream(featuresArray.spliterator(), false).filter(JsonElement::isJsonPrimitive) - .map(JsonElement::getAsString).map(s -> s.toUpperCase(Locale.ENGLISH)).map(AEFeature::valueOf) - .toArray(AEFeature[]::new); - } else if (JSONUtils.isString(jsonObject, JSON_FEATURES_KEY)) { - final String featureName = JSONUtils.getString(jsonObject, JSON_FEATURES_KEY) - .toUpperCase(Locale.ENGLISH); - features = new AEFeature[] { AEFeature.valueOf(featureName) }; - } else { - features = new AEFeature[] {}; - } - - return new FeaturesEnabled(features); - } - - @Override - public ResourceLocation getID() { - return NAME; - } - - } - -} \ No newline at end of file diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json b/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json index b0a66311a..172562e0f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["ADVANCED_CARDS"] - } - ], "result": { "item": "appliedenergistics2:advanced_card", "count": 2 diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json b/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json index 314768657..eb1be2cb4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["CORES"] - } - ], "result": { "item": "appliedenergistics2:annihilation_core", "count": 2 diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json b/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json index 841bb3984..3993e010d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["BASIC_CARDS"] - } - ], "result": { "item": "appliedenergistics2:basic_card", "count": 2 diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json index b1c4ff79d..9286610c2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["BASIC_CARDS"] - } - ], "result": { "item": "appliedenergistics2:capacity_card" }, diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json index 54e20cc56..4757f7dc0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["ADVANCED_CARDS", "CRAFTING_CPU"] - } - ], "result": { "item": "appliedenergistics2:crafting_card" }, diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json index 6de77e54b..d850f8b03 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["ADVANCED_CARDS"] - } - ], "result": { "item": "appliedenergistics2:fuzzy_card" }, diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json index a4d7e1f80..a229b12a0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["ADVANCED_CARDS"] - } - ], "result": { "item": "appliedenergistics2:inverter_card" }, diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json index 7833e5ee0..6fc23318f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["BASIC_CARDS"] - } - ], "result": { "item": "appliedenergistics2:redstone_card" }, diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json index 260ea93bf..6ad175d98 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["ADVANCED_CARDS"] - } - ], "result": { "item": "appliedenergistics2:speed_card" }, diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json b/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json index 81c738f36..a40a29bd5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["CORES"] - } - ], "result": { "item": "appliedenergistics2:formation_core", "count": 2 diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json index e68d46d5a..df85875f5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json @@ -1,10 +1,4 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["GRIND_STONE"] - } - ], "result": { "item": "appliedenergistics2:wooden_gear" }, diff --git a/src/main/resources/data/appliedenergistics2/recipes/special/disassemble.json b/src/main/resources/data/appliedenergistics2/recipes/special/disassemble.json index 38add6605..c1aa106be 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/special/disassemble.json +++ b/src/main/resources/data/appliedenergistics2/recipes/special/disassemble.json @@ -1,9 +1,3 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["ENABLE_DISASSEMBLY_CRAFTING"] - } - ], "type": "appliedenergistics2:disassemble" } diff --git a/src/main/resources/data/appliedenergistics2/recipes/special/facade.json b/src/main/resources/data/appliedenergistics2/recipes/special/facade.json index 047800560..bda66d438 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/special/facade.json +++ b/src/main/resources/data/appliedenergistics2/recipes/special/facade.json @@ -1,9 +1,3 @@ { - "conditions": [ - { - "type": "appliedenergistics2:feature", - "features": ["ENABLE_FACADE_CRAFTING"] - } - ], "type": "appliedenergistics2:facade" }