CaveVinesBlock .java

net.minecraft.world.level.block.CaveVinesBlock (class, 82 lines): members: CHANCE_OF_BERRIES_ON_GROWTH, updateBodyAfterConvertedFromHead, getGrowIntoState.

net.minecraft.world.level.blockclass82 linescommonextends GrowingPlantHeadBlock2.9 KB

Implements

API Surface (11)

int getBlocksToGrowWhenBonemealed(final RandomSource random)
boolean canGrowInto(final BlockState state)
Block getBodyBlock()
BlockState updateBodyAfterConvertedFromHead(final BlockState headState, final BlockState bodyState)
BlockState getGrowIntoState(final BlockState growFromState, final RandomSource random)
ItemStack getCloneItemStack(final LevelReader level, final BlockPos pos, final BlockState state, final boolean includeData)
InteractionResult useWithoutItem(final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult)
void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder)
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)

CHANCE_OF_BERRIES_ON_GROWTH

Full Source

CaveVinesBlock.java82 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.server.level.ServerLevel;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.world.InteractionResult;
8
import net.minecraft.world.entity.player.Player;
9
import net.minecraft.world.item.ItemStack;
10
import net.minecraft.world.item.Items;
11
import net.minecraft.world.level.Level;
12
import net.minecraft.world.level.LevelReader;
13
import net.minecraft.world.level.block.state.BlockBehaviour;
14
import net.minecraft.world.level.block.state.BlockState;
15
import net.minecraft.world.level.block.state.StateDefinition;
16
import net.minecraft.world.phys.BlockHitResult;
17
18
public class CaveVinesBlock extends GrowingPlantHeadBlock implements CaveVines {
19
	private static final float CHANCE_OF_BERRIES_ON_GROWTH = 0.11F;
20
21
	public CaveVinesBlock(final BlockBehaviour.Properties properties) {
22
		super(properties, Direction.DOWN, SHAPE, false, 0.1);
23
		this.registerDefaultState(this.stateDefinition.any().setValue(AGE, 0).setValue(BERRIES, false));
24
	}
25
26
	@Override
27
	protected int getBlocksToGrowWhenBonemealed(final RandomSource random) {
28
		return 1;
29
	}
30
31
	@Override
32
	protected boolean canGrowInto(final BlockState state) {
33
		return state.isAir();
34
	}
35
36
	@Override
37
	protected Block getBodyBlock() {
38
		return Blocks.CAVE_VINES_PLANT;
39
	}
40
41
	@Override
42
	protected BlockState updateBodyAfterConvertedFromHead(final BlockState headState, final BlockState bodyState) {
43
		return bodyState.setValue(BERRIES, headState.getValue(BERRIES));
44
	}
45
46
	@Override
47
	protected BlockState getGrowIntoState(final BlockState growFromState, final RandomSource random) {
48
		return super.getGrowIntoState(growFromState, random).setValue(BERRIES, random.nextFloat() < 0.11F);
49
	}
50
51
	@Override
52
	protected ItemStack getCloneItemStack(final LevelReader level, final BlockPos pos, final BlockState state, final boolean includeData) {
53
		return new ItemStack(Items.GLOW_BERRIES);
54
	}
55
56
	@Override
57
	protected InteractionResult useWithoutItem(final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult) {
58
		return CaveVines.use(player, state, level, pos);
59
	}
60
61
	@Override
62
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
63
		super.createBlockStateDefinition(builder);
64
		builder.add(BERRIES);
65
	}
66
67
	@Override
68
	public boolean isValidBonemealTarget(final LevelReader level, final BlockPos pos, final BlockState state, final BonemealSource source) {
69
		return !state.getValue(BERRIES);
70
	}
71
72
	@Override
73
	public boolean isBonemealSuccess(final Level level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source) {
74
		return true;
75
	}
76
77
	@Override
78
	public void performBonemeal(final ServerLevel level, final RandomSource random, final BlockPos pos, final BlockState state, final BonemealSource source) {
79
		level.setBlock(pos, state.setValue(BERRIES, true), 2);
80
	}
81
}
82

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