BeetrootBlock .java

net.minecraft.world.level.block.BeetrootBlock (class): members: getBonemealAgeIncrease, getAgeProperty, getMaxAge, getBaseSeedId, MAX_AGE, AGE, SHAPES.

net.minecraft.world.level.blockclass64 linescommonextends CropBlock2.0 KB

API Surface (7)

IntegerProperty getAgeProperty()
int getMaxAge()
ItemLike getBaseSeedId()
void randomTick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random)
int getBonemealAgeIncrease(final Level level)
void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder)
VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context)

Fields & Constants (3)

MAX_AGE
AGE
SHAPES

Full Source

BeetrootBlock.java64 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.item.Items;
7
import net.minecraft.world.level.BlockGetter;
8
import net.minecraft.world.level.ItemLike;
9
import net.minecraft.world.level.Level;
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.IntegerProperty;
15
import net.minecraft.world.phys.shapes.CollisionContext;
16
import net.minecraft.world.phys.shapes.VoxelShape;
17
18
public class BeetrootBlock extends CropBlock {
19
	public static final int MAX_AGE = 3;
20
	public static final IntegerProperty AGE = BlockStateProperties.AGE_3;
21
	private static final VoxelShape[] SHAPES = Block.boxes(3, age -> Block.column(16.0, 0.0, 2 + age * 2));
22
23
	public BeetrootBlock(final BlockBehaviour.Properties properties) {
24
		super(properties);
25
	}
26
27
	@Override
28
	protected IntegerProperty getAgeProperty() {
29
		return AGE;
30
	}
31
32
	@Override
33
	public int getMaxAge() {
34
		return 3;
35
	}
36
37
	@Override
38
	protected ItemLike getBaseSeedId() {
39
		return Items.BEETROOT_SEEDS;
40
	}
41
42
	@Override
43
	protected void randomTick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random) {
44
		if (random.nextInt(3) != 0) {
45
			super.randomTick(state, level, pos, random);
46
		}
47
	}
48
49
	@Override
50
	protected int getBonemealAgeIncrease(final Level level) {
51
		return super.getBonemealAgeIncrease(level) / 3;
52
	}
53
54
	@Override
55
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
56
		builder.add(AGE);
57
	}
58
59
	@Override
60
	protected VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) {
61
		return SHAPES[this.getAge(state)];
62
	}
63
}
64

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