HeavyCoreBlock .java

net.minecraft.world.level.block.HeavyCoreBlock (class, 74 lines): members: WATERLOGGED, getFluidState, isPathfindable, SHAPE, neighbourState, updateShape.

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

Implements

API Surface (6)

void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder)
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)
BlockState getStateForPlacement(final BlockPlaceContext context)
VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context)
boolean isPathfindable(final BlockState state, final PathComputationType type)

Fields & Constants (9)

WATERLOGGED
SHAPE
state
level
ticks
pos
directionToNeighbour
neighbourPos
neighbourState

Full Source

HeavyCoreBlock.java74 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.BlockGetter;
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
import net.minecraft.world.level.material.FluidState;
16
import net.minecraft.world.level.material.Fluids;
17
import net.minecraft.world.level.pathfinder.PathComputationType;
18
import net.minecraft.world.phys.shapes.CollisionContext;
19
import net.minecraft.world.phys.shapes.VoxelShape;
20
21
public class HeavyCoreBlock extends Block implements SimpleWaterloggedBlock {
22
	public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
23
	private static final VoxelShape SHAPE = Block.column(8.0, 0.0, 8.0);
24
25
	public HeavyCoreBlock(final BlockBehaviour.Properties properties) {
26
		super(properties);
27
		this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false));
28
	}
29
30
	@Override
31
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
32
		builder.add(WATERLOGGED);
33
	}
34
35
	@Override
36
	protected BlockState updateShape(
37
		final BlockState state,
38
		final LevelReader level,
39
		final ScheduledTickAccess ticks,
40
		final BlockPos pos,
41
		final Direction directionToNeighbour,
42
		final BlockPos neighbourPos,
43
		final BlockState neighbourState,
44
		final RandomSource random
45
	) {
46
		if (state.getValue(WATERLOGGED)) {
47
			ticks.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
48
		}
49
50
		return super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random);
51
	}
52
53
	@Override
54
	protected FluidState getFluidState(final BlockState state) {
55
		return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
56
	}
57
58
	@Override
59
	public BlockState getStateForPlacement(final BlockPlaceContext context) {
60
		FluidState replacedFluidState = context.getLevel().getFluidState(context.getClickedPos());
61
		return this.defaultBlockState().setValue(WATERLOGGED, replacedFluidState.is(Fluids.WATER));
62
	}
63
64
	@Override
65
	protected VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) {
66
		return SHAPE;
67
	}
68
69
	@Override
70
	protected boolean isPathfindable(final BlockState state, final PathComputationType type) {
71
		return false;
72
	}
73
}
74

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