TorchflowerCropBlock .java

net.minecraft.world.level.block.TorchflowerCropBlock (class): members: BONEMEAL_INCREASE, getStateForAge, getBonemealAgeIncrease, getAgeProperty, MAX_AGE.

net.minecraft.world.level.blockclass70 linescommonextends CropBlock2.1 KB

API Surface (8)

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

Fields & Constants (4)

MAX_AGE
AGE
SHAPES
BONEMEAL_INCREASE

Full Source

TorchflowerCropBlock.java70 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 TorchflowerCropBlock extends CropBlock {
19
	public static final int MAX_AGE = 1;
20
	public static final IntegerProperty AGE = BlockStateProperties.AGE_1;
21
	private static final VoxelShape[] SHAPES = Block.boxes(1, age -> Block.column(6.0, 0.0, 6 + age * 4));
22
	private static final int BONEMEAL_INCREASE = 1;
23
24
	public TorchflowerCropBlock(final BlockBehaviour.Properties properties) {
25
		super(properties);
26
	}
27
28
	@Override
29
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
30
		builder.add(AGE);
31
	}
32
33
	@Override
34
	public VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) {
35
		return SHAPES[this.getAge(state)];
36
	}
37
38
	@Override
39
	protected IntegerProperty getAgeProperty() {
40
		return AGE;
41
	}
42
43
	@Override
44
	public int getMaxAge() {
45
		return 2;
46
	}
47
48
	@Override
49
	protected ItemLike getBaseSeedId() {
50
		return Items.TORCHFLOWER_SEEDS;
51
	}
52
53
	@Override
54
	public BlockState getStateForAge(final int age) {
55
		return age == 2 ? Blocks.TORCHFLOWER.defaultBlockState() : super.getStateForAge(age);
56
	}
57
58
	@Override
59
	public void randomTick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random) {
60
		if (random.nextInt(3) != 0) {
61
			super.randomTick(state, level, pos, random);
62
		}
63
	}
64
65
	@Override
66
	protected int getBonemealAgeIncrease(final Level level) {
67
		return 1;
68
	}
69
}
70

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