SmokerBlock .java

net.minecraft.world.level.block.SmokerBlock (class): members: openContainer, getTicker, newBlockEntity, animateTick. imports: SmokerBlockEntity, Stats.

net.minecraft.world.level.blockclass65 linescommonextends AbstractFurnaceBlock2.3 KB

API Surface (3)

BlockEntity newBlockEntity(final BlockPos worldPosition, final BlockState blockState)
void openContainer(final Level level, final BlockPos pos, final Player player)
void animateTick(final BlockState state, final Level level, final BlockPos pos, final RandomSource random)

Full Source

SmokerBlock.java65 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.particles.ParticleTypes;
5
import net.minecraft.sounds.SoundEvents;
6
import net.minecraft.sounds.SoundSource;
7
import net.minecraft.stats.Stats;
8
import net.minecraft.util.RandomSource;
9
import net.minecraft.world.MenuProvider;
10
import net.minecraft.world.entity.player.Player;
11
import net.minecraft.world.level.Level;
12
import net.minecraft.world.level.block.entity.BlockEntity;
13
import net.minecraft.world.level.block.entity.BlockEntityTicker;
14
import net.minecraft.world.level.block.entity.BlockEntityType;
15
import net.minecraft.world.level.block.entity.BlockEntityTypes;
16
import net.minecraft.world.level.block.entity.SmokerBlockEntity;
17
import net.minecraft.world.level.block.state.BlockBehaviour;
18
import net.minecraft.world.level.block.state.BlockState;
19
import org.jspecify.annotations.Nullable;
20
21
/**
22
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
23
 */
24
public class SmokerBlock extends AbstractFurnaceBlock {
25
	/**
26
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
27
	 */
28
	public SmokerBlock(final BlockBehaviour.Properties properties) {
29
		super(properties);
30
	}
31
32
	@Override
33
	public BlockEntity newBlockEntity(final BlockPos worldPosition, final BlockState blockState) {
34
		return new SmokerBlockEntity(worldPosition, blockState);
35
	}
36
37
	@Override
38
	public <T extends BlockEntity> @Nullable BlockEntityTicker<T> getTicker(final Level level, final BlockState blockState, final BlockEntityType<T> type) {
39
		return createFurnaceTicker(level, type, BlockEntityTypes.SMOKER);
40
	}
41
42
	@Override
43
	protected void openContainer(final Level level, final BlockPos pos, final Player player) {
44
		BlockEntity blockEntity = level.getBlockEntity(pos);
45
		if (blockEntity instanceof SmokerBlockEntity) {
46
			player.openMenu((MenuProvider)blockEntity);
47
			player.awardStat(Stats.INTERACT_WITH_SMOKER);
48
		}
49
	}
50
51
	@Override
52
	public void animateTick(final BlockState state, final Level level, final BlockPos pos, final RandomSource random) {
53
		if (state.getValue(LIT)) {
54
			double x = pos.getX() + 0.5;
55
			double y = pos.getY();
56
			double z = pos.getZ() + 0.5;
57
			if (random.nextDouble() < 0.1) {
58
				level.playLocalSound(x, y, z, SoundEvents.SMOKER_SMOKE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
59
			}
60
61
			level.addParticle(ParticleTypes.SMOKE, x, y + 1.1, z, 0.0, 0.0, 0.0);
62
		}
63
	}
64
}
65

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