Fix factories resetting progress

This commit is contained in:
Aidan C. Brady 2014-02-19 23:36:01 -05:00
parent 656a1a8baa
commit 7c9d267499
2 changed files with 32 additions and 1 deletions

View file

@ -1,5 +1,7 @@
package mekanism.common; package mekanism.common;
import java.util.Map;
import mekanism.api.AdvancedInput; import mekanism.api.AdvancedInput;
import mekanism.api.gas.Gas; import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
@ -8,6 +10,7 @@ import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedElectricMachine;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -133,6 +136,31 @@ public interface IFactory
return false; return false;
} }
public boolean hasRecipe(ItemStack itemStack)
{
if(itemStack == null)
{
return false;
}
for(Object obj : recipe.get().entrySet())
{
if(((Map.Entry)obj).getKey() instanceof AdvancedInput)
{
Map.Entry entry = (Map.Entry)obj;
ItemStack stack = ((AdvancedInput)entry.getKey()).itemStack;
if(StackUtils.equalsWildcard(stack, itemStack))
{
return true;
}
}
}
return false;
}
public TileEntityAdvancedElectricMachine getTile() public TileEntityAdvancedElectricMachine getTile()
{ {
if(cacheTile == null) if(cacheTile == null)

View file

@ -227,7 +227,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
if(!canOperate(getInputSlot(process), getOutputSlot(process))) if(!canOperate(getInputSlot(process), getOutputSlot(process)))
{ {
progress[process] = 0; if(!RecipeType.values()[recipeType].usesFuel() || !RecipeType.values()[recipeType].hasRecipe(inventory[getInputSlot(process)]))
{
progress[process] = 0;
}
} }
} }