Skip to content

Commit

Permalink
fix NPE with null fluids in quantum tanks (#2443)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0003296)
  • Loading branch information
TechLord22 authored and ALongStringOfNumbers committed May 7, 2024
1 parent 2f8d115 commit 71405be
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fml.relauncher.Side;
Expand Down Expand Up @@ -139,8 +140,14 @@ public static void renderChestStack(double x, double y, double z, MetaTileEntity
public static void renderTankFluid(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline,
FluidTank tank, IBlockAccess world, BlockPos pos, EnumFacing frontFacing) {
FluidStack stack = tank.getFluid();
if (stack == null || stack.amount == 0 || !ConfigHolder.client.enableFancyChestRender)
if (stack == null || stack.amount == 0 || !ConfigHolder.client.enableFancyChestRender) {
return;
}

Fluid fluid = stack.getFluid();
if (fluid == null) {
return;
}

if (world != null) {
renderState.setBrightness(world, pos);
Expand All @@ -150,15 +157,15 @@ public static void renderTankFluid(CCRenderState renderState, Matrix4 translatio
14.9375 / 16.0, 14.9375 / 16.0);

double fillFraction = (double) stack.amount / tank.getCapacity();
boolean gas = stack.getFluid().isGaseous();
boolean gas = fluid.isGaseous(stack);
if (gas) {
partialFluidBox.min.y = Math.max(13.9375 - (11.875 * fillFraction), 2.0) / 16.0;
} else {
partialFluidBox.max.y = Math.min((11.875 * fillFraction) + 2.0625, 14.0) / 16.0;
}

renderState.setFluidColour(stack);
ResourceLocation fluidStill = stack.getFluid().getStill(stack);
ResourceLocation fluidStill = fluid.getStill(stack);
TextureAtlasSprite fluidStillSprite = Minecraft.getMinecraft().getTextureMapBlocks()
.getAtlasSprite(fluidStill.toString());

Expand Down

0 comments on commit 71405be

Please sign in to comment.