Skip to content

Commit a2d8178

Browse files
committed
Fix crash when serializing empty JSON ingredients.
1 parent d696438 commit a2d8178

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Common/src/main/java/net/darkhax/bookshelf/api/serialization/SerializerIngredient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.darkhax.bookshelf.api.serialization;
22

3+
import com.google.gson.JsonArray;
34
import com.google.gson.JsonElement;
45
import net.minecraft.nbt.Tag;
56
import net.minecraft.network.FriendlyByteBuf;
@@ -16,6 +17,12 @@ private SerializerIngredient() {
1617
@Override
1718
public Ingredient fromJSON(JsonElement json) {
1819

20+
// Support Empty Ingredient
21+
if (json instanceof JsonArray array && array.isEmpty()) {
22+
23+
return Ingredient.EMPTY;
24+
}
25+
1926
return Ingredient.fromJson(json);
2027
}
2128

0 commit comments

Comments
 (0)