mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-05 03:22:37 +01:00
Merge pull request #6952 from IThundxr/mc1.18/fluidstack-ingredient-crash-fix
Better FluidIngredient exception handling
This commit is contained in:
commit
d39f89983a
2 changed files with 5 additions and 3 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue