CoralFanBlock .java

net.minecraft.world.level.block.CoralFanBlock (class): members: deadBlock, onPlace, neighbourState, directionToNeighbour, updateShape, neighbourPos, ticks.

net.minecraft.world.level.blockclass63 linescommonextends BaseCoralFanBlock2.1 KB

API Surface (3)

void onPlace(final BlockState state, final Level level, final BlockPos pos, final BlockState oldState, final boolean movedByPiston)
void tick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random)
BlockState updateShape(final BlockState state, final LevelReader level, final ScheduledTickAccess ticks, final BlockPos pos, final Direction directionToNeighbour, final BlockPos neighbourPos, final BlockState neighbourState, final RandomSource random)

Fields & Constants (8)

deadBlock
state
level
ticks
pos
directionToNeighbour
neighbourPos
neighbourState

Full Source

CoralFanBlock.java63 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.level.Level;
8
import net.minecraft.world.level.LevelReader;
9
import net.minecraft.world.level.ScheduledTickAccess;
10
import net.minecraft.world.level.block.state.BlockBehaviour;
11
import net.minecraft.world.level.block.state.BlockState;
12
import net.minecraft.world.level.material.Fluids;
13
14
/**
15
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
16
 */
17
public class CoralFanBlock extends BaseCoralFanBlock {
18
	private final Block deadBlock;
19
20
	/**
21
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
22
	 */
23
	public CoralFanBlock(final Block deadBlock, final BlockBehaviour.Properties properties) {
24
		super(properties);
25
		this.deadBlock = deadBlock;
26
	}
27
28
	@Override
29
	protected void onPlace(final BlockState state, final Level level, final BlockPos pos, final BlockState oldState, final boolean movedByPiston) {
30
		this.tryScheduleDieTick(state, level, level, level.getRandom(), pos);
31
	}
32
33
	@Override
34
	protected void tick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random) {
35
		if (!scanForWater(state, level, pos)) {
36
			level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false), 2);
37
		}
38
	}
39
40
	@Override
41
	protected BlockState updateShape(
42
		final BlockState state,
43
		final LevelReader level,
44
		final ScheduledTickAccess ticks,
45
		final BlockPos pos,
46
		final Direction directionToNeighbour,
47
		final BlockPos neighbourPos,
48
		final BlockState neighbourState,
49
		final RandomSource random
50
	) {
51
		if (directionToNeighbour == Direction.DOWN && !state.canSurvive(level, pos)) {
52
			return Blocks.AIR.defaultBlockState();
53
		}
54
55
		this.tryScheduleDieTick(state, level, ticks, random, pos);
56
		if (state.getValue(WATERLOGGED)) {
57
			ticks.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
58
		}
59
60
		return super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random);
61
	}
62
}
63

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