68 lines
2.2 KiB
Java
68 lines
2.2 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.serialization.MapCodec
|
|
*/
|
|
package net.minecraft.world.level.block;
|
|
|
|
import com.mojang.serialization.MapCodec;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.stats.Stat;
|
|
import net.minecraft.stats.Stats;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.block.ChestBlock;
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
|
import net.minecraft.world.level.block.entity.TrappedChestBlockEntity;
|
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
public class TrappedChestBlock
|
|
extends ChestBlock {
|
|
public static final MapCodec<TrappedChestBlock> CODEC = TrappedChestBlock.simpleCodec(TrappedChestBlock::new);
|
|
|
|
@Override
|
|
public MapCodec<TrappedChestBlock> codec() {
|
|
return CODEC;
|
|
}
|
|
|
|
public TrappedChestBlock(BlockBehaviour.Properties properties) {
|
|
super(() -> BlockEntityType.TRAPPED_CHEST, SoundEvents.CHEST_OPEN, SoundEvents.CHEST_CLOSE, properties);
|
|
}
|
|
|
|
@Override
|
|
public BlockEntity newBlockEntity(BlockPos worldPosition, BlockState blockState) {
|
|
return new TrappedChestBlockEntity(worldPosition, blockState);
|
|
}
|
|
|
|
@Override
|
|
protected Stat<Identifier> getOpenChestStat() {
|
|
return Stats.CUSTOM.get(Stats.TRIGGER_TRAPPED_CHEST);
|
|
}
|
|
|
|
@Override
|
|
protected boolean isSignalSource(BlockState state) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
protected int getSignal(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
|
return Mth.clamp(ChestBlockEntity.getOpenCount(level, pos), 0, 15);
|
|
}
|
|
|
|
@Override
|
|
protected int getDirectSignal(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
|
if (direction == Direction.UP) {
|
|
return state.getSignal(level, pos, direction);
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
|