package net.minecraft.world.level.block;

import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.core.Direction;

public abstract class GrowingPlantBlock extends Block {
    protected final Direction growthDirection;
    protected final boolean scheduleFluidTicks;
    protected final VoxelShape shape;
    
    protected GrowingPlantBlock(final Properties c, final Direction fz, final VoxelShape dfg, final boolean boolean4) {
        super(c);
        this.growthDirection = fz;
        this.shape = dfg;
        this.scheduleFluidTicks = boolean4;
    }
    
    @Override
    public boolean canSurvive(final BlockState cfj, final LevelReader bqd, final BlockPos fu) {
        final BlockPos fu2 = fu.relative(this.growthDirection.getOpposite());
        final BlockState cfj2 = bqd.getBlockState(fu2);
        final Block bvr7 = cfj2.getBlock();
        return this.canAttachToBlock(bvr7) && (bvr7 == this.getHeadBlock() || bvr7 == this.getBodyBlock() || cfj2.isFaceSturdy(bqd, fu2, this.growthDirection));
    }
    
    protected boolean canAttachToBlock(final Block bvr) {
        return true;
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return this.shape;
    }
    
    protected abstract GrowingPlantHeadBlock getHeadBlock();
    
    protected abstract Block getBodyBlock();
}
