TrappedChestBlock .java

net.minecraft.world.level.block.TrappedChestBlock (class, 48 lines): members: getOpenChestStat, getDirectSignal, isSignalSource, ownSignal, newBlockEntity.

net.minecraft.world.level.blockclass48 linescommonextends ChestBlock1.7 KB

API Surface (5)

BlockEntity newBlockEntity(final BlockPos worldPosition, final BlockState blockState)
Stat<Identifier> getOpenChestStat()
boolean isSignalSource(final BlockState state)
int ownSignal(final BlockState state, final BlockGetter level, final BlockPos pos)
int getDirectSignal(final BlockState state, final BlockGetter level, final BlockPos pos, final Direction direction)

Full Source

TrappedChestBlock.java48 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.Direction;
5
import net.minecraft.resources.Identifier;
6
import net.minecraft.sounds.SoundEvents;
7
import net.minecraft.stats.Stat;
8
import net.minecraft.stats.Stats;
9
import net.minecraft.util.Mth;
10
import net.minecraft.world.level.BlockGetter;
11
import net.minecraft.world.level.block.entity.BlockEntity;
12
import net.minecraft.world.level.block.entity.BlockEntityTypes;
13
import net.minecraft.world.level.block.entity.ChestBlockEntity;
14
import net.minecraft.world.level.block.entity.TrappedChestBlockEntity;
15
import net.minecraft.world.level.block.state.BlockBehaviour;
16
import net.minecraft.world.level.block.state.BlockState;
17
18
public class TrappedChestBlock extends ChestBlock {
19
	public TrappedChestBlock(final BlockBehaviour.Properties properties) {
20
		super(() -> BlockEntityTypes.TRAPPED_CHEST, SoundEvents.CHEST_OPEN, SoundEvents.CHEST_CLOSE, properties);
21
	}
22
23
	@Override
24
	public BlockEntity newBlockEntity(final BlockPos worldPosition, final BlockState blockState) {
25
		return new TrappedChestBlockEntity(worldPosition, blockState);
26
	}
27
28
	@Override
29
	protected Stat<Identifier> getOpenChestStat() {
30
		return Stats.CUSTOM.get(Stats.TRIGGER_TRAPPED_CHEST);
31
	}
32
33
	@Override
34
	protected boolean isSignalSource(final BlockState state) {
35
		return true;
36
	}
37
38
	@Override
39
	protected int ownSignal(final BlockState state, final BlockGetter level, final BlockPos pos) {
40
		return Mth.clamp(ChestBlockEntity.getOpenCount(level, pos), 0, 15);
41
	}
42
43
	@Override
44
	protected int getDirectSignal(final BlockState state, final BlockGetter level, final BlockPos pos, final Direction direction) {
45
		return direction == Direction.UP ? state.getSignal(level, pos, direction) : 0;
46
	}
47
}
48

Decompiled Minecraft 26.3 source of TrappedChestBlock (net/minecraft/world/level/block/TrappedChestBlock.java) with Mojang official mappings, stored verbatim on the site.