Fixes #1601: Do not allow 0 as stacksize for recipes

This commit is contained in:
yueh
2015-08-06 22:45:16 +02:00
committed by thatsIch
parent b0504f4141
commit d26caa5f8b
9 changed files with 82 additions and 43 deletions
@@ -23,6 +23,8 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.exceptions.MissingIngredientError;
@@ -34,16 +36,22 @@ import appeng.api.recipes.IIngredient;
public class GroupIngredient implements IIngredient
{
final String name;
final List<IIngredient> ingredients;
int qty = 0;
ItemStack[] baked;
private final String name;
private final List<IIngredient> ingredients;
private final int qty;
private ItemStack[] baked;
boolean isInside = false;
public GroupIngredient( String myName, List<IIngredient> ingredients ) throws RecipeError
public GroupIngredient( String myName, List<IIngredient> ingredients, int qty ) throws RecipeError
{
Preconditions.checkNotNull( myName );
Preconditions.checkNotNull( ingredients );
Preconditions.checkState( !ingredients.isEmpty() );
Preconditions.checkState( qty > 0 );
this.name = myName;
this.qty = qty;
for( IIngredient ingredient : ingredients )
{
@@ -58,9 +66,8 @@ public class GroupIngredient implements IIngredient
public IIngredient copy( int qty ) throws RecipeError
{
GroupIngredient gi = new GroupIngredient( this.name, this.ingredients );
gi.qty = qty;
return gi;
Preconditions.checkState( qty > 0 );
return new GroupIngredient( this.name, this.ingredients, qty );
}
@Override
@@ -143,7 +150,7 @@ public class GroupIngredient implements IIngredient
@Override
public int getQty()
{
return 0;
return this.qty;
}
@Override