From 3063bd887cd1243ef40d24b685abaa81239aef83 Mon Sep 17 00:00:00 2001 From: fscan Date: Sun, 26 Nov 2017 15:44:56 +0100 Subject: [PATCH] Revert DamageableRecipe changes (#3246) Forge fixed this after all. This is no longer needed. --- .../recipes/DamagedRecipeFactory.java | 105 ------------------ .../recipes/_factories.json | 3 +- .../recipes/network/parts/cable_anchor.json | 2 +- 3 files changed, 2 insertions(+), 108 deletions(-) delete mode 100644 src/main/java/appeng/recipes/factories/recipes/DamagedRecipeFactory.java diff --git a/src/main/java/appeng/recipes/factories/recipes/DamagedRecipeFactory.java b/src/main/java/appeng/recipes/factories/recipes/DamagedRecipeFactory.java deleted file mode 100644 index 6816e5560..000000000 --- a/src/main/java/appeng/recipes/factories/recipes/DamagedRecipeFactory.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2017, 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.factories.recipes; - - -import java.util.Iterator; - -import javax.annotation.Nonnull; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; - -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.JsonUtils; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.common.crafting.IRecipeFactory; -import net.minecraftforge.common.crafting.JsonContext; -import net.minecraftforge.oredict.ShapelessOreRecipe; - - -public class DamagedRecipeFactory implements IRecipeFactory -{ - @Override - public IRecipe parse( JsonContext context, JsonObject json ) - { - String group = JsonUtils.getString( json, "group", "" ); - - NonNullList ings = NonNullList.create(); - for( JsonElement ele : JsonUtils.getJsonArray( json, "ingredients" ) ) - { - ings.add( CraftingHelper.getIngredient( ele, context ) ); - } - - if( ings.isEmpty() ) - { - throw new JsonParseException( "No ingredients for shapeless recipe" ); - } - - return new DamagedRecipe( group.isEmpty() ? null : new ResourceLocation( group ), ings, PartRecipeFactory.getResult( json, context ) ); - } - - private static class DamagedRecipe extends ShapelessOreRecipe - { - public DamagedRecipe( ResourceLocation group, NonNullList input, ItemStack result ) - { - super( group, input, result ); - } - - @Override - public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World world ) - { - NonNullList required = NonNullList.create(); - required.addAll( input ); - - for( int i = 0; i < inv.getSizeInventory(); ++i ) - { - final ItemStack current = inv.getStackInSlot( i ); - if( !current.isEmpty() ) - { - boolean inRecipe = false; - final Iterator req = required.iterator(); - - while( req.hasNext() ) - { - if( req.next().apply( current ) ) - { - inRecipe = true; - req.remove(); - break; - } - } - if( !inRecipe ) - { - return false; - } - } - } - - return required.isEmpty(); - } - } -} diff --git a/src/main/resources/assets/appliedenergistics2/recipes/_factories.json b/src/main/resources/assets/appliedenergistics2/recipes/_factories.json index b611ee14f..5f8190ca8 100644 --- a/src/main/resources/assets/appliedenergistics2/recipes/_factories.json +++ b/src/main/resources/assets/appliedenergistics2/recipes/_factories.json @@ -8,7 +8,6 @@ }, "recipes": { "part_shaped": "appeng.recipes.factories.recipes.PartRecipeFactory", - "part_shapeless": "appeng.recipes.factories.recipes.PartRecipeFactory", - "damaged": "appeng.recipes.factories.recipes.DamagedRecipeFactory" + "part_shapeless": "appeng.recipes.factories.recipes.PartRecipeFactory" } } diff --git a/src/main/resources/assets/appliedenergistics2/recipes/network/parts/cable_anchor.json b/src/main/resources/assets/appliedenergistics2/recipes/network/parts/cable_anchor.json index 4f6560026..f1b45ab16 100644 --- a/src/main/resources/assets/appliedenergistics2/recipes/network/parts/cable_anchor.json +++ b/src/main/resources/assets/appliedenergistics2/recipes/network/parts/cable_anchor.json @@ -1,5 +1,5 @@ { - "type": "appliedenergistics2:damaged", + "type": "appliedenergistics2:part_shapeless", "result": { "part": "part.cable_anchor", "count": 3