Skip to content

Commit

Permalink
Merge pull request Creators-of-Create#6952 from IThundxr/mc1.18/fluid…
Browse files Browse the repository at this point in the history
…stack-ingredient-crash-fix

Better FluidIngredient exception handling
  • Loading branch information
simibubi authored Oct 23, 2024
2 parents b7f272c + a624a6e commit d39f899
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public static boolean isWater(Fluid fluid) {
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;
}
Expand Down Expand Up @@ -147,6 +147,8 @@ public static FluidStack deserializeFluidStack(JsonObject json) {
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);

Expand Down
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

0 comments on commit d39f899

Please sign in to comment.