PlaceOnWaterBlockItem .java

net.minecraft.world.item.PlaceOnWaterBlockItem (class, 29 lines): members: useOn, use. imports: UseOnContext, ClipContext, BlockHitResult, InteractionHand.

net.minecraft.world.itemclass29 linescommonextends BlockItem1.0 KB

API Surface (2)

InteractionResult useOn(final UseOnContext context)
InteractionResult use(final Level level, final Player player, final InteractionHand hand)

Full Source

PlaceOnWaterBlockItem.java29 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item;
2
3
import net.minecraft.world.InteractionHand;
4
import net.minecraft.world.InteractionResult;
5
import net.minecraft.world.entity.player.Player;
6
import net.minecraft.world.item.context.UseOnContext;
7
import net.minecraft.world.level.ClipContext;
8
import net.minecraft.world.level.Level;
9
import net.minecraft.world.level.block.Block;
10
import net.minecraft.world.phys.BlockHitResult;
11
12
public class PlaceOnWaterBlockItem extends BlockItem {
13
	public PlaceOnWaterBlockItem(final Block block, final Item.Properties properties) {
14
		super(block, properties);
15
	}
16
17
	@Override
18
	public InteractionResult useOn(final UseOnContext context) {
19
		return InteractionResult.PASS;
20
	}
21
22
	@Override
23
	public InteractionResult use(final Level level, final Player player, final InteractionHand hand) {
24
		BlockHitResult hitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY);
25
		BlockHitResult blockAboveResult = hitResult.withPosition(hitResult.getBlockPos().above());
26
		return super.useOn(new UseOnContext(player, hand, blockAboveResult));
27
	}
28
}
29

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