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 9cb93b5 commit 1f5d977
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
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 @@ -176,10 +176,7 @@ 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 1f5d977

Please sign in to comment.