From a624a6e452cdb3b4a60d769102e2142087ecff29 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 23 Oct 2024 15:52:07 -0400 Subject: [PATCH] Fix crash when empty fluids are specified --- .../com/simibubi/create/foundation/fluid/FluidHelper.java | 6 ++++-- .../simibubi/create/foundation/fluid/FluidIngredient.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java index e00cbd7d3..7e47daee6 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java @@ -53,11 +53,11 @@ public class FluidHelper { public static boolean isLava(Fluid fluid) { return convertToStill(fluid) == Fluids.LAVA; } - + public static boolean isSame(FluidStack fluidStack, FluidStack fluidStack2) { return fluidStack.getFluid() == fluidStack2.getFluid(); } - + public static boolean isSame(FluidStack fluidStack, Fluid fluid) { return fluidStack.getFluid() == fluid; } @@ -147,6 +147,8 @@ public class FluidHelper { Fluid fluid = ForgeRegistries.FLUIDS.getValue(id); if (fluid == null) throw new JsonSyntaxException("Unknown fluid '" + id + "'"); + if (fluid == Fluids.EMPTY) + throw new JsonSyntaxException("Invalid empty fluid '" + id + "'"); int amount = GsonHelper.getAsInt(json, "amount"); FluidStack stack = new FluidStack(fluid, amount); diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java index ce69e7579..5672f1b83 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java @@ -124,7 +124,7 @@ public abstract class FluidIngredient implements Predicate { 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();