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.world.level.material.Fluid;
import net.minecraft.tags.Tag;
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 dlx) {
        this.minecraft = dlx;
    }
    
    @Override
    public void render(final PoseStack dhl, final MultiBufferSource ebz, final double double3, final double double4, final double double5) {
        final BlockPos fu10 = this.minecraft.player.blockPosition();
        final LevelReader bqd11 = 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 fu11 : BlockPos.betweenClosed(fu10.offset(-10, -10, -10), fu10.offset(10, 10, 10))) {
            final FluidState cxa14 = bqd11.getFluidState(fu11);
            if (cxa14.is(FluidTags.WATER)) {
                final double double6 = fu11.getY() + cxa14.getHeight(bqd11, fu11);
                DebugRenderer.renderFilledBox(new AABB(fu11.getX() + 0.01f, fu11.getY() + 0.01f, fu11.getZ() + 0.01f, fu11.getX() + 0.99f, double6, fu11.getZ() + 0.99f).move(-double3, -double4, -double5), 1.0f, 1.0f, 1.0f, 0.2f);
            }
        }
        for (final BlockPos fu11 : BlockPos.betweenClosed(fu10.offset(-10, -10, -10), fu10.offset(10, 10, 10))) {
            final FluidState cxa14 = bqd11.getFluidState(fu11);
            if (cxa14.is(FluidTags.WATER)) {
                DebugRenderer.renderFloatingText(String.valueOf(cxa14.getAmount()), fu11.getX() + 0.5, fu11.getY() + cxa14.getHeight(bqd11, fu11), fu11.getZ() + 0.5, -16777216);
            }
        }
        RenderSystem.enableTexture();
        RenderSystem.disableBlend();
    }
}
