@@ -30,6 +30,8 @@ public class InternalDoorBlock extends BaseEntityBlock {
3030
3131 public static final DirectionProperty FACING = HorizontalDirectionalBlock .FACING ;
3232 public static final BooleanProperty OPEN = BooleanProperty .create ("open" );
33+ public static final BooleanProperty OFFSET = BooleanProperty .create ("offset" );
34+
3335 /**
3436 * This is this door instance's understanding of if it is locked or not.
3537 * <br> This is needed to account for when multiple internal doors are in a Tardis, and the player is locking a different door
@@ -41,7 +43,7 @@ public class InternalDoorBlock extends BaseEntityBlock {
4143
4244 public InternalDoorBlock (Properties properties ) {
4345 super (properties );
44- this .registerDefaultState (this .stateDefinition .any ().setValue (FACING , Direction .NORTH ).setValue (OPEN , false ).setValue (LOCKED , false ));
46+ this .registerDefaultState (this .stateDefinition .any ().setValue (OFFSET , false ). setValue ( FACING , Direction .NORTH ).setValue (OPEN , false ).setValue (LOCKED , false ));
4547 }
4648
4749 @ Override
@@ -55,6 +57,10 @@ public void onPlace(BlockState blockState, Level level, BlockPos blockPos, Block
5557
5658 @ Override
5759 public VoxelShape getShape (BlockState blockState , BlockGetter blockGetter , BlockPos blockPos , CollisionContext collisionContext ) {
60+
61+ if (blockState .getValue (OFFSET )) {
62+ return COLLISION .move (0 , 0 , -0.5 );
63+ }
5864 return COLLISION ;
5965 }
6066
@@ -80,13 +86,13 @@ public BlockEntity getDoorBlockEntity() {
8086 @ Override
8187 protected void createBlockStateDefinition (StateDefinition .Builder <Block , BlockState > builder ) {
8288 super .createBlockStateDefinition (builder );
83- builder .add (OPEN , FACING , LOCKED );
89+ builder .add (OPEN , FACING , LOCKED , OFFSET );
8490 }
8591
8692 @ Override
8793 public BlockState getStateForPlacement (@ NotNull BlockPlaceContext blockPlaceContext ) {
8894 BlockState state = super .getStateForPlacement (blockPlaceContext );
89- return state .setValue (FACING , blockPlaceContext .getHorizontalDirection ()).setValue (OPEN , false ).setValue (LOCKED , false );
95+ return state .setValue (FACING , blockPlaceContext .getHorizontalDirection ()).setValue (OPEN , false ).setValue (LOCKED , false ). setValue ( OFFSET , blockPlaceContext . getPlayer (). isCrouching ()) ;
9096 }
9197
9298 @ Override
0 commit comments