mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-30 06:45:03 +01:00
Fix crash when empty fluids are specified
This commit is contained in:
parent
51bb416b0e
commit
a624a6e452
2 changed files with 5 additions and 3 deletions
|
@ -53,11 +53,11 @@ public class FluidHelper {
|
||||||
public static boolean isLava(Fluid fluid) {
|
public static boolean isLava(Fluid fluid) {
|
||||||
return convertToStill(fluid) == Fluids.LAVA;
|
return convertToStill(fluid) == Fluids.LAVA;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSame(FluidStack fluidStack, FluidStack fluidStack2) {
|
public static boolean isSame(FluidStack fluidStack, FluidStack fluidStack2) {
|
||||||
return fluidStack.getFluid() == fluidStack2.getFluid();
|
return fluidStack.getFluid() == fluidStack2.getFluid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSame(FluidStack fluidStack, Fluid fluid) {
|
public static boolean isSame(FluidStack fluidStack, Fluid fluid) {
|
||||||
return fluidStack.getFluid() == fluid;
|
return fluidStack.getFluid() == fluid;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,8 @@ public class FluidHelper {
|
||||||
Fluid fluid = ForgeRegistries.FLUIDS.getValue(id);
|
Fluid fluid = ForgeRegistries.FLUIDS.getValue(id);
|
||||||
if (fluid == null)
|
if (fluid == null)
|
||||||
throw new JsonSyntaxException("Unknown fluid '" + id + "'");
|
throw new JsonSyntaxException("Unknown fluid '" + id + "'");
|
||||||
|
if (fluid == Fluids.EMPTY)
|
||||||
|
throw new JsonSyntaxException("Invalid empty fluid '" + id + "'");
|
||||||
int amount = GsonHelper.getAsInt(json, "amount");
|
int amount = GsonHelper.getAsInt(json, "amount");
|
||||||
FluidStack stack = new FluidStack(fluid, 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) {
|
public static FluidIngredient deserialize(@Nullable JsonElement je) {
|
||||||
if (!isFluidIngredient(je))
|
if (!isFluidIngredient(je))
|
||||||
throw new JsonSyntaxException("Invalid fluid ingredient: " + Objects.toString(je));
|
throw new JsonSyntaxException("Invalid fluid ingredient: " + je);
|
||||||
|
|
||||||
JsonObject json = je.getAsJsonObject();
|
JsonObject json = je.getAsJsonObject();
|
||||||
FluidIngredient ingredient = json.has("fluidTag") ? new FluidTagIngredient() : new FluidStackIngredient();
|
FluidIngredient ingredient = json.has("fluidTag") ? new FluidTagIngredient() : new FluidStackIngredient();
|
||||||
|
|
Loading…
Reference in a new issue