Brick Oven fully supports Ore Dictionary in JSON.

master
sealedinterface 2016-05-31 18:50:10 -07:00
parent 37de46033c
commit 461a2f3040
8 changed files with 73 additions and 31 deletions

View File

@ -15,7 +15,7 @@ public class JsonBrickOvenRecipeHandler
private List<String> includes = new ArrayList<>();
private List<String> modDependencies = new ArrayList<>();
private List<String> __COMMENTS = new ArrayList<>();
//private List<String> __COMMENTS = new ArrayList<>();
public JsonBrickOvenRecipeHandler()
{
@ -23,9 +23,9 @@ public class JsonBrickOvenRecipeHandler
}
public JsonBrickOvenRecipeHandler(boolean includeTesting)
{
__COMMENTS = new ArrayList<>();
__COMMENTS.add("Brick Oven recipes do not support ore dictionary in ingredients.");
__COMMENTS.add("This will change eventually. This only applies to Brick Oven recipes.");
//__COMMENTS = new ArrayList<>();
//__COMMENTS.add("Brick Oven recipes do not support ore dictionary in ingredients.");
//__COMMENTS.add("This will change eventually. This only applies to Brick Oven recipes.");
if (includeTesting)
{

View File

@ -89,6 +89,12 @@ public class JsonBrickOvenShapedRecipe
JsonLoadedItem ing = new JsonLoadedItem(new ItemStack(block));
ingredients.put(active, ing);
}
else if (obj instanceof String)
{
String ore = (String)obj;
JsonLoadedItem ing = JsonLoadedItem.makeOreDictionary(ore);
ingredients.put(active, ing);
}
}
}
}
@ -115,16 +121,23 @@ public class JsonBrickOvenShapedRecipe
JsonLoadedItem jli = entry.getValue();
ItemStack stack = jli.getFirstItemStackOrNull();
if (stack != null)
if (jli.isOreDictionary())
{
res.add(stack);
res.add(jli.getItemName());
}
else
{
ItemStack invalid = new ItemStack(Blocks.barrier);
invalid.setStackDisplayName("ERROR IN LOADING JSON RECIPE. MISSING INGREDIENT.");
res.add(invalid);
ItemStack stack = jli.getFirstItemStackOrNull();
if (stack != null)
{
res.add(stack);
}
else
{
ItemStack invalid = new ItemStack(Blocks.barrier);
invalid.setStackDisplayName("ERROR IN LOADING JSON RECIPE. MISSING INGREDIENT.");
res.add(invalid);
}
}
}
Object[] params = res.toArray();

View File

@ -41,6 +41,11 @@ public class JsonBrickOvenShapelessRecipe
Block block = (Block)obj;
inputs.add(new JsonLoadedItem(new ItemStack(block)));
}
else if (obj instanceof String)
{
String ore = (String)obj;
inputs.add(JsonLoadedItem.makeOreDictionary(ore));
}
}
}
@ -55,10 +60,17 @@ public class JsonBrickOvenShapelessRecipe
List<Object> res = new ArrayList<>();
for (JsonLoadedItem jli : inputs)
{
ItemStack stack = jli.getFirstItemStackOrNull();
if (stack != null)
if (jli.isOreDictionary())
{
res.add(stack);
res.add(jli.getItemName());
}
else
{
ItemStack stack = jli.getFirstItemStackOrNull();
if (stack != null)
{
res.add(stack);
}
}
}
Object[] params = res.toArray();

View File

@ -7,6 +7,7 @@ import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.gui.GuiBrickOven;
import net.einsteinsci.betterbeginnings.register.recipe.*;
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.client.gui.inventory.GuiContainer;
@ -15,6 +16,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import java.util.*;
@ -56,20 +58,28 @@ public class NEIBrickOvenRecipeHandler extends TemplateRecipeHandler
output = new PositionedStack(shapeless.getRecipeOutput(), 119, 10);
OreRecipeElement[] stacks = shapeless.getInputs();
for (int y = 0; y < 3; y++)
if (stacks.length > 0)
{
for (int x = 0; x < 3; x++)
for (int y = 0; y < 3; y++)
{
int i = y * 3 + x;
if (stacks[i] == null)
for (int x = 0; x < 3; x++)
{
continue;
}
int i = y * 3 + x;
inputs[i] = new PositionedStack(stacks[i].getValidItems(), 25 + x * 18, 6 + y * 18);
if (stacks[i] == null)
{
continue;
}
inputs[i] = new PositionedStack(stacks[i].getValidItems(), 25 + x * 18, 6 + y * 18);
}
}
}
else
{
LogUtil.log(Level.ERROR, "getInputs() returned empty array!");
}
}
}

View File

@ -105,15 +105,15 @@ public class RegisterRecipes
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.golden_apple, 1, 1), "###", "#A#", "###", '#',
Blocks.gold_block, 'A', Items.apple);
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.cake), "MMM", "SES", "WWW", 'M', Items.milk_bucket,
'S', Items.sugar, 'E', Items.egg, 'W', Items.wheat);
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.bread, 2), "WWW", 'W', Items.wheat);
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.cookie, 8), "WCW", 'W', Items.wheat, 'C',
'S', Items.sugar, 'E', Items.egg, 'W', "cropWheat");
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.bread, 2), "WWW", 'W', "cropWheat");
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.cookie, 8), "WCW", 'W', "cropWheat", 'C',
new ItemStack(Items.dye, 1, 3)); // Cocoa bean
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.rabbit_stew), " R ", "CPM", " B ",
'R', Items.cooked_rabbit, 'C', Items.carrot, 'P', Items.baked_potato,
'R', Items.cooked_rabbit, 'C', "cropCarrot", 'P', "cropPotato",
'M', Blocks.brown_mushroom, 'B', Items.bowl);
BrickOvenConfig.addShapedRecipe(new ItemStack(Items.rabbit_stew), " R ", "CPM", " B ",
'R', Items.cooked_rabbit, 'C', Items.carrot, 'P', Items.baked_potato,
'R', Items.cooked_rabbit, 'C', "cropCarrot", 'P', "cropPotato",
'M', Blocks.red_mushroom, 'B', Items.bowl);
BrickOvenConfig.addShapedRecipe(new ItemStack(RegisterItems.marshmallow, 3), " S ", "SSS", " S ",
'S', Items.sugar);
@ -128,7 +128,7 @@ public class RegisterRecipes
new ItemStack(Items.fish, 1, 1));
BrickOvenConfig.addShapelessRecipe(new ItemStack(Items.cooked_rabbit), Items.rabbit);
BrickOvenConfig.addShapelessRecipe(new ItemStack(Items.cooked_mutton), Items.mutton);
BrickOvenConfig.addShapelessRecipe(new ItemStack(Items.baked_potato), Items.potato);
BrickOvenConfig.addShapelessRecipe(new ItemStack(Items.baked_potato), "cropPotato");
BrickOvenConfig.addShapelessRecipe(new ItemStack(Items.pumpkin_pie), Items.egg, Items.sugar,
Blocks.pumpkin);
BrickOvenConfig.addShapelessRecipe(new ItemStack(Items.fermented_spider_eye), Items.spider_eye,

View File

@ -131,6 +131,10 @@ public class BrickOvenRecipeHandler
{
res.add(new OreRecipeElement(new ItemStack((Block)obj)));
}
else if (obj instanceof String)
{
res.add(new OreRecipeElement((String)obj));
}
else if(obj instanceof OreRecipeElement)
{
res.add(obj);

View File

@ -223,7 +223,6 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
{
buf.add(ore);
}
}
return buf.toArray(new OreRecipeElement[0]);

View File

@ -149,15 +149,19 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
@Override
public OreRecipeElement[] getInputs()
{
List<OreRecipeElement> buf = new ArrayList<>();
OreRecipeElement[] res = new OreRecipeElement[9];
int i = 0;
for (OreRecipeElement ore : recipeItems)
{
if (ore != null)
{
buf.add(ore);
res[i] = ore;
}
i++;
}
return buf.toArray(new OreRecipeElement[0]);
return res;
}
}