SnowyBlock .java

net.minecraft.world.level.block.SnowyBlock (class): members: isSnowySetting, SNOWY, neighbourState, directionToNeighbour, updateShape, neighbourPos, ticks.

net.minecraft.world.level.blockclass61 linescommonextends Block2.1 KB

API Surface (4)

BlockState updateShape(final BlockState state, final LevelReader level, final ScheduledTickAccess ticks, final BlockPos pos, final Direction directionToNeighbour, final BlockPos neighbourPos, final BlockState neighbourState, final RandomSource random)
BlockState getStateForPlacement(final BlockPlaceContext context)
boolean isSnowySetting(final BlockState aboveState)
void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder)

Fields & Constants (8)

SNOWY
state
level
ticks
pos
directionToNeighbour
neighbourPos
neighbourState

Full Source

SnowyBlock.java61 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.tags.BlockTags;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.world.item.context.BlockPlaceContext;
8
import net.minecraft.world.level.LevelReader;
9
import net.minecraft.world.level.ScheduledTickAccess;
10
import net.minecraft.world.level.block.state.BlockBehaviour;
11
import net.minecraft.world.level.block.state.BlockState;
12
import net.minecraft.world.level.block.state.StateDefinition;
13
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
14
import net.minecraft.world.level.block.state.properties.BooleanProperty;
15
16
/**
17
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
18
 */
19
public class SnowyBlock extends Block {
20
	public static final BooleanProperty SNOWY = BlockStateProperties.SNOWY;
21
22
	/**
23
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
24
	 */
25
	public SnowyBlock(final BlockBehaviour.Properties properties) {
26
		super(properties);
27
		this.registerDefaultState(this.stateDefinition.any().setValue(SNOWY, false));
28
	}
29
30
	@Override
31
	protected BlockState updateShape(
32
		final BlockState state,
33
		final LevelReader level,
34
		final ScheduledTickAccess ticks,
35
		final BlockPos pos,
36
		final Direction directionToNeighbour,
37
		final BlockPos neighbourPos,
38
		final BlockState neighbourState,
39
		final RandomSource random
40
	) {
41
		return directionToNeighbour == Direction.UP
42
			? state.setValue(SNOWY, isSnowySetting(neighbourState))
43
			: super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random);
44
	}
45
46
	@Override
47
	public BlockState getStateForPlacement(final BlockPlaceContext context) {
48
		BlockState aboveState = context.getLevel().getBlockState(context.getClickedPos().above());
49
		return this.defaultBlockState().setValue(SNOWY, isSnowySetting(aboveState));
50
	}
51
52
	protected static boolean isSnowySetting(final BlockState aboveState) {
53
		return aboveState.is(BlockTags.SNOW);
54
	}
55
56
	@Override
57
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
58
		builder.add(SNOWY);
59
	}
60
}
61

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