Actually fix NBT recipes

This commit is contained in:
Tom Elfring committed 2017-06-25 14:26:21 +02:00
1 parent 678581f440
commit 6aa2ad30fe
89 files changed
+209 -151

No files matched your search

+1 -1
View File
@@ -279,7 +279,7 @@ public class Mekanism
*/
public void addRecipes()
{
if(true)
if(false) // Generate JSON files from code, disabled.
{
MekanismRecipes.generate();
MekanismToolsRecipes.generate();
@@ -0,0 +1,58 @@
package mekanism.common.recipe;
import com.google.gson.JsonObject;
import mekanism.common.util.RecipeUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.IIngredientFactory;
import net.minecraftforge.common.crafting.JsonContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class MekanismIngredient extends Ingredient
{
private final ItemStack stack;
protected MekanismIngredient(ItemStack stack)
{
super(stack);
this.stack = stack;
}
@Override
public boolean apply(@Nullable ItemStack input)
{
if (input == null)
return false;
return RecipeUtils.areItemsEqualForCrafting(this.stack, input);
}
public static Ingredient fromStacks(ItemStack... stacks)
{
if (stacks.length > 0)
{
for (ItemStack itemstack : stacks)
{
if (!itemstack.isEmpty())
{
return new MekanismIngredient(itemstack);
}
}
}
return EMPTY;
}
// Used in _factories.json
public static class IngredientFactory implements IIngredientFactory
{
@Nonnull
@Override
public Ingredient parse(JsonContext context, JsonObject json) {
final ItemStack stack = CraftingHelper.getItemStack(json, context);
return MekanismIngredient.fromStacks(stack);
}
}
}
@@ -178,7 +178,7 @@ public class RecipeGenerator {
throw new IllegalArgumentException("Missing NBT mapping for Key: " + key);
}
}
ret.put("type", "minecraft:item_nbt");
ret.put("type", "mekanism:item_nbt");
ret.put("nbt", tag);
}
@@ -1,9 +1,6 @@
package mekanism.common.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import mekanism.api.energy.IEnergizedItem;