AbstractCauldronBlock .java

net.minecraft.world.level.block.AbstractCauldronBlock (class): members: interactions, FLOOR_LEVEL, SHAPE_INSIDE, canReceiveStalactiteDrip, isFull, hand.

net.minecraft.world.level.blockclass105 linescommonextends Block3.5 KB

API Surface (9)

double getContentHeight(final BlockState state)
InteractionResult useItemOn(final ItemStack itemStack, final BlockState state, final Level level, final BlockPos pos, final Player player, final InteractionHand hand, final BlockHitResult hitResult)
VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context)
VoxelShape getInteractionShape(final BlockState state, final BlockGetter level, final BlockPos pos)
boolean hasAnalogOutputSignal(final BlockState state)
boolean isPathfindable(final BlockState state, final PathComputationType type)
void tick(final BlockState cauldronState, final ServerLevel level, final BlockPos pos, final RandomSource random)
boolean canReceiveStalactiteDrip(final Fluid fluid)
void receiveStalactiteDrip(final BlockState state, final Level level, final BlockPos pos, final Fluid fluid)

Fields & Constants (10)

FLOOR_LEVEL
SHAPE_INSIDE
SHAPE
interactions
itemStack
state
level
pos
player
hand

Full Source

AbstractCauldronBlock.java105 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.cauldron.CauldronInteraction;
5
import net.minecraft.server.level.ServerLevel;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.util.Util;
8
import net.minecraft.world.InteractionHand;
9
import net.minecraft.world.InteractionResult;
10
import net.minecraft.world.entity.player.Player;
11
import net.minecraft.world.item.ItemStack;
12
import net.minecraft.world.level.BlockGetter;
13
import net.minecraft.world.level.Level;
14
import net.minecraft.world.level.block.state.BlockBehaviour;
15
import net.minecraft.world.level.block.state.BlockState;
16
import net.minecraft.world.level.material.Fluid;
17
import net.minecraft.world.level.material.Fluids;
18
import net.minecraft.world.level.pathfinder.PathComputationType;
19
import net.minecraft.world.phys.BlockHitResult;
20
import net.minecraft.world.phys.shapes.BooleanOp;
21
import net.minecraft.world.phys.shapes.CollisionContext;
22
import net.minecraft.world.phys.shapes.Shapes;
23
import net.minecraft.world.phys.shapes.VoxelShape;
24
25
public abstract class AbstractCauldronBlock extends Block {
26
	protected static final int FLOOR_LEVEL = 4;
27
	private static final VoxelShape SHAPE_INSIDE = Block.column(12.0, 4.0, 16.0);
28
	protected static final VoxelShape SHAPE = Util.make(
29
		() -> {
30
			int legWidth = 4;
31
			int legHeight = 3;
32
			int legThickness = 2;
33
			return Shapes.join(
34
				Shapes.block(),
35
				Shapes.or(Block.column(16.0, 8.0, 0.0, 3.0), Block.column(8.0, 16.0, 0.0, 3.0), Block.column(12.0, 0.0, 3.0), SHAPE_INSIDE),
36
				BooleanOp.ONLY_FIRST
37
			);
38
		}
39
	);
40
	protected final CauldronInteraction.Dispatcher interactions;
41
42
	public AbstractCauldronBlock(final BlockBehaviour.Properties properties, final CauldronInteraction.Dispatcher interactions) {
43
		super(properties);
44
		this.interactions = interactions;
45
	}
46
47
	protected double getContentHeight(final BlockState state) {
48
		return 0.0;
49
	}
50
51
	@Override
52
	protected InteractionResult useItemOn(
53
		final ItemStack itemStack,
54
		final BlockState state,
55
		final Level level,
56
		final BlockPos pos,
57
		final Player player,
58
		final InteractionHand hand,
59
		final BlockHitResult hitResult
60
	) {
61
		CauldronInteraction behavior = this.interactions.get(itemStack);
62
		return behavior.interact(state, level, pos, player, hand, itemStack);
63
	}
64
65
	@Override
66
	protected VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) {
67
		return SHAPE;
68
	}
69
70
	@Override
71
	protected VoxelShape getInteractionShape(final BlockState state, final BlockGetter level, final BlockPos pos) {
72
		return SHAPE_INSIDE;
73
	}
74
75
	@Override
76
	protected boolean hasAnalogOutputSignal(final BlockState state) {
77
		return true;
78
	}
79
80
	@Override
81
	protected boolean isPathfindable(final BlockState state, final PathComputationType type) {
82
		return false;
83
	}
84
85
	public abstract boolean isFull(final BlockState state);
86
87
	@Override
88
	protected void tick(final BlockState cauldronState, final ServerLevel level, final BlockPos pos, final RandomSource random) {
89
		BlockPos stalactitePos = PointedDripstoneBlock.findStalactiteTipAboveCauldron(level, pos);
90
		if (stalactitePos != null) {
91
			Fluid fluid = PointedDripstoneBlock.getCauldronFillFluidType(level, stalactitePos);
92
			if (fluid != Fluids.EMPTY && this.canReceiveStalactiteDrip(fluid)) {
93
				this.receiveStalactiteDrip(cauldronState, level, pos, fluid);
94
			}
95
		}
96
	}
97
98
	protected boolean canReceiveStalactiteDrip(final Fluid fluid) {
99
		return false;
100
	}
101
102
	protected void receiveStalactiteDrip(final BlockState state, final Level level, final BlockPos pos, final Fluid fluid) {
103
	}
104
}
105

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