package net.minecraft.world.level.block;

import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.stats.Stats;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.stats.Stat;
import net.minecraft.world.level.block.entity.TrappedChestBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class TrappedChestBlock extends ChestBlock {
    public TrappedChestBlock(final Properties c) {
        super(c, () -> BlockEntityType.TRAPPED_CHEST);
    }
    
    @Override
    public BlockEntity newBlockEntity(final BlockGetter bpg) {
        return new TrappedChestBlockEntity();
    }
    
    @Override
    protected Stat<ResourceLocation> getOpenChestStat() {
        return Stats.CUSTOM.get(Stats.TRIGGER_TRAPPED_CHEST);
    }
    
    @Override
    public boolean isSignalSource(final BlockState cfj) {
        return true;
    }
    
    @Override
    public int getSignal(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final Direction fz) {
        return Mth.clamp(ChestBlockEntity.getOpenCount(bpg, fu), 0, 15);
    }
    
    @Override
    public int getDirectSignal(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final Direction fz) {
        if (fz == Direction.UP) {
            return cfj.getSignal(bpg, fu, fz);
        }
        return 0;
    }
}
