package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.StateDefinition;
import java.util.Iterator;
import java.util.List;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.player.Player;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.material.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.properties.BooleanProperty;

public class PressurePlateBlock extends BasePressurePlateBlock {
    public static final BooleanProperty POWERED;
    private final Sensitivity sensitivity;
    
    protected PressurePlateBlock(final Sensitivity a, final Properties c) {
        super(c);
        this.registerDefaultState(((StateHolder<O, BlockState>)this.stateDefinition.any()).<Comparable, Boolean>setValue((Property<Comparable>)PressurePlateBlock.POWERED, false));
        this.sensitivity = a;
    }
    
    @Override
    protected int getSignalForState(final BlockState cfj) {
        return cfj.<Boolean>getValue((Property<Boolean>)PressurePlateBlock.POWERED) ? 15 : 0;
    }
    
    @Override
    protected BlockState setSignalForState(final BlockState cfj, final int integer) {
        return ((StateHolder<O, BlockState>)cfj).<Comparable, Boolean>setValue((Property<Comparable>)PressurePlateBlock.POWERED, integer > 0);
    }
    
    @Override
    protected void playOnSound(final LevelAccessor bqc, final BlockPos fu) {
        if (this.material == Material.WOOD || this.material == Material.NETHER_WOOD) {
            bqc.playSound(null, fu, SoundEvents.WOODEN_PRESSURE_PLATE_CLICK_ON, SoundSource.BLOCKS, 0.3f, 0.8f);
        }
        else {
            bqc.playSound(null, fu, SoundEvents.STONE_PRESSURE_PLATE_CLICK_ON, SoundSource.BLOCKS, 0.3f, 0.6f);
        }
    }
    
    @Override
    protected void playOffSound(final LevelAccessor bqc, final BlockPos fu) {
        if (this.material == Material.WOOD || this.material == Material.NETHER_WOOD) {
            bqc.playSound(null, fu, SoundEvents.WOODEN_PRESSURE_PLATE_CLICK_OFF, SoundSource.BLOCKS, 0.3f, 0.7f);
        }
        else {
            bqc.playSound(null, fu, SoundEvents.STONE_PRESSURE_PLATE_CLICK_OFF, SoundSource.BLOCKS, 0.3f, 0.5f);
        }
    }
    
    @Override
    protected int getSignalStrength(final Level bqb, final BlockPos fu) {
        final AABB deg4 = PressurePlateBlock.TOUCH_AABB.move(fu);
        List<? extends Entity> list5 = null;
        switch (this.sensitivity) {
            case EVERYTHING: {
                list5 = bqb.getEntities(null, deg4);
                break;
            }
            case MOBS: {
                list5 = bqb.getEntitiesOfClass(LivingEntity.class, deg4);
                break;
            }
            default: {
                return 0;
            }
        }
        if (!list5.isEmpty()) {
            for (final Entity aom7 : list5) {
                if (!aom7.isIgnoringBlockTriggers()) {
                    return 15;
                }
            }
        }
        return 0;
    }
    
    @Override
    protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
        a.add(PressurePlateBlock.POWERED);
    }
    
    static {
        POWERED = BlockStateProperties.POWERED;
    }
    
    public enum Sensitivity {
        EVERYTHING, 
        MOBS;
    }
}
