Merge pull request #6952 from IThundxr/mc1.18/fluidstack-ingredient-crash-fix

Better FluidIngredient exception handling
This commit is contained in:
simibubi 2024-10-23 21:53:31 +02:00 committed by GitHub
commit d39f89983a
Failed to generate hash of commit
2 changed files with 5 additions and 3 deletions

View file

@ -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);

View file

@ -124,7 +124,7 @@ public abstract class FluidIngredient implements Predicate<FluidStack> {
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();