Removed superfluous conditional recipes (#4433)
If needed, a global flag to disable all AE2 recipes will be added later.
This commit is contained in:
@@ -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<EntityType<?>> event) {
|
||||
|
||||
@@ -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<IFinishedRecipe> 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()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<AEFeature> 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<FeaturesEnabled> {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user