WaterloggedTransparentBlock .java

net.minecraft.world.level.block.WaterloggedTransparentBlock (class): members: WATERLOGGED, getFluidState, neighbourState, directionToNeighbour, ticks.

net.minecraft.world.level.blockclass66 linescommonextends TransparentBlock2.4 KB

Implements

API Surface (3)

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)
FluidState getFluidState(final BlockState state)
void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder)

Fields & Constants (8)

WATERLOGGED
state
level
ticks
pos
directionToNeighbour
neighbourPos
neighbourState

Full Source

WaterloggedTransparentBlock.java66 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.util.RandomSource;
6
import net.minecraft.world.item.context.BlockPlaceContext;
7
import net.minecraft.world.level.LevelReader;
8
import net.minecraft.world.level.ScheduledTickAccess;
9
import net.minecraft.world.level.block.state.BlockBehaviour;
10
import net.minecraft.world.level.block.state.BlockState;
11
import net.minecraft.world.level.block.state.StateDefinition;
12
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
13
import net.minecraft.world.level.block.state.properties.BooleanProperty;
14
import net.minecraft.world.level.material.FluidState;
15
import net.minecraft.world.level.material.Fluids;
16
import org.jspecify.annotations.Nullable;
17
18
/**
19
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
20
 */
21
public class WaterloggedTransparentBlock extends TransparentBlock implements SimpleWaterloggedBlock {
22
	public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
23
24
	/**
25
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
26
	 */
27
	public WaterloggedTransparentBlock(final BlockBehaviour.Properties properties) {
28
		super(properties);
29
		this.registerDefaultState(this.defaultBlockState().setValue(WATERLOGGED, false));
30
	}
31
32
	@Override
33
	public @Nullable BlockState getStateForPlacement(final BlockPlaceContext context) {
34
		FluidState replacedFluidState = context.getLevel().getFluidState(context.getClickedPos());
35
		return super.getStateForPlacement(context).setValue(WATERLOGGED, replacedFluidState.is(Fluids.WATER));
36
	}
37
38
	@Override
39
	protected BlockState updateShape(
40
		final BlockState state,
41
		final LevelReader level,
42
		final ScheduledTickAccess ticks,
43
		final BlockPos pos,
44
		final Direction directionToNeighbour,
45
		final BlockPos neighbourPos,
46
		final BlockState neighbourState,
47
		final RandomSource random
48
	) {
49
		if (state.getValue(WATERLOGGED)) {
50
			ticks.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
51
		}
52
53
		return super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random);
54
	}
55
56
	@Override
57
	protected FluidState getFluidState(final BlockState state) {
58
		return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(true) : super.getFluidState(state);
59
	}
60
61
	@Override
62
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
63
		builder.add(WATERLOGGED);
64
	}
65
}
66

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