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
@@ -33,6 +33,10 @@ import java.util.zip.ZipOutputStream;
import javax.annotation.Nonnull;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.HashMultimap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.LoaderState;
@@ -72,9 +76,8 @@ import com.google.common.collect.HashMultimap;
*/
public class RecipeHandler implements IRecipeHandler
{
public final List<String> tokens = new LinkedList<String>();
final RecipeData data;
private final RecipeData data;
private final List<String> tokens = new LinkedList<String>();
public RecipeHandler()
{
@@ -83,12 +86,13 @@ public class RecipeHandler implements IRecipeHandler
RecipeHandler( RecipeHandler parent )
{
Preconditions.checkNotNull( parent );
this.data = parent.data;
}
private void addCrafting( ICraftHandler ch )
{
this.data.Handlers.add( ch );
this.data.handlers.add( ch );
}
public String getName( @Nonnull IIngredient i )
@@ -114,6 +118,8 @@ public class RecipeHandler implements IRecipeHandler
public String getName( ItemStack is ) throws RecipeError
{
Preconditions.checkNotNull( is );
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() );
String realName = id.modId + ':' + id.name;
@@ -220,6 +226,8 @@ public class RecipeHandler implements IRecipeHandler
public String alias( String in )
{
Preconditions.checkNotNull( in );
String out = this.data.aliases.get( in );
if( out != null )
@@ -233,6 +241,9 @@ public class RecipeHandler implements IRecipeHandler
@Override
public void parseRecipes( IRecipeLoader loader, String path )
{
Preconditions.checkNotNull( loader );
Preconditions.checkNotNull( path );
try
{
BufferedReader reader = null;
@@ -364,7 +375,7 @@ public class RecipeHandler implements IRecipeHandler
Map<Class, Integer> processed = new HashMap<Class, Integer>();
try
{
for( ICraftHandler ch : this.data.Handlers )
for( ICraftHandler ch : this.data.handlers )
{
try
{
@@ -503,7 +514,7 @@ public class RecipeHandler implements IRecipeHandler
{
List<IWebsiteSerializer> out = new LinkedList<IWebsiteSerializer>();
for( ICraftHandler ch : this.data.Handlers )
for( ICraftHandler ch : this.data.handlers )
{
try
{
@@ -521,6 +532,11 @@ public class RecipeHandler implements IRecipeHandler
return out;
}
RecipeData getData()
{
return this.data;
}
private void processTokens( IRecipeLoader loader, String file, int line ) throws RecipeError
{
try
@@ -557,7 +573,7 @@ public class RecipeHandler implements IRecipeHandler
if( inputs.size() == 1 && inputs.get( 0 ).size() > 0 && post.size() == 1 )
{
this.data.groups.put( post.get( 0 ), new GroupIngredient( post.get( 0 ), inputs.get( 0 ) ) );
this.data.groups.put( post.get( 0 ), new GroupIngredient( post.get( 0 ), inputs.get( 0 ), 1 ) );
}
else
{
@@ -743,7 +759,7 @@ public class RecipeHandler implements IRecipeHandler
}
catch( MissedIngredientSet grp )
{
return new IngredientSet( grp.rrs );
return new IngredientSet( grp.getResolverResultSet(), qty );
}
}