minecraft-source/src/net/minecraft/world/level/block/TrappedChestBlock.java

49 lines
1.6 KiB
Java

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