65 lines
3.3 KiB
Java
65 lines
3.3 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.block.state.AbstractStateHolder;
|
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
import net.minecraft.world.level.block.state.StateDefinition;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.level.material.FluidState;
|
|
import net.minecraft.world.level.material.Fluids;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.item.BlockPlaceContext;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.LevelReader;
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.block.state.properties.WoodType;
|
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
|
|
|
public class StandingSignBlock extends SignBlock {
|
|
public static final IntegerProperty ROTATION;
|
|
|
|
public StandingSignBlock(final Properties c, final WoodType bzp) {
|
|
super(c, bzp);
|
|
this.registerDefaultState((((AbstractStateHolder<O, BlockState>)this.stateDefinition.any()).setValue((Property<Comparable>)StandingSignBlock.ROTATION, 0)).<Comparable, Boolean>setValue((Property<Comparable>)StandingSignBlock.WATERLOGGED, false));
|
|
}
|
|
|
|
@Override
|
|
public boolean canSurvive(final BlockState byg, final LevelReader bjw, final BlockPos fk) {
|
|
return bjw.getBlockState(fk.below()).getMaterial().isSolid();
|
|
}
|
|
|
|
@Override
|
|
public BlockState getStateForPlacement(final BlockPlaceContext bcn) {
|
|
final FluidState cog3 = bcn.getLevel().getFluidState(bcn.getClickedPos());
|
|
return (((AbstractStateHolder<O, BlockState>)this.defaultBlockState()).setValue((Property<Comparable>)StandingSignBlock.ROTATION, Mth.floor((180.0f + bcn.getRotation()) * 16.0f / 360.0f + 0.5) & 0xF)).<Comparable, Boolean>setValue((Property<Comparable>)StandingSignBlock.WATERLOGGED, cog3.getType() == Fluids.WATER);
|
|
}
|
|
|
|
@Override
|
|
public BlockState updateShape(final BlockState byg1, final Direction fp, final BlockState byg3, final LevelAccessor bju, final BlockPos fk5, final BlockPos fk6) {
|
|
if (fp == Direction.DOWN && !this.canSurvive(byg1, bju, fk5)) {
|
|
return Blocks.AIR.defaultBlockState();
|
|
}
|
|
return super.updateShape(byg1, fp, byg3, bju, fk5, fk6);
|
|
}
|
|
|
|
@Override
|
|
public BlockState rotate(final BlockState byg, final Rotation btr) {
|
|
return ((AbstractStateHolder<O, BlockState>)byg).<Comparable, Integer>setValue((Property<Comparable>)StandingSignBlock.ROTATION, btr.rotate(byg.<Integer>getValue((Property<Integer>)StandingSignBlock.ROTATION), 16));
|
|
}
|
|
|
|
@Override
|
|
public BlockState mirror(final BlockState byg, final Mirror bsr) {
|
|
return ((AbstractStateHolder<O, BlockState>)byg).<Comparable, Integer>setValue((Property<Comparable>)StandingSignBlock.ROTATION, bsr.mirror(byg.<Integer>getValue((Property<Integer>)StandingSignBlock.ROTATION), 16));
|
|
}
|
|
|
|
@Override
|
|
protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
|
|
a.add(StandingSignBlock.ROTATION, StandingSignBlock.WATERLOGGED);
|
|
}
|
|
|
|
static {
|
|
ROTATION = BlockStateProperties.ROTATION_16;
|
|
}
|
|
}
|