Skip to content

Commit

Permalink
better fluid ingredient exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Sep 16, 2024
1 parent 11787d8 commit 9cb93b5
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ else if (json.has("fluid"))

public static FluidIngredient deserialize(@Nullable JsonElement je) {
if (!isFluidIngredient(je))
throw new JsonSyntaxException("Invalid fluid ingredient: " + Objects.toString(je));
throw new JsonSyntaxException("Invalid fluid ingredient: " + je);

JsonObject json = je.getAsJsonObject();
FluidIngredient ingredient = json.has("fluidTag") ? new FluidTagIngredient() : new FluidStackIngredient();
Expand Down Expand Up @@ -176,7 +176,10 @@ protected void writeInternal(FriendlyByteBuf buffer) {

@Override
protected void readInternal(JsonObject json) {
String fluidName = GsonHelper.getAsString(json, "fluid");
FluidStack stack = FluidHelper.deserializeFluidStack(json);
if (stack.isEmpty())
throw new JsonSyntaxException("Invalid Fluid: " + fluidName);
fluid = stack.getFluid();
tagToMatch = stack.getOrCreateTag();
}
Expand Down

0 comments on commit 9cb93b5

Please sign in to comment.