@@ -0,0 +1,2099 @@
+package info.u_team.u_team_core.util;%0A%0Aimport com.google.gson.*;%0A%0Aimport info.u_team.u_team_core.ingredient.FluidIngredient;%0Aimport net.minecraft.item.*;%0Aimport net.minecraft.item.crafting.Ingredient;%0Aimport net.minecraft.util.ResourceLocation;%0Aimport net.minecraftforge.common.crafting.CraftingHelper;%0Aimport net.minecraftforge.registries.ForgeRegistries;%0A%0Apublic class SerializeUtil %7B%0A%09%0A%09public static JsonElement serializeItemIngredient(Ingredient ingredient) %7B%0A%09%09return ingredient.serialize();%0A%09%7D%0A%09%0A%09public static Ingredient deserializeItemIngredient(JsonElement json) %7B%0A%09%09return Ingredient.deserialize(json);%0A%09%7D%0A%09%0A%09public static JsonElement serializeFluidIngredient(FluidIngredient ingredient) %7B%0A%09%09return ingredient.serialize();%0A%09%7D%0A%09%0A%09public static FluidIngredient deserializeFluidIngredient(JsonElement json) %7B%0A%09%09return FluidIngredient.deserialize(json);%0A%09%7D%0A%09%0A%09public static JsonElement serializeItemStack(ItemStack stack) %7B%0A%09%09final String itemName = ForgeRegistries.ITEMS.getKey(stack.getItem()).toString();%0A%09%09final int count = stack.getCount();%0A%09%09if (stack.hasTag() %7C%7C count != 1) %7B%0A%09%09%09final JsonObject object = new JsonObject();%0A%09%09%09object.addProperty(%22item%22, itemName);%0A%09%09%09if (count != 1) %7B%0A%09%09%09%09object.addProperty(%22count%22, stack.getCount());%0A%09%09%09%7D%0A%09%09%09if (stack.hasTag()) %7B%0A%09%09%09%09object.addProperty(%22nbt%22, stack.getTag().toString());%0A%09%09%09%7D%0A%09%09%09return object;%0A%09%09%7D else %7B%0A%09%09%09return new JsonPrimitive(itemName);%0A%09%09%7D%0A%09%7D%0A%09%0A%09public static ItemStack deserializeItemStack(JsonElement json) %7B%0A%09%09if (json != null && !json.isJsonNull()) %7B%0A%09%09%09if (json.isJsonObject()) %7B%0A%09%09%09%09return CraftingHelper.getItemStack(json.getAsJsonObject(), true);%0A%09%09%09%7D else if (json.isJsonPrimitive()) %7B%0A%09%09%09%09final Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(json.getAsString()));%0A%09%09%09%09if (item == null) %7B%0A%09%09%09%09%09throw new IllegalStateException(%22Item: %22 + json.getAsString() + %22 does not exist%22);%0A%09%09%09%09%7D%0A%09%09%09%09return new ItemStack(item);%0A%09%09%09%7D else %7B%0A%09%09%09%09throw new JsonSyntaxException(%22Expected item to be object or array of objects%22);%0A%09%09%09%7D%0A%09%09%7D else %7B%0A%09%09%09throw new JsonSyntaxException(%22Item cannot be null%22);%0A%09%09%7D%0A%09%7D%0A%09%0A%7D%0A

Add serialize util