CoralWallFanBlock .java

net.minecraft.world.level.block.CoralWallFanBlock (class, 63 lines): members: deadBlock, onPlace, neighbourState, directionToNeighbour, updateShape, ticks.

net.minecraft.world.level.blockclass63 linescommonextends BaseCoralWallFanBlock2.2 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

CoralWallFanBlock.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 CoralWallFanBlock extends BaseCoralWallFanBlock {
18
	private final Block deadBlock;
19
20
	/**
21
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
22
	 */
23
	public CoralWallFanBlock(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).setValue(FACING, state.getValue(FACING)), 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.getOpposite() == state.getValue(FACING) && !state.canSurvive(level, pos)) {
52
			return Blocks.AIR.defaultBlockState();
53
		}
54
55
		if (state.getValue(WATERLOGGED)) {
56
			ticks.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
57
		}
58
59
		this.tryScheduleDieTick(state, level, ticks, random, pos);
60
		return super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random);
61
	}
62
}
63

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