Update to support updated recipe format in reborn core.

This commit is contained in:
modmuss50 2017-01-08 21:43:15 +00:00
parent d435d5d772
commit 6aa8fde64a
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA
7 changed files with 54 additions and 91 deletions

View file

@ -12,6 +12,7 @@ import reborncore.api.recipe.IBaseRecipeType;
import reborncore.api.recipe.RecipeHandler;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.recipes.RecipeTranslator;
import reborncore.common.tile.TileLegacyMachineBase;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
@ -124,14 +125,20 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
if (recipeType == null) {
return false;
}
for (ItemStack input : recipeType.getInputs()) {
Boolean hasItem = false;
for (Object input : recipeType.getInputs()) {
boolean hasItem = false;
boolean useOreDict = input instanceof String || recipeType.useOreDic();
boolean checkSize = input instanceof ItemStack;
for (int inputslot = 0; inputslot < 2; inputslot++) {
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true,
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).getCount() >= input.getCount()) {
hasItem = true;
if (ItemUtils.isInputEqual(input, inventory.getStackInSlot(inputslot), true, true,
useOreDict)) {
ItemStack stack = RecipeTranslator.getStackFromObject(input);
if(!checkSize || inventory.getStackInSlot(inputslot).getCount() >= stack.getCount()){
hasItem = true;
}
}
}
if (!hasItem)
return false;
}
@ -199,11 +206,16 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
hasAllRecipes = false;
}
if (hasAllRecipes) {
for (ItemStack input : recipeType.getInputs()) {
for (Object input : recipeType.getInputs()) {
boolean useOreDict = input instanceof String || recipeType.useOreDic();
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true,
recipeType.useOreDic())) {
inventory.decrStackSize(inputSlot, input.getCount());
if (ItemUtils.isInputEqual(input, inventory.getStackInSlot(inputSlot), true, true,
useOreDict)) {
int count = 1;
if(input instanceof ItemStack){
count = RecipeTranslator.getStackFromObject(input).getCount();
}
inventory.decrStackSize(inputSlot, count);
break;
}
}