Made the empowerer work with all of its recipes

Closes #295
This commit is contained in:
Ellpeck 2016-10-21 00:13:21 +02:00
parent 64b62b4f80
commit 4e8e749f4f
2 changed files with 38 additions and 35 deletions

View file

@ -55,7 +55,7 @@ public class BlockEmpowerer extends BlockContainerBase{
if(empowerer != null){ if(empowerer != null){
ItemStack stackThere = empowerer.getStackInSlot(0); ItemStack stackThere = empowerer.getStackInSlot(0);
if(heldItem != null){ if(heldItem != null){
if(stackThere == null && TileEntityEmpowerer.getRecipeForInput(heldItem) != null){ if(stackThere == null && !TileEntityEmpowerer.getRecipesForInput(heldItem).isEmpty()){
ItemStack toPut = heldItem.copy(); ItemStack toPut = heldItem.copy();
toPut.stackSize = 1; toPut.stackSize = 1;
empowerer.setInventorySlotContents(0, toPut); empowerer.setInventorySlotContents(0, toPut);

View file

@ -35,15 +35,16 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
super(1, "empowerer"); super(1, "empowerer");
} }
public static EmpowererRecipe getRecipeForInput(ItemStack input){ public static List<EmpowererRecipe> getRecipesForInput(ItemStack input){
List<EmpowererRecipe> recipesThatWork = new ArrayList<EmpowererRecipe>();
if(input != null){ if(input != null){
for(EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES){ for(EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES){
if(recipe.input != null && recipe.input.isItemEqual(input)){ if(recipe.input != null && recipe.input.isItemEqual(input)){
return recipe; recipesThatWork.add(recipe);
} }
} }
} }
return null; return recipesThatWork;
} }
@Override @Override
@ -51,8 +52,9 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
super.updateEntity(); super.updateEntity();
if(!this.worldObj.isRemote){ if(!this.worldObj.isRemote){
EmpowererRecipe recipe = getRecipeForInput(this.slots[0]); List<EmpowererRecipe> recipes = getRecipesForInput(this.slots[0]);
if(recipe != null){ if(!recipes.isEmpty()){
for(EmpowererRecipe recipe : recipes){
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time); TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
if(modifierStands != null){ //Meaning the display stands around match all the criteria if(modifierStands != null){ //Meaning the display stands around match all the criteria
boolean lessParticles = ConfigBoolValues.LESS_PARTICLES.isEnabled(); boolean lessParticles = ConfigBoolValues.LESS_PARTICLES.isEnabled();
@ -88,6 +90,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
} }
} }
} }
}
else{ else{
this.processTime = 0; this.processTime = 0;
} }
@ -152,7 +155,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
@Override @Override
public boolean isItemValidForSlot(int index, ItemStack stack){ public boolean isItemValidForSlot(int index, ItemStack stack){
return getRecipeForInput(stack) != null; return !getRecipesForInput(stack).isEmpty();
} }
@Override @Override
@ -162,7 +165,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
@Override @Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){ public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){
return getRecipeForInput(stack) == null; return !getRecipesForInput(stack).isEmpty();
} }
@Override @Override