LilyPadBlock .java

net.minecraft.world.level.block.LilyPadBlock (class): members: mayPlaceOn, effectApplier, entityInside, SHAPE, getShape. imports: AbstractBoat, FluidTags.

net.minecraft.world.level.blockclass54 linescommonextends VegetationBlock2.0 KB

API Surface (3)

void entityInside(final BlockState state, final Level level, final BlockPos pos, final Entity entity, final InsideBlockEffectApplier effectApplier, final boolean isPrecise)
VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context)
boolean mayPlaceOn(final BlockState state, final BlockGetter level, final BlockPos pos)

Fields & Constants (2)

SHAPE
effectApplier

Full Source

LilyPadBlock.java54 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.tags.BlockTags;
6
import net.minecraft.tags.FluidTags;
7
import net.minecraft.world.entity.Entity;
8
import net.minecraft.world.entity.InsideBlockEffectApplier;
9
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
10
import net.minecraft.world.level.BlockGetter;
11
import net.minecraft.world.level.Level;
12
import net.minecraft.world.level.block.state.BlockBehaviour;
13
import net.minecraft.world.level.block.state.BlockState;
14
import net.minecraft.world.level.material.FluidState;
15
import net.minecraft.world.level.material.Fluids;
16
import net.minecraft.world.phys.shapes.CollisionContext;
17
import net.minecraft.world.phys.shapes.VoxelShape;
18
19
/**
20
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
21
 */
22
public class LilyPadBlock extends VegetationBlock {
23
	private static final VoxelShape SHAPE = Block.column(14.0, 0.0, 1.5);
24
25
	/**
26
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
27
	 */
28
	public LilyPadBlock(final BlockBehaviour.Properties properties) {
29
		super(properties);
30
	}
31
32
	@Override
33
	protected void entityInside(
34
		final BlockState state, final Level level, final BlockPos pos, final Entity entity, final InsideBlockEffectApplier effectApplier, final boolean isPrecise
35
	) {
36
		super.entityInside(state, level, pos, entity, effectApplier, isPrecise);
37
		if (level instanceof ServerLevel && entity instanceof AbstractBoat) {
38
			level.destroyBlock(pos.immutable(), true, entity);
39
		}
40
	}
41
42
	@Override
43
	protected VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) {
44
		return SHAPE;
45
	}
46
47
	@Override
48
	protected boolean mayPlaceOn(final BlockState state, final BlockGetter level, final BlockPos pos) {
49
		FluidState fluidState = level.getFluidState(pos);
50
		FluidState fluidAbove = level.getFluidState(pos.above());
51
		return (fluidState.is(FluidTags.SUPPORTS_LILY_PAD) || state.is(BlockTags.SUPPORTS_LILY_PAD)) && fluidAbove.is(Fluids.EMPTY);
52
	}
53
}
54

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