package xyz.brassgoggledcoders.steamagerevolution.modules.storage.multiblock.tank;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fml.common.FMLLog;
import xyz.brassgoggledcoders.steamagerevolution.utils.RenderUtil;

public class MultiblockTankRenderer extends TileEntitySpecialRenderer<TileEntityTankCasing> {

	protected static Minecraft mc = Minecraft.getMinecraft();

	@Override
	public void render(TileEntityTankCasing tile, double x, double y, double z, float partialTicks, int destroyStage,
			float alpha) {
		// RE last check - ensures we only render once. Save delegate should be at reference coord - lowest x,y,z etc -
		// so should always be casing.
		if(tile.isConnected() && tile.getMultiblockController().isAssembled() && tile.isMultiblockSaveDelegate()) {
			ControllerTank t = tile.getMultiblockController();
			FluidTank tank = t.tank;
			FluidStack fluid = tank.getFluid();

			if(fluid != null) {
				// FMLLog.warning("Fluid is not null");
				float d = RenderUtil.FLUID_OFFSET;
				int yd = 1 + Math.max(0, t.maximumInteriorPos.getY() - t.maximumInteriorPos.getY());
				int height = yd * 1000 - (int) (d * 2000d);
				FMLLog.warning("Trying render" + height);
				RenderUtil.renderStackedFluidCuboid(fluid, x, y, z, tile.getPos(), t.minimumInteriorPos,
						t.maximumInteriorPos, d, height);
				// RenderUtil.renderFluidCuboid(liquid, tile.getPos(), x, y, z, d, d, d, 1d - d, height - d, 1d - d);
			}
		}
	}
}
@@ -191,16 +191,57 @@
 nderer;%0A
+import net.minecraft.util.math.BlockPos;%0A
 import n
@@ -325,53 +325,8 @@
 nk;%0A
-import net.minecraftforge.fml.common.FMLLog;%0A
 impo
@@ -1070,73 +1070,461 @@
 ();%0A
-%0A
 %09%09%09
-if(fluid != null) %7B%0A%09%09%09%09// FMLLog.warning(%22Fluid is not null%22
+double x1 = t.minimumInteriorPos.getX() - tile.getPos().getX();%0A%09%09%09double y1 = t.minimumInteriorPos.getY() - tile.getPos().getY();%0A%09%09%09double z1 = t.minimumInteriorPos.getZ() - tile.getPos().getZ();%0A%0A%09%09%09double x2 = t.maximumInteriorPos.getX() - tile.getPos().getX();%0A%09%09%09double z2 = t.maximumInteriorPos.getZ() - tile.getPos().getZ();%0A%0A%09%09%09if(fluid != null) %7B%0A%09%09%09%09BlockPos minPos = new BlockPos(x1, y1, z1);%0A%09%09%09%09BlockPos maxPos = new BlockPos(x2, y1, z2
 );%0A%09
@@ -1619,26 +1619,26 @@
 getY() - t.m
-ax
+in
 imumInterior
@@ -1654,19 +1654,22 @@
 ));%0A%09%09%09%09
-int
+double
  height 
@@ -1674,83 +1674,66 @@
 t = 
-yd * 1000 - (int) (d * 2000d);%0A%09%09%09%09FMLLog.warning(%22Trying render%22 + height)
+(((float) fluid.amount / (float) tank.getCapacity())) / yd
 ;%0A%09%09
@@ -1805,169 +1805,33 @@
 (), 
-t.
 min
-imumInteriorPos,%0A%09%09%09%09%09%09t.maximumInteriorPos, d, height);%0A%09%09%09%09// RenderUtil.renderFluidCuboid(liquid, tile.getPos(), x, y, z, d, d, d, 1d - d, height - d, 1d
+Pos, maxPos, d, height
  - d

Fix multiblock tank fluid rendering