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){
ItemStack stackThere = empowerer.getStackInSlot(0);
if(heldItem != null){
if(stackThere == null && TileEntityEmpowerer.getRecipeForInput(heldItem) != null){
if(stackThere == null && !TileEntityEmpowerer.getRecipesForInput(heldItem).isEmpty()){
ItemStack toPut = heldItem.copy();
toPut.stackSize = 1;
empowerer.setInventorySlotContents(0, toPut);

View file

@ -35,15 +35,16 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
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){
for(EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES){
if(recipe.input != null && recipe.input.isItemEqual(input)){
return recipe;
recipesThatWork.add(recipe);
}
}
}
return null;
return recipesThatWork;
}
@Override
@ -51,40 +52,42 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
super.updateEntity();
if(!this.worldObj.isRemote){
EmpowererRecipe recipe = getRecipeForInput(this.slots[0]);
if(recipe != null){
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
if(modifierStands != null){ //Meaning the display stands around match all the criteria
boolean lessParticles = ConfigBoolValues.LESS_PARTICLES.isEnabled();
List<EmpowererRecipe> recipes = getRecipesForInput(this.slots[0]);
if(!recipes.isEmpty()){
for(EmpowererRecipe recipe : recipes){
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
if(modifierStands != null){ //Meaning the display stands around match all the criteria
boolean lessParticles = ConfigBoolValues.LESS_PARTICLES.isEnabled();
this.processTime++;
boolean done = this.processTime >= recipe.time;
this.processTime++;
boolean done = this.processTime >= recipe.time;
for(TileEntityDisplayStand stand : modifierStands){
stand.storage.extractEnergy(recipe.energyPerStand/recipe.time, false);
for(TileEntityDisplayStand stand : modifierStands){
stand.storage.extractEnergy(recipe.energyPerStand/recipe.time, false);
if(done){
stand.decrStackSize(0, 1);
}
if(!lessParticles){
AssetUtil.shootParticles(this.worldObj, stand.getPos().getX(), stand.getPos().getY()+0.45F, stand.getPos().getZ(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), recipe.particleColor, 8, 0.5F, 1F);
}
}
if(!lessParticles && this.processTime%5 == 0 && this.worldObj instanceof WorldServer){
((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, false, this.pos.getX()+0.5, this.pos.getY()+1.1, this.pos.getZ()+0.5, 3, 0, 0, 0, 0.1D);
}
if(done){
stand.decrStackSize(0, 1);
if(!lessParticles){
((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.END_ROD, false, this.pos.getX()+0.5, this.pos.getY()+1.1, this.pos.getZ()+0.5, 300, 0, 0, 0, 0.25D);
}
this.slots[0] = recipe.output.copy();
this.markDirty();
this.processTime = 0;
}
if(!lessParticles){
AssetUtil.shootParticles(this.worldObj, stand.getPos().getX(), stand.getPos().getY()+0.45F, stand.getPos().getZ(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), recipe.particleColor, 8, 0.5F, 1F);
}
}
if(!lessParticles && this.processTime%5 == 0 && this.worldObj instanceof WorldServer){
((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, false, this.pos.getX()+0.5, this.pos.getY()+1.1, this.pos.getZ()+0.5, 3, 0, 0, 0, 0.1D);
}
if(done){
if(!lessParticles){
((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.END_ROD, false, this.pos.getX()+0.5, this.pos.getY()+1.1, this.pos.getZ()+0.5, 300, 0, 0, 0, 0.25D);
}
this.slots[0] = recipe.output.copy();
this.markDirty();
this.processTime = 0;
}
}
}
@ -152,7 +155,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
return getRecipeForInput(stack) != null;
return !getRecipesForInput(stack).isEmpty();
}
@Override
@ -162,7 +165,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){
return getRecipeForInput(stack) == null;
return !getRecipesForInput(stack).isEmpty();
}
@Override