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,40 +52,42 @@ 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()){
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time); for(EmpowererRecipe recipe : recipes){
if(modifierStands != null){ //Meaning the display stands around match all the criteria TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
boolean lessParticles = ConfigBoolValues.LESS_PARTICLES.isEnabled(); if(modifierStands != null){ //Meaning the display stands around match all the criteria
boolean lessParticles = ConfigBoolValues.LESS_PARTICLES.isEnabled();
this.processTime++; this.processTime++;
boolean done = this.processTime >= recipe.time; boolean done = this.processTime >= recipe.time;
for(TileEntityDisplayStand stand : modifierStands){ for(TileEntityDisplayStand stand : modifierStands){
stand.storage.extractEnergy(recipe.energyPerStand/recipe.time, false); 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){ 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 @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