Fixed recipe crash when another mod registers a wooden gear.
I'll have to go through every other recipe later.
This commit is contained in:
@@ -25,6 +25,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -36,7 +37,9 @@ import com.google.common.collect.HashMultimap;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.IConditionFactory;
|
||||
import net.minecraftforge.common.crafting.IIngredientFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
@@ -763,6 +766,17 @@ public class RecipeHandler implements IRecipeHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class MaterialExists implements IConditionFactory
|
||||
{
|
||||
@Override
|
||||
public BooleanSupplier parse( JsonContext jsonContext, JsonObject jsonObject ) {
|
||||
String material = JsonUtils.getString( jsonObject, "material" );
|
||||
Object result = (Object) Api.INSTANCE.registries().recipes().resolveItem( AppEng.MOD_ID, material );
|
||||
return () -> result != null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class PartFactory implements IIngredientFactory
|
||||
{
|
||||
|
||||
|
||||
@@ -47,12 +47,7 @@ public class PartShapelessCraftingFactory extends ShapelessOreRecipe
|
||||
|
||||
String ingredient = resultObject.get( "part" ).getAsString();
|
||||
Object result = (Object) Api.INSTANCE.registries().recipes().resolveItem( AppEng.MOD_ID, ingredient );
|
||||
if( result instanceof ResolverResultSet )
|
||||
{
|
||||
ResolverResultSet resolverResultSet = (ResolverResultSet) result;
|
||||
return new PartShapelessCraftingFactory(group.isEmpty() ? null : new ResourceLocation(group), ings, resolverResultSet.results.toArray( new ItemStack[resolverResultSet.results.size()] )[0]);
|
||||
}
|
||||
else if( result instanceof ResolverResult )
|
||||
if( result instanceof ResolverResult )
|
||||
{
|
||||
ResolverResult resolverResult = (ResolverResult) result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user