mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Fix Behavior With Unknown Items in Recipes (#8105)
This commit is contained in:
1 parent
11bdf592c8
commit
1e040c9f1f
2 files changed
+14
-4
No files matched your search
@@ -38,6 +38,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.crafting.conditions.IConditionSerializer;
|
||||
@@ -156,14 +157,23 @@ public class CraftingHelper
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT)
|
||||
{
|
||||
return getItemStack(json, readNBT, false);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT, boolean disallowsAirInRecipe)
|
||||
{
|
||||
String itemName = GsonHelper.getAsString(json, "item");
|
||||
ResourceLocation itemKey = new ResourceLocation(itemName);
|
||||
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName));
|
||||
|
||||
if (item == null)
|
||||
if (!ForgeRegistries.ITEMS.containsKey(itemKey))
|
||||
throw new JsonSyntaxException("Unknown item '" + itemName + "'");
|
||||
|
||||
Item item = ForgeRegistries.ITEMS.getValue(itemKey);
|
||||
|
||||
if (disallowsAirInRecipe && item == Items.AIR)
|
||||
throw new JsonSyntaxException("Invalid item: " + itemName);
|
||||
|
||||
if (readNBT && json.has("nbt"))
|
||||
{
|
||||
// Lets hope this works? Needs test
|
||||
|
||||
Reference in new issue
Block a user