BushBlock .java

net.minecraft.world.level.block.BushBlock (class): members: DEFAULT_SHAPE_HEIGHT, shapeHeight, shape, isValidBonemealTarget, isBonemealSuccess, getShape.

net.minecraft.world.level.blockclass58 linescommonextends VegetationBlock2.1 KB

Implements

API Surface (4)

VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context)
boolean isValidBonemealTarget(final LevelReader level, final BlockPos pos, final BlockState state, final BonemealSource source)
boolean isBonemealSuccess(final Level level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source)
void performBonemeal(final ServerLevel level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source)

Fields & Constants (3)

DEFAULT_SHAPE_HEIGHT
shape
shapeHeight

Full Source

BushBlock.java58 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.server.level.ServerLevel;
5
import net.minecraft.util.RandomSource;
6
import net.minecraft.world.level.BlockGetter;
7
import net.minecraft.world.level.Level;
8
import net.minecraft.world.level.LevelReader;
9
import net.minecraft.world.level.block.state.BlockBehaviour;
10
import net.minecraft.world.level.block.state.BlockState;
11
import net.minecraft.world.phys.shapes.CollisionContext;
12
import net.minecraft.world.phys.shapes.VoxelShape;
13
14
/**
15
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
16
 */
17
public class BushBlock extends VegetationBlock implements BonemealableBlock {
18
	public static final int DEFAULT_SHAPE_HEIGHT = 13;
19
	private final VoxelShape shape;
20
	private final int shapeHeight;
21
22
	/**
23
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
24
	 */
25
	public BushBlock(final BlockBehaviour.Properties properties) {
26
		this(properties, 13);
27
	}
28
29
	/**
30
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
31
	 */
32
	public BushBlock(final BlockBehaviour.Properties properties, final int shapeHeight) {
33
		super(properties);
34
		this.shapeHeight = shapeHeight;
35
		this.shape = Block.column(16.0, 0.0, shapeHeight);
36
	}
37
38
	@Override
39
	protected VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) {
40
		return this.shape;
41
	}
42
43
	@Override
44
	public boolean isValidBonemealTarget(final LevelReader level, final BlockPos pos, final BlockState state, final BonemealSource source) {
45
		return BonemealableBlock.hasSpreadableNeighbourPos(level, pos, state);
46
	}
47
48
	@Override
49
	public boolean isBonemealSuccess(final Level level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source) {
50
		return true;
51
	}
52
53
	@Override
54
	public void performBonemeal(final ServerLevel level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source) {
55
		BonemealableBlock.findSpreadableNeighbourPos(level, pos, state).ifPresent(blockPos -> level.setBlockAndUpdate(blockPos, this.defaultBlockState()));
56
	}
57
}
58

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