Machines no longer require an input in the set slot

This commit is contained in:
modmuss50 2015-05-16 17:23:39 +01:00
parent f7124cb7e6
commit d32b39d8c6
2 changed files with 41 additions and 16 deletions

View file

@ -51,7 +51,7 @@ if (ENV.BUILD_NUMBER) {
}
minecraft {
version = "1.7.10-10.13.3.1394-1710ls"
version = "1.7.10-10.13.3.1403-1.7.10"
replace "@MODVERSION@", project.version
replaceIn "ModInfo.java"
replaceIn "package-info.java"

View file

@ -1,6 +1,7 @@
package techreborn.api.recipe;
import ic2.api.energy.prefab.BasicSink;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.tiles.TileMachineBase;
@ -87,27 +88,17 @@ public class RecipeCrafter {
public void updateEntity() {
if (currentRecipe == null) {
for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) {
boolean isFullRecipe = false;
for (int i = 0; i < inputs; i++) {
if (ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), recipe.getInputs().get(i), true, true, true) && inventory.getStackInSlot(inputSlots[i]).stackSize >= recipe.getInputs().get(i).stackSize) {
isFullRecipe = true;
} else {
isFullRecipe = false;
}
}
if (isFullRecipe) {
if(hasAllInputs(recipe)){
currentRecipe = recipe;
return;
}
}
} else {
for (int i = 0; i < inputs; i++) {
if (!ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), currentRecipe.getInputs().get(i), true, true, true) || (inventory.getStackInSlot(inputSlots[i]) == null || (inventory.getStackInSlot(inputSlots[i]).stackSize < currentRecipe.getInputs().get(i).stackSize))) {
if(!hasAllInputs()){
currentRecipe = null;
currentTickTime = 0;
return;
}
}
if (currentTickTime >= currentRecipe.tickTime()) {
boolean canGiveInvAll = true;
for (int i = 0; i < currentRecipe.getOutputs().size(); i++) {
@ -141,6 +132,40 @@ public class RecipeCrafter {
}
}
public boolean hasAllInputs(){
if(currentRecipe == null){
return false;
}
for(ItemStack input : currentRecipe.getInputs()){
Boolean hasItem = false;
for(int inputslot : inputSlots){
if(ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, true)){
hasItem = true;
}
}
if(!hasItem)
return false;
}
return true;
}
public boolean hasAllInputs(IBaseRecipeType recipeType){
if(recipeType == null){
return false;
}
for(ItemStack input : recipeType.getInputs()){
Boolean hasItem = false;
for(int inputslot : inputSlots){
if(ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, true)){
hasItem = true;
}
}
if(!hasItem)
return false;
}
return true;
}
public boolean canFitStack(ItemStack stack, int slot) {
if (stack == null) {
return true;