mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Add validation to recipe registry (#4957)
This commit is contained in:
1 parent
d09a8d98d7
commit
43895d773e
6 files changed
+71
-6
No files matched your search
@@ -402,10 +402,22 @@ public class GameData
|
||||
}
|
||||
}
|
||||
|
||||
private static class RecipeCallbacks implements IForgeRegistry.MissingFactory<IRecipe>
|
||||
private static class RecipeCallbacks implements IForgeRegistry.ValidateCallback<IRecipe>, IForgeRegistry.MissingFactory<IRecipe>
|
||||
{
|
||||
static final RecipeCallbacks INSTANCE = new RecipeCallbacks();
|
||||
|
||||
@Override
|
||||
public void onValidate(IForgeRegistryInternal<IRecipe> owner, RegistryManager stage, int id, ResourceLocation key, IRecipe obj)
|
||||
{
|
||||
if (stage != RegistryManager.ACTIVE) return;
|
||||
// verify the recipe output yields a registered item
|
||||
Item item = obj.getRecipeOutput().getItem();
|
||||
if (!stage.getRegistry(Item.class).containsValue(item))
|
||||
{
|
||||
throw new IllegalStateException(String.format("Recipe %s (%s) produces unregistered item %s (%s)", key, obj, item.getRegistryName(), item));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe createMissing(ResourceLocation key, boolean isNetwork)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user