diff --git a/src/main/java/techreborn/api/recipe/BaseRecipe.java b/src/main/java/techreborn/api/recipe/BaseRecipe.java index b4af134a1..95a1967ba 100644 --- a/src/main/java/techreborn/api/recipe/BaseRecipe.java +++ b/src/main/java/techreborn/api/recipe/BaseRecipe.java @@ -1,6 +1,7 @@ package techreborn.api.recipe; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import java.util.ArrayList; import java.util.List; @@ -53,4 +54,14 @@ public abstract class BaseRecipe implements IBaseRecipeType { public int euPerTick() { return euPerTick; } + + @Override + public boolean canCraft(TileEntity tile) { + return true; + } + + @Override + public boolean onCraft(TileEntity tile) { + return true; + } } diff --git a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java index d44831686..9e4022881 100644 --- a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java +++ b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java @@ -1,6 +1,7 @@ package techreborn.api.recipe; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import java.util.List; @@ -42,4 +43,18 @@ public interface IBaseRecipeType { * @return the amount of eu to be used per tick. */ public int euPerTick(); + + /** + * + * @param tile the tile that is doing the crafting + * @return if true the recipe will craft, if false it will not + */ + public boolean canCraft(TileEntity tile); + + /** + * + * @param tile the tile that is doing the crafting + * @return return true if fluid was taken and should craft + */ + public boolean onCraft(TileEntity tile); } diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 3b8b8f622..4a60a949f 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -88,10 +88,18 @@ public class RecipeCrafter { public void updateEntity() { if (currentRecipe == null) { for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) { - if(hasAllInputs(recipe)){ - currentRecipe = recipe; - parentTile.syncWithAll(); - return; + if(recipe.canCraft(parentTile) && hasAllInputs(recipe)){ + boolean canGiveInvAll = true; + for (int i = 0; i < recipe.getOutputs().size(); i++) { + if (!canFitStack(recipe.getOutputs().get(i), outputSlots[i])) { + canGiveInvAll = false; + } + } + if(canGiveInvAll){ + currentRecipe = recipe; + parentTile.syncWithAll(); + return; + } } } } else { @@ -109,7 +117,7 @@ public class RecipeCrafter { } } ArrayList filledSlots = new ArrayList(); - if (canGiveInvAll) { + if (canGiveInvAll && currentRecipe.onCraft(parentTile)) { for (int i = 0; i < currentRecipe.getOutputs().size(); i++) { if (!filledSlots.contains(outputSlots[i])) { fitStack(currentRecipe.getOutputs().get(i), outputSlots[i]);