Skip to content

Commit 81a18b1

Browse files
committed
- Enhancement: Doors can now be placed at 2x2 rendering by shift right-clicking when placing
1 parent 82a2dd7 commit 81a18b1

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88

99
#### Enhancements
1010
- Enhancement: Added tooltips to various screens to indicate which mod added content
11-
- Enhancement: Players can now sleep in the TARDIS (No spawnpoint setting)
11+
- Enhancement: Players can now sleep in the TARDIS (No spawnpoint setting)
12+
- Enhancement: Doors can now be placed at 2x2 rendering by shift right-clicking when placing

common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/GlobalDoorRenderer.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import net.minecraft.client.renderer.MultiBufferSource;
55
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
66
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
7+
import net.minecraft.world.level.block.state.BlockState;
78
import whocraft.tardis_refined.client.renderer.vortex.RenderTargetHelper;
9+
import whocraft.tardis_refined.common.block.door.GlobalDoorBlock;
810
import whocraft.tardis_refined.common.blockentity.door.GlobalDoorBlockEntity;
911

1012
public class GlobalDoorRenderer implements BlockEntityRenderer<GlobalDoorBlockEntity>, BlockEntityRendererProvider<GlobalDoorBlockEntity> {
@@ -14,8 +16,18 @@ public GlobalDoorRenderer(BlockEntityRendererProvider.Context context) {
1416

1517

1618
@Override
17-
public void render(GlobalDoorBlockEntity blockEntity, float partialTick, PoseStack stack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) {
18-
RenderTargetHelper.renderVortex(blockEntity, partialTick, stack, bufferSource, packedLight, packedOverlay);
19+
public void render(GlobalDoorBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) {
20+
21+
poseStack.pushPose();
22+
BlockState blockstate = blockEntity.getBlockState();
23+
24+
if(blockstate.hasProperty(GlobalDoorBlock.OFFSET) && blockstate.getValue(GlobalDoorBlock.OFFSET)) {
25+
poseStack.translate(0, 0, -0.5);
26+
// poseStack.translate(0, 0, -0.01);
27+
}
28+
29+
RenderTargetHelper.renderVortex(blockEntity, partialTick, poseStack, bufferSource, packedLight, packedOverlay);
30+
poseStack.popPose();
1931
}
2032

2133

common/src/main/java/whocraft/tardis_refined/common/block/door/InternalDoorBlock.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)