Added OreDictionary Support for Brick Oven (hardcoded only)
parent
638cc4dd2c
commit
1c78aed706
|
@ -5,10 +5,7 @@ import codechicken.nei.PositionedStack;
|
|||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.GuiBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.BrickOvenRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.BrickOvenShapedRecipe;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.BrickOvenShapelessRecipe;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.IBrickOvenRecipe;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.*;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
|
@ -37,7 +34,7 @@ public class NEIBrickOvenRecipeHandler extends TemplateRecipeHandler
|
|||
BrickOvenShapedRecipe shaped = (BrickOvenShapedRecipe)ibr;
|
||||
|
||||
output = new PositionedStack(shaped.getRecipeOutput(), 119, 10);
|
||||
ItemStack[] grid = shaped.getThreeByThree();
|
||||
OreRecipeElement[] grid = shaped.getThreeByThree();
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int x = 0; x < 3; x++)
|
||||
|
@ -49,7 +46,7 @@ public class NEIBrickOvenRecipeHandler extends TemplateRecipeHandler
|
|||
continue;
|
||||
}
|
||||
|
||||
inputs[i] = new PositionedStack(grid[i], 25 + x * 18, 6 + y * 18);
|
||||
inputs[i] = new PositionedStack(grid[i].getValidItems(), 25 + x * 18, 6 + y * 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +55,7 @@ public class NEIBrickOvenRecipeHandler extends TemplateRecipeHandler
|
|||
BrickOvenShapelessRecipe shapeless = (BrickOvenShapelessRecipe)ibr;
|
||||
|
||||
output = new PositionedStack(shapeless.getRecipeOutput(), 119, 10);
|
||||
ItemStack[] stacks = shapeless.getInputs();
|
||||
OreRecipeElement[] stacks = shapeless.getInputs();
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int x = 0; x < 3; x++)
|
||||
|
@ -70,7 +67,7 @@ public class NEIBrickOvenRecipeHandler extends TemplateRecipeHandler
|
|||
continue;
|
||||
}
|
||||
|
||||
inputs[i] = new PositionedStack(stacks[i], 25 + x * 18, 6 + y * 18);
|
||||
inputs[i] = new PositionedStack(stacks[i].getValidItems(), 25 + x * 18, 6 + y * 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,19 +131,17 @@ public class NEIBrickOvenRecipeHandler extends TemplateRecipeHandler
|
|||
for (IBrickOvenRecipe ibr : BrickOvenRecipeHandler.getRecipeList())
|
||||
{
|
||||
boolean found = false;
|
||||
ItemStack[] inp = ibr.getInputs();
|
||||
OreRecipeElement[] inp = ibr.getInputs();
|
||||
for (int i = 0; i < inp.length; i++)
|
||||
{
|
||||
ItemStack is = inp[i];
|
||||
OreRecipeElement ore = inp[i];
|
||||
|
||||
if (is == null)
|
||||
if (ore == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is.getItem() == ingredient.getItem() &&
|
||||
(is.getItemDamage() == ingredient.getItemDamage() ||
|
||||
ingredient.getItemDamage() == OreDictionary.WILDCARD_VALUE))
|
||||
if (ore.matches(ingredient))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
package 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.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BrickOvenRecipeHandler
|
||||
{
|
||||
private static final BrickOvenRecipeHandler INSTANCE = new BrickOvenRecipeHandler();
|
||||
protected List<IBrickOvenRecipe> recipes = new ArrayList<IBrickOvenRecipe>();
|
||||
protected List<IBrickOvenRecipe> recipes = new ArrayList<>();
|
||||
|
||||
public BrickOvenRecipeHandler()
|
||||
{ }
|
||||
|
@ -56,41 +58,46 @@ public class BrickOvenRecipeHandler
|
|||
for (hashmap = new HashMap(); i < args.length; i += 2)
|
||||
{
|
||||
Character character = (Character)args[i];
|
||||
ItemStack itemstack1 = null;
|
||||
OreRecipeElement stackInRecipe = null;
|
||||
|
||||
if (args[i + 1] instanceof Item)
|
||||
{
|
||||
itemstack1 = new ItemStack((Item)args[i + 1]);
|
||||
stackInRecipe = new OreRecipeElement(new ItemStack((Item)args[i + 1], 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
else if (args[i + 1] instanceof Block)
|
||||
{
|
||||
itemstack1 = new ItemStack((Block)args[i + 1], 1, OreDictionary.WILDCARD_VALUE);
|
||||
stackInRecipe = new OreRecipeElement(
|
||||
new ItemStack((Block)args[i + 1], 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
else if (args[i + 1] instanceof ItemStack)
|
||||
{
|
||||
itemstack1 = (ItemStack)args[i + 1];
|
||||
stackInRecipe = new OreRecipeElement((ItemStack)args[i + 1]);
|
||||
}
|
||||
else if (args[i + 1] instanceof String)
|
||||
{
|
||||
stackInRecipe = new OreRecipeElement((String)args[i + 1], 1);
|
||||
}
|
||||
|
||||
hashmap.put(character, itemstack1);
|
||||
hashmap.put(character, stackInRecipe);
|
||||
}
|
||||
|
||||
ItemStack[] aitemstack = new ItemStack[j * k];
|
||||
OreRecipeElement[] aOreRecipeElement = new OreRecipeElement[j * k];
|
||||
|
||||
for (int i1 = 0; i1 < j * k; ++i1)
|
||||
{
|
||||
char c0 = s.charAt(i1);
|
||||
|
||||
if (hashmap.containsKey(Character.valueOf(c0)))
|
||||
if (hashmap.containsKey(c0))
|
||||
{
|
||||
aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy();
|
||||
aOreRecipeElement[i1] = ((OreRecipeElement)hashmap.get(c0)).copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
aitemstack[i1] = null;
|
||||
aOreRecipeElement[i1] = null;
|
||||
}
|
||||
}
|
||||
|
||||
BrickOvenShapedRecipe ovenrecipe = new BrickOvenShapedRecipe(j, k, aitemstack, result);
|
||||
BrickOvenShapedRecipe ovenrecipe = new BrickOvenShapedRecipe(j, k, aOreRecipeElement, result);
|
||||
recipes.add(ovenrecipe);
|
||||
return ovenrecipe;
|
||||
}
|
||||
|
@ -107,34 +114,34 @@ public class BrickOvenRecipeHandler
|
|||
|
||||
public BrickOvenShapelessRecipe putShapelessRecipe(ItemStack output, Object... args)
|
||||
{
|
||||
ArrayList arraylist = new ArrayList();
|
||||
Object[] aobject = args;
|
||||
int i = args.length;
|
||||
ArrayList res = new ArrayList();
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
for (Object obj : args)
|
||||
{
|
||||
Object object1 = aobject[j];
|
||||
|
||||
if (object1 instanceof ItemStack)
|
||||
if (obj instanceof ItemStack)
|
||||
{
|
||||
arraylist.add(((ItemStack)object1).copy());
|
||||
res.add(new OreRecipeElement((ItemStack)obj));
|
||||
}
|
||||
else if (object1 instanceof Item)
|
||||
else if (obj instanceof Item)
|
||||
{
|
||||
arraylist.add(new ItemStack((Item)object1));
|
||||
res.add(new OreRecipeElement(new ItemStack((Item)obj)));
|
||||
}
|
||||
else if (obj instanceof Block)
|
||||
{
|
||||
res.add(new OreRecipeElement(new ItemStack((Block)obj)));
|
||||
}
|
||||
else if(obj instanceof OreRecipeElement)
|
||||
{
|
||||
res.add(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(object1 instanceof Block))
|
||||
{
|
||||
throw new RuntimeException("Invalid shapeless recipe!");
|
||||
}
|
||||
|
||||
arraylist.add(new ItemStack((Block)object1));
|
||||
LogUtil.log(Level.WARN, "Invalid shapeless recipe!");
|
||||
}
|
||||
}
|
||||
|
||||
BrickOvenShapelessRecipe recipe = new BrickOvenShapelessRecipe(output, arraylist);
|
||||
BrickOvenShapelessRecipe recipe = new BrickOvenShapelessRecipe(output, res);
|
||||
recipes.add(recipe);
|
||||
|
||||
return recipe;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOvenBase;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -22,14 +23,14 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
/**
|
||||
* Is a array of ItemStack that composes the recipe.
|
||||
*/
|
||||
public final ItemStack[] recipeItems;
|
||||
public final OreRecipeElement[] recipeItems;
|
||||
/**
|
||||
* Is the ItemStack that you get when craft the recipe.
|
||||
*/
|
||||
private ItemStack recipeOutput;
|
||||
private boolean strangeField;
|
||||
|
||||
public BrickOvenShapedRecipe(int width, int height, ItemStack[] input, ItemStack output)
|
||||
public BrickOvenShapedRecipe(int width, int height, OreRecipeElement[] input, ItemStack output)
|
||||
{
|
||||
recipeWidth = width;
|
||||
recipeHeight = height;
|
||||
|
@ -41,7 +42,7 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(TileEntityBrickOven oven)
|
||||
public boolean matches(TileEntityBrickOvenBase oven)
|
||||
{
|
||||
for (int i = 0; i <= 3 - recipeWidth; ++i)
|
||||
{
|
||||
|
@ -62,29 +63,7 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(TileEntityNetherBrickOven oven)
|
||||
{
|
||||
for (int i = 0; i <= 3 - recipeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j <= 3 - recipeHeight; ++j)
|
||||
{
|
||||
if (checkMatch(oven, i, j, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkMatch(oven, i, j, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkMatch(TileEntityNetherBrickOven oven, int width, int height, boolean flag4)
|
||||
private boolean checkMatch(TileEntityBrickOvenBase oven, int width, int height, boolean flag4)
|
||||
{
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
|
@ -92,36 +71,30 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
{
|
||||
int i1 = k - width;
|
||||
int j1 = l - height;
|
||||
ItemStack itemstack = null;
|
||||
OreRecipeElement recipeIngredient = null;
|
||||
|
||||
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
|
||||
{
|
||||
if (flag4)
|
||||
{
|
||||
itemstack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
recipeIngredient = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = recipeItems[i1 + j1 * recipeWidth];
|
||||
recipeIngredient = recipeItems[i1 + j1 * recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = oven.getStackInRowAndColumn(k, l);
|
||||
|
||||
if (itemstack1 != null || itemstack != null)
|
||||
if (itemstack1 != null || recipeIngredient != null)
|
||||
{
|
||||
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
|
||||
if (itemstack1 == null && recipeIngredient != null || itemstack1 != null && recipeIngredient == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItem() != itemstack1.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItemDamage() != OreDictionary.WILDCARD_VALUE &&
|
||||
itemstack.getItemDamage() != itemstack1.getItemDamage())
|
||||
if(!recipeIngredient.matches(itemstack1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -136,28 +109,7 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityBrickOven oven)
|
||||
{
|
||||
ItemStack itemstack = getRecipeOutput().copy();
|
||||
|
||||
if (strangeField)
|
||||
{
|
||||
for (int i = 0; i < oven.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack1 = oven.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null && itemstack1.hasTagCompound())
|
||||
{
|
||||
itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityNetherBrickOven oven)
|
||||
public ItemStack getCraftingResult(TileEntityBrickOvenBase oven)
|
||||
{
|
||||
ItemStack itemstack = getRecipeOutput().copy();
|
||||
|
||||
|
@ -189,14 +141,14 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
@Override
|
||||
public boolean contains(ItemStack stack)
|
||||
{
|
||||
for (ItemStack s : recipeItems)
|
||||
for (OreRecipeElement ore : recipeItems)
|
||||
{
|
||||
if (s == null)
|
||||
if (ore == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (s.getItem() == stack.getItem())
|
||||
if(ore.matches(stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -210,45 +162,6 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
return recipeOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputs()
|
||||
{
|
||||
List<ItemStack> buf = new ArrayList<>();
|
||||
for (ItemStack is : recipeItems)
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
buf.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
return buf.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
public ItemStack[] getThreeByThree()
|
||||
{
|
||||
ItemStack[] res = new ItemStack[9];
|
||||
|
||||
int y = 0, x = 0;
|
||||
int v = 0, u = 0;
|
||||
for (int i = 0; i < getRecipeSize(); i++)
|
||||
{
|
||||
res[x + y * 3] = recipeItems[u + v * recipeWidth];
|
||||
|
||||
u++;
|
||||
if (u >= recipeWidth)
|
||||
{
|
||||
u = 0;
|
||||
v++;
|
||||
}
|
||||
|
||||
x = u;
|
||||
y = v;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the region of a crafting inventory is match for the recipe.
|
||||
*/
|
||||
|
@ -260,36 +173,30 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
{
|
||||
int i1 = k - width;
|
||||
int j1 = l - height;
|
||||
ItemStack itemstack = null;
|
||||
OreRecipeElement recipeIngredient = null;
|
||||
|
||||
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
|
||||
{
|
||||
if (flag4)
|
||||
{
|
||||
itemstack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
recipeIngredient = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = recipeItems[i1 + j1 * recipeWidth];
|
||||
recipeIngredient = recipeItems[i1 + j1 * recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = oven.getStackInRowAndColumn(k, l);
|
||||
|
||||
if (itemstack1 != null || itemstack != null)
|
||||
if (itemstack1 != null || recipeIngredient != null)
|
||||
{
|
||||
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
|
||||
if (itemstack1 == null && recipeIngredient != null || itemstack1 != null && recipeIngredient == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItem() != itemstack1.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItemDamage() != OreDictionary.WILDCARD_VALUE &&
|
||||
itemstack.getItemDamage() != itemstack1.getItemDamage())
|
||||
if(!recipeIngredient.matches(itemstack1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -300,9 +207,54 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
return true;
|
||||
}
|
||||
|
||||
public BrickOvenShapedRecipe func_92100_c()
|
||||
/*public BrickOvenShapedRecipe func_92100_c()
|
||||
{
|
||||
strangeField = true;
|
||||
return this;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public OreRecipeElement[] getInputs()
|
||||
{
|
||||
List<OreRecipeElement> buf = new ArrayList<>();
|
||||
for (OreRecipeElement ore : recipeItems)
|
||||
{
|
||||
if (ore != null)
|
||||
{
|
||||
buf.add(ore);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return buf.toArray(new OreRecipeElement[0]);
|
||||
}
|
||||
|
||||
public OreRecipeElement[] getThreeByThree()
|
||||
{
|
||||
OreRecipeElement[] res = new OreRecipeElement[9];
|
||||
|
||||
int y = 0, x = 0;
|
||||
int v = 0, u = 0;
|
||||
for (int i = 0; i < getRecipeSize(); i++)
|
||||
{
|
||||
if(recipeItems[u + v * recipeWidth] == null)
|
||||
{
|
||||
res[x + y * 3] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
res[x + y * 3] = recipeItems[u + v * recipeWidth];
|
||||
}
|
||||
u++;
|
||||
if (u >= recipeWidth)
|
||||
{
|
||||
u = 0;
|
||||
v++;
|
||||
}
|
||||
|
||||
x = u;
|
||||
y = v;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOvenBase;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
@ -12,13 +13,13 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
|||
/**
|
||||
* Is a List of ItemStack that composes the recipe.
|
||||
*/
|
||||
public final List<ItemStack> recipeItems;
|
||||
public final List<OreRecipeElement> recipeItems;
|
||||
/**
|
||||
* Is the ItemStack that you get when craft the recipe.
|
||||
*/
|
||||
private final ItemStack recipeOutput;
|
||||
|
||||
public BrickOvenShapelessRecipe(ItemStack output, List<ItemStack> input)
|
||||
public BrickOvenShapelessRecipe(ItemStack output, List<OreRecipeElement> input)
|
||||
{
|
||||
recipeOutput = output;
|
||||
recipeItems = input;
|
||||
|
@ -28,9 +29,9 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
|||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(TileEntityBrickOven oven)
|
||||
public boolean matches(TileEntityBrickOvenBase oven)
|
||||
{
|
||||
ArrayList<ItemStack> arraylist = new ArrayList<ItemStack>(recipeItems);
|
||||
ArrayList<OreRecipeElement> arraylist = new ArrayList<>(recipeItems);
|
||||
|
||||
for (int col = 0; col < 3; ++col)
|
||||
{
|
||||
|
@ -45,12 +46,9 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
|||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ItemStack itemstack1 = (ItemStack)iterator.next();
|
||||
OreRecipeElement itemstack1 = (OreRecipeElement)iterator.next();
|
||||
|
||||
if (itemstack.getItem() == itemstack1.getItem() &&
|
||||
(itemstack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemstack
|
||||
.getItemDamage() == itemstack1
|
||||
.getItemDamage()))
|
||||
if (itemstack1 != null && itemstack1.matches(itemstack))
|
||||
{
|
||||
flag = true;
|
||||
arraylist.remove(itemstack1);
|
||||
|
@ -69,59 +67,53 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
|||
return arraylist.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(TileEntityNetherBrickOven oven)
|
||||
{
|
||||
ArrayList<ItemStack> arraylist = new ArrayList<ItemStack>(recipeItems);
|
||||
|
||||
for (int col = 0; col < 3; ++col)
|
||||
{
|
||||
for (int row = 0; row < 3; ++row)
|
||||
{
|
||||
ItemStack itemstack = oven.getStackInRowAndColumn(row, col);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
boolean flag = false;
|
||||
Iterator iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ItemStack itemstack1 = (ItemStack)iterator.next();
|
||||
|
||||
if (itemstack.getItem() == itemstack1.getItem() &&
|
||||
(itemstack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemstack
|
||||
.getItemDamage() == itemstack1
|
||||
.getItemDamage()))
|
||||
{
|
||||
flag = true;
|
||||
arraylist.remove(itemstack1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist.isEmpty();
|
||||
}
|
||||
//@Override
|
||||
//public boolean matches(TileEntityNetherBrickOven oven)
|
||||
//{
|
||||
// ArrayList<OreRecipeElement> arraylist = new ArrayList<>(recipeItems);
|
||||
//
|
||||
// for (int col = 0; col < 3; ++col)
|
||||
// {
|
||||
// for (int row = 0; row < 3; ++row)
|
||||
// {
|
||||
// ItemStack itemstack = oven.getStackInRowAndColumn(row, col);
|
||||
//
|
||||
// if (itemstack != null)
|
||||
// {
|
||||
// boolean flag = false;
|
||||
// Iterator iterator = arraylist.iterator();
|
||||
//
|
||||
// while (iterator.hasNext())
|
||||
// {
|
||||
// ItemStack itemstack1 = (ItemStack)iterator.next();
|
||||
//
|
||||
// if (itemstack.getItem() == itemstack1.getItem() &&
|
||||
// (itemstack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemstack
|
||||
// .getItemDamage() == itemstack1
|
||||
// .getItemDamage()))
|
||||
// {
|
||||
// flag = true;
|
||||
// arraylist.remove(itemstack1);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!flag)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return arraylist.isEmpty();
|
||||
//}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityBrickOven oven)
|
||||
{
|
||||
return recipeOutput.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityNetherBrickOven oven)
|
||||
public ItemStack getCraftingResult(TileEntityBrickOvenBase oven)
|
||||
{
|
||||
return recipeOutput.copy();
|
||||
}
|
||||
|
@ -138,9 +130,9 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
|||
@Override
|
||||
public boolean contains(ItemStack stack)
|
||||
{
|
||||
for (ItemStack s : recipeItems)
|
||||
for (OreRecipeElement ore : recipeItems)
|
||||
{
|
||||
if (s.getItem() == stack.getItem())
|
||||
if (ore.matches(stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -155,14 +147,17 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputs()
|
||||
public OreRecipeElement[] getInputs()
|
||||
{
|
||||
ItemStack[] res = new ItemStack[9];
|
||||
for (int i = 0; i < recipeItems.size(); i++)
|
||||
List<OreRecipeElement> buf = new ArrayList<>();
|
||||
for (OreRecipeElement ore : recipeItems)
|
||||
{
|
||||
res[i] = recipeItems.get(i);
|
||||
if (ore != null)
|
||||
{
|
||||
buf.add(ore);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
return buf.toArray(new OreRecipeElement[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOvenBase;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -11,16 +12,12 @@ public interface IBrickOvenRecipe
|
|||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
boolean matches(TileEntityBrickOven inv);
|
||||
|
||||
boolean matches(TileEntityNetherBrickOven inv);
|
||||
boolean matches(TileEntityBrickOvenBase inv);
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
ItemStack getCraftingResult(TileEntityBrickOven inv);
|
||||
|
||||
ItemStack getCraftingResult(TileEntityNetherBrickOven inv);
|
||||
ItemStack getCraftingResult(TileEntityBrickOvenBase inv);
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
|
@ -31,5 +28,5 @@ public interface IBrickOvenRecipe
|
|||
|
||||
ItemStack getRecipeOutput();
|
||||
|
||||
ItemStack[] getInputs();
|
||||
OreRecipeElement[] getInputs();
|
||||
}
|
||||
|
|
|
@ -188,6 +188,11 @@ public abstract class TileEntityBrickOvenBase extends TileEntitySpecializedFurna
|
|||
return slot == OUTPUT ? false : slot == FUEL ? isItemFuel(stack) : true;
|
||||
}
|
||||
|
||||
public ItemStack getStackInRowAndColumn(int row, int column)
|
||||
{
|
||||
return getStackInSlot(INPUTSTART + row + column * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int par1, ItemStack stack, EnumFacing side)
|
||||
{
|
||||
|
|
|
@ -231,11 +231,6 @@ public class TileEntityNetherBrickOven extends TileEntityBrickOvenBase implement
|
|||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getStackInRowAndColumn(int row, int column)
|
||||
{
|
||||
return getStackInSlot(INPUTSTART + row + column * 3);
|
||||
}
|
||||
|
||||
public int getFuelLevelScaled(int maxLevel)
|
||||
{
|
||||
float levelAbs = getFuelLevel();
|
||||
|
|
Loading…
Reference in New Issue