package net.minecraft.world.phys.shapes;

import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.item.Items;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.material.Fluid;
import java.util.function.Predicate;
import net.minecraft.world.item.Item;

public class EntityCollisionContext implements CollisionContext {
    protected static final CollisionContext EMPTY;
    private final boolean descending;
    private final double entityBottom;
    private final Item heldItem;
    private final Predicate<Fluid> canStandOnFluid;
    
    protected EntityCollisionContext(final boolean boolean1, final double double2, final Item bke, final Predicate<Fluid> predicate) {
        this.descending = boolean1;
        this.entityBottom = double2;
        this.heldItem = bke;
        this.canStandOnFluid = predicate;
    }
    
    @Deprecated
    protected EntityCollisionContext(final Entity aom) {
        this(aom.isDescending(), aom.getY(), (aom instanceof LivingEntity) ? ((LivingEntity)aom).getMainHandItem().getItem() : Items.AIR, (aom instanceof LivingEntity) ? (LivingEntity)aom::canStandOnFluid : (cwz -> false));
    }
    
    @Override
    public boolean isHoldingItem(final Item bke) {
        return this.heldItem == bke;
    }
    
    @Override
    public boolean canStandOnFluid(final FluidState cxa, final FlowingFluid cwy) {
        return this.canStandOnFluid.test(cwy) && !cxa.getType().isSame(cwy);
    }
    
    @Override
    public boolean isDescending() {
        return this.descending;
    }
    
    @Override
    public boolean isAbove(final VoxelShape dfg, final BlockPos fu, final boolean boolean3) {
        return this.entityBottom > fu.getY() + dfg.max(Direction.Axis.Y) - 9.999999747378752E-6;
    }
    
    static {
        EMPTY = new EntityCollisionContext(false, -1.7976931348623157E308, Items.AIR, cwz -> false) {
            @Override
            public boolean isAbove(final VoxelShape dfg, final BlockPos fu, final boolean boolean3) {
                return boolean3;
            }
        };
    }
}
