TallGrassBlock .java

net.minecraft.world.level.block.TallGrassBlock (class, 51 lines): members: isValidBonemealTarget, isBonemealSuccess, performBonemeal, SHAPE, getShape.

net.minecraft.world.level.blockclass51 linescommonextends VegetationBlock2.0 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 (1)

SHAPE

Full Source

TallGrassBlock.java51 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 TallGrassBlock extends VegetationBlock implements BonemealableBlock {
18
	private static final VoxelShape SHAPE = Block.column(12.0, 0.0, 13.0);
19
20
	/**
21
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
22
	 */
23
	public TallGrassBlock(final BlockBehaviour.Properties properties) {
24
		super(properties);
25
	}
26
27
	@Override
28
	protected VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) {
29
		return SHAPE;
30
	}
31
32
	@Override
33
	public boolean isValidBonemealTarget(final LevelReader level, final BlockPos pos, final BlockState state, final BonemealSource source) {
34
		return getGrownBlock(state).defaultBlockState().canSurvive(level, pos) && level.isEmptyBlock(pos.above()) && level.isInsideBuildHeight(pos.above());
35
	}
36
37
	@Override
38
	public boolean isBonemealSuccess(final Level level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source) {
39
		return true;
40
	}
41
42
	@Override
43
	public void performBonemeal(final ServerLevel level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source) {
44
		DoublePlantBlock.placeAt(level, getGrownBlock(state).defaultBlockState(), pos, 2);
45
	}
46
47
	private static DoublePlantBlock getGrownBlock(final BlockState state) {
48
		return (DoublePlantBlock)(state.is(Blocks.FERN) ? Blocks.LARGE_FERN : Blocks.TALL_GRASS);
49
	}
50
}
51

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