MangroveRootsBlock .java

net.minecraft.world.level.block.MangroveRootsBlock (class, 72 lines): members: skipRendering, WATERLOGGED, getFluidState, neighbourState, updateShape.

net.minecraft.world.level.blockclass72 linescommonextends Block2.7 KB

Implements

API Surface (4)

boolean skipRendering(final BlockState state, final BlockState neighborState, final Direction direction)
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

MangroveRootsBlock.java72 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 MangroveRootsBlock extends Block 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 MangroveRootsBlock(final BlockBehaviour.Properties properties) {
28
		super(properties);
29
		this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false));
30
	}
31
32
	@Override
33
	protected boolean skipRendering(final BlockState state, final BlockState neighborState, final Direction direction) {
34
		return neighborState.is(Blocks.MANGROVE_ROOTS) && direction.getAxis() == Direction.Axis.Y;
35
	}
36
37
	@Override
38
	public @Nullable BlockState getStateForPlacement(final BlockPlaceContext context) {
39
		FluidState replacedFluidState = context.getLevel().getFluidState(context.getClickedPos());
40
		boolean isWaterSource = replacedFluidState.is(Fluids.WATER);
41
		return super.getStateForPlacement(context).setValue(WATERLOGGED, isWaterSource);
42
	}
43
44
	@Override
45
	protected BlockState updateShape(
46
		final BlockState state,
47
		final LevelReader level,
48
		final ScheduledTickAccess ticks,
49
		final BlockPos pos,
50
		final Direction directionToNeighbour,
51
		final BlockPos neighbourPos,
52
		final BlockState neighbourState,
53
		final RandomSource random
54
	) {
55
		if (state.getValue(WATERLOGGED)) {
56
			ticks.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
57
		}
58
59
		return super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random);
60
	}
61
62
	@Override
63
	protected FluidState getFluidState(final BlockState state) {
64
		return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
65
	}
66
67
	@Override
68
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
69
		builder.add(WATERLOGGED);
70
	}
71
}
72

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