StandingSignBlock .java

net.minecraft.world.level.block.StandingSignBlock (class): members: getYRotationDegrees, ROTATION, attachmentPoint, canSurvive, mirror, rotate, ticks.

net.minecraft.world.level.blockclass81 linescommonextends SignBlock3.1 KB

Implements

API Surface (8)

boolean canSurvive(final BlockState state, final LevelReader level, final BlockPos pos)
BlockState getStateForPlacement(final BlockPlaceContext context)
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)
float getYRotationDegrees(final BlockState state)
BlockState rotate(final BlockState state, final Rotation rotation)
BlockState mirror(final BlockState state, final Mirror mirror)
void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder)
PlainSignBlock.Attachment attachmentPoint(final BlockState state)

Fields & Constants (8)

ROTATION
state
level
ticks
pos
directionToNeighbour
neighbourPos
neighbourState

Full Source

StandingSignBlock.java81 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.util.RandomSource;
6
import net.minecraft.world.item.context.BlockPlaceContext;
7
import net.minecraft.world.level.LevelReader;
8
import net.minecraft.world.level.ScheduledTickAccess;
9
import net.minecraft.world.level.block.state.BlockBehaviour;
10
import net.minecraft.world.level.block.state.BlockState;
11
import net.minecraft.world.level.block.state.StateDefinition;
12
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
13
import net.minecraft.world.level.block.state.properties.IntegerProperty;
14
import net.minecraft.world.level.block.state.properties.RotationSegment;
15
import net.minecraft.world.level.block.state.properties.WoodType;
16
import net.minecraft.world.level.material.FluidState;
17
import net.minecraft.world.level.material.Fluids;
18
19
public class StandingSignBlock extends SignBlock implements PlainSignBlock {
20
	public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
21
22
	public StandingSignBlock(final WoodType type, final BlockBehaviour.Properties properties) {
23
		super(type, properties.sound(type.soundType()));
24
		this.registerDefaultState(this.stateDefinition.any().setValue(ROTATION, 8).setValue(WATERLOGGED, false));
25
	}
26
27
	@Override
28
	protected boolean canSurvive(final BlockState state, final LevelReader level, final BlockPos pos) {
29
		return level.getBlockState(pos.below()).isSolid();
30
	}
31
32
	@Override
33
	public BlockState getStateForPlacement(final BlockPlaceContext context) {
34
		FluidState replacedFluidState = context.getLevel().getFluidState(context.getClickedPos());
35
		return this.defaultBlockState()
36
			.setValue(ROTATION, RotationSegment.convertToSegment(context.getRotation() + 180.0F))
37
			.setValue(WATERLOGGED, replacedFluidState.is(Fluids.WATER));
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
		return directionToNeighbour == Direction.DOWN && !this.canSurvive(state, level, pos)
52
			? Blocks.AIR.defaultBlockState()
53
			: super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random);
54
	}
55
56
	@Override
57
	public float getYRotationDegrees(final BlockState state) {
58
		return RotationSegment.convertToDegrees(state.getValue(ROTATION));
59
	}
60
61
	@Override
62
	protected BlockState rotate(final BlockState state, final Rotation rotation) {
63
		return state.setValue(ROTATION, rotation.rotate(state.getValue(ROTATION), 16));
64
	}
65
66
	@Override
67
	protected BlockState mirror(final BlockState state, final Mirror mirror) {
68
		return state.setValue(ROTATION, mirror.mirror(state.getValue(ROTATION), 16));
69
	}
70
71
	@Override
72
	protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
73
		builder.add(ROTATION, WATERLOGGED);
74
	}
75
76
	@Override
77
	public PlainSignBlock.Attachment attachmentPoint(final BlockState state) {
78
		return PlainSignBlock.Attachment.GROUND;
79
	}
80
}
81

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