package net.minecraft.client.renderer.debug;

import net.minecraft.world.level.material.FluidState;
import java.util.Iterator;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.tags.FluidTags;
import net.minecraft.core.BlockPos;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;

public class WaterDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
    private final Minecraft minecraft;
    
    public WaterDebugRenderer(final Minecraft dbn) {
        this.minecraft = dbn;
    }
    
    @Override
    public void render(final PoseStack cyl, final MultiBufferSource dqt, final double double3, final double double4, final double double5) {
        final BlockPos fk10 = this.minecraft.player.getCommandSenderBlockPosition();
        final LevelReader bjz11 = this.minecraft.player.level;
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(0.0f, 1.0f, 0.0f, 0.75f);
        RenderSystem.disableTexture();
        RenderSystem.lineWidth(6.0f);
        for (final BlockPos fk11 : BlockPos.betweenClosed(fk10.offset(-10, -10, -10), fk10.offset(10, 10, 10))) {
            final FluidState coj14 = bjz11.getFluidState(fk11);
            if (coj14.is(FluidTags.WATER)) {
                final double double6 = fk11.getY() + coj14.getHeight(bjz11, fk11);
                DebugRenderer.renderFilledBox(new AABB(fk11.getX() + 0.01f, fk11.getY() + 0.01f, fk11.getZ() + 0.01f, fk11.getX() + 0.99f, double6, fk11.getZ() + 0.99f).move(-double3, -double4, -double5), 1.0f, 1.0f, 1.0f, 0.2f);
            }
        }
        for (final BlockPos fk11 : BlockPos.betweenClosed(fk10.offset(-10, -10, -10), fk10.offset(10, 10, 10))) {
            final FluidState coj14 = bjz11.getFluidState(fk11);
            if (coj14.is(FluidTags.WATER)) {
                DebugRenderer.renderFloatingText(String.valueOf(coj14.getAmount()), fk11.getX() + 0.5, fk11.getY() + coj14.getHeight(bjz11, fk11), fk11.getZ() + 0.5, -16777216);
            }
        }
        RenderSystem.enableTexture();
        RenderSystem.disableBlend();
    }
}
