package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import java.util.Random;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.phys.shapes.VoxelShape;

public class EndRodBlock extends DirectionalBlock {
    protected static final VoxelShape Y_AXIS_AABB;
    protected static final VoxelShape Z_AXIS_AABB;
    protected static final VoxelShape X_AXIS_AABB;
    
    protected EndRodBlock(final Properties c) {
        super(c);
        this.registerDefaultState(((StateHolder<O, BlockState>)this.stateDefinition.any()).<Comparable, Direction>setValue((Property<Comparable>)EndRodBlock.FACING, Direction.UP));
    }
    
    @Override
    public BlockState rotate(final BlockState cfj, final Rotation cap) {
        return ((StateHolder<O, BlockState>)cfj).<Comparable, Direction>setValue((Property<Comparable>)EndRodBlock.FACING, cap.rotate(cfj.<Direction>getValue((Property<Direction>)EndRodBlock.FACING)));
    }
    
    @Override
    public BlockState mirror(final BlockState cfj, final Mirror bzj) {
        return ((StateHolder<O, BlockState>)cfj).<Comparable, Direction>setValue((Property<Comparable>)EndRodBlock.FACING, bzj.mirror(cfj.<Direction>getValue((Property<Direction>)EndRodBlock.FACING)));
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        switch (cfj.<Direction>getValue((Property<Direction>)EndRodBlock.FACING).getAxis()) {
            default: {
                return EndRodBlock.X_AXIS_AABB;
            }
            case Z: {
                return EndRodBlock.Z_AXIS_AABB;
            }
            case Y: {
                return EndRodBlock.Y_AXIS_AABB;
            }
        }
    }
    
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bin) {
        final Direction fz3 = bin.getClickedFace();
        final BlockState cfj4 = bin.getLevel().getBlockState(bin.getClickedPos().relative(fz3.getOpposite()));
        if (cfj4.is(this) && cfj4.<Comparable>getValue((Property<Comparable>)EndRodBlock.FACING) == fz3) {
            return ((StateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Direction>setValue((Property<Comparable>)EndRodBlock.FACING, fz3.getOpposite());
        }
        return ((StateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Direction>setValue((Property<Comparable>)EndRodBlock.FACING, fz3);
    }
    
    @Override
    public void animateTick(final BlockState cfj, final Level bqb, final BlockPos fu, final Random random) {
        final Direction fz6 = cfj.<Direction>getValue((Property<Direction>)EndRodBlock.FACING);
        final double double7 = fu.getX() + 0.55 - random.nextFloat() * 0.1f;
        final double double8 = fu.getY() + 0.55 - random.nextFloat() * 0.1f;
        final double double9 = fu.getZ() + 0.55 - random.nextFloat() * 0.1f;
        final double double10 = 0.4f - (random.nextFloat() + random.nextFloat()) * 0.4f;
        if (random.nextInt(5) == 0) {
            bqb.addParticle(ParticleTypes.END_ROD, double7 + fz6.getStepX() * double10, double8 + fz6.getStepY() * double10, double9 + fz6.getStepZ() * double10, random.nextGaussian() * 0.005, random.nextGaussian() * 0.005, random.nextGaussian() * 0.005);
        }
    }
    
    @Override
    protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
        a.add(EndRodBlock.FACING);
    }
    
    @Override
    public PushReaction getPistonPushReaction(final BlockState cfj) {
        return PushReaction.NORMAL;
    }
    
    @Override
    public boolean isPathfindable(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final PathComputationType czg) {
        return false;
    }
    
    static {
        Y_AXIS_AABB = Block.box(6.0, 0.0, 6.0, 10.0, 16.0, 10.0);
        Z_AXIS_AABB = Block.box(6.0, 6.0, 0.0, 10.0, 10.0, 16.0);
        X_AXIS_AABB = Block.box(0.0, 6.0, 6.0, 16.0, 10.0, 10.0);
    }
}
