Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better FluidIngredient exception handling #6952

Open
wants to merge 1 commit into
base: mc1.18/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,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 @@ -123,6 +123,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 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