| 1 | package net.minecraft.world.level.block;
|
| 2 |
|
| 3 | import net.minecraft.core.BlockPos;
|
| 4 | import net.minecraft.world.level.Level;
|
| 5 | import net.minecraft.world.level.block.state.BlockBehaviour;
|
| 6 | import net.minecraft.world.level.block.state.BlockState;
|
| 7 | import net.minecraft.world.level.block.state.StateDefinition;
|
| 8 | import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
| 9 | import net.minecraft.world.level.block.state.properties.EnumProperty;
|
| 10 | import net.minecraft.world.level.block.state.properties.Property;
|
| 11 | import net.minecraft.world.level.block.state.properties.RailShape;
|
| 12 |
|
| 13 | /**
|
| 14 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 15 | */
|
| 16 | public class RailBlock extends BaseRailBlock {
|
| 17 | public static final EnumProperty<RailShape> SHAPE = BlockStateProperties.RAIL_SHAPE;
|
| 18 |
|
| 19 | /**
|
| 20 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 21 | */
|
| 22 | public RailBlock(final BlockBehaviour.Properties properties) {
|
| 23 | super(false, properties);
|
| 24 | this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, RailShape.NORTH_SOUTH).setValue(WATERLOGGED, false));
|
| 25 | }
|
| 26 |
|
| 27 | @Override
|
| 28 | protected void updateState(final BlockState state, final Level level, final BlockPos pos, final Block block) {
|
| 29 | if (block.defaultBlockState().isSignalSource() && new RailState(level, pos, state).countPotentialConnections() == 3) {
|
| 30 | this.updateDir(level, pos, state, false);
|
| 31 | }
|
| 32 | }
|
| 33 |
|
| 34 | @Override
|
| 35 | public Property<RailShape> getShapeProperty() {
|
| 36 | return SHAPE;
|
| 37 | }
|
| 38 |
|
| 39 | @Override
|
| 40 | protected BlockState rotate(final BlockState state, final Rotation rotation) {
|
| 41 | RailShape currentShape = state.getValue(SHAPE);
|
| 42 | RailShape newShape = this.rotate(currentShape, rotation);
|
| 43 | return state.setValue(SHAPE, newShape);
|
| 44 | }
|
| 45 |
|
| 46 | @Override
|
| 47 | protected BlockState mirror(final BlockState state, final Mirror mirror) {
|
| 48 | RailShape currentShape = state.getValue(SHAPE);
|
| 49 | RailShape newShape = this.mirror(currentShape, mirror);
|
| 50 | return state.setValue(SHAPE, newShape);
|
| 51 | }
|
| 52 |
|
| 53 | @Override
|
| 54 | protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> builder) {
|
| 55 | builder.add(SHAPE, WATERLOGGED);
|
| 56 | }
|
| 57 | }
|
| 58 |
|