package net.minecraft.world.level.material;

import net.minecraft.core.Registry;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.core.Direction;
import net.minecraft.tags.Tag;
import javax.annotation.Nullable;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import java.util.Random;
import net.minecraft.world.level.Level;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import com.mojang.serialization.MapCodec;
import net.minecraft.world.level.block.state.properties.Property;
import com.google.common.collect.ImmutableMap;
import com.mojang.serialization.Codec;
import net.minecraft.world.level.block.state.StateHolder;

public final class FluidState extends StateHolder<Fluid, FluidState> {
    public static final Codec<FluidState> CODEC;
    
    public FluidState(final Fluid cwz, final ImmutableMap<Property<?>, Comparable<?>> immutableMap, final MapCodec<FluidState> mapCodec) {
        super(cwz, immutableMap, mapCodec);
    }
    
    public Fluid getType() {
        return (Fluid)this.owner;
    }
    
    public boolean isSource() {
        return this.getType().isSource(this);
    }
    
    public boolean isEmpty() {
        return this.getType().isEmpty();
    }
    
    public float getHeight(final BlockGetter bpg, final BlockPos fu) {
        return this.getType().getHeight(this, bpg, fu);
    }
    
    public float getOwnHeight() {
        return this.getType().getOwnHeight(this);
    }
    
    public int getAmount() {
        return this.getType().getAmount(this);
    }
    
    public boolean shouldRenderBackwardUpFace(final BlockGetter bpg, final BlockPos fu) {
        for (int integer4 = -1; integer4 <= 1; ++integer4) {
            for (int integer5 = -1; integer5 <= 1; ++integer5) {
                final BlockPos fu2 = fu.offset(integer4, 0, integer5);
                final FluidState cxa7 = bpg.getFluidState(fu2);
                if (!cxa7.getType().isSame(this.getType()) && !bpg.getBlockState(fu2).isSolidRender(bpg, fu2)) {
                    return true;
                }
            }
        }
        return false;
    }
    
    public void tick(final Level bqb, final BlockPos fu) {
        this.getType().tick(bqb, fu, this);
    }
    
    public void animateTick(final Level bqb, final BlockPos fu, final Random random) {
        this.getType().animateTick(bqb, fu, this, random);
    }
    
    public boolean isRandomlyTicking() {
        return this.getType().isRandomlyTicking();
    }
    
    public void randomTick(final Level bqb, final BlockPos fu, final Random random) {
        this.getType().randomTick(bqb, fu, this, random);
    }
    
    public Vec3 getFlow(final BlockGetter bpg, final BlockPos fu) {
        return this.getType().getFlow(bpg, fu, this);
    }
    
    public BlockState createLegacyBlock() {
        return this.getType().createLegacyBlock(this);
    }
    
    @Nullable
    public ParticleOptions getDripParticle() {
        return this.getType().getDripParticle();
    }
    
    public boolean is(final Tag<Fluid> adf) {
        return this.getType().is(adf);
    }
    
    public float getExplosionResistance() {
        return this.getType().getExplosionResistance();
    }
    
    public boolean canBeReplacedWith(final BlockGetter bpg, final BlockPos fu, final Fluid cwz, final Direction fz) {
        return this.getType().canBeReplacedWith(this, bpg, fu, cwz, fz);
    }
    
    public VoxelShape getShape(final BlockGetter bpg, final BlockPos fu) {
        return this.getType().getShape(this, bpg, fu);
    }
    
    static {
        CODEC = StateHolder.<Object, FluidState>codec((com.mojang.serialization.Codec<Object>)Registry.FLUID, Fluid::defaultFluidState).stable();
    }
}
