Skip to content

Commit f7539d6

Browse files
authored
Merge pull request #188 from Theobl08/1.20-main
Fix block rotation for hull blocks and catwalk railling
2 parents 2090679 + 02734db commit f7539d6

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

common/src/main/java/com/github/talrey/createdeco/blocks/CatwalkRailingBlock.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.minecraft.world.level.Level;
1515
import net.minecraft.world.level.block.Block;
1616
import net.minecraft.world.level.block.Blocks;
17+
import net.minecraft.world.level.block.Rotation;
1718
import net.minecraft.world.level.block.state.BlockState;
1819
import net.minecraft.world.level.block.state.StateDefinition;
1920
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@@ -218,4 +219,40 @@ public static boolean isEmpty (BlockState state) {
218219
public FluidState getFluidState(BlockState state) {
219220
return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
220221
}
222+
223+
@Override
224+
public BlockState rotate(BlockState state, Rotation rotation) {
225+
boolean north = state.getValue(NORTH_FENCE);
226+
boolean south = state.getValue(SOUTH_FENCE);
227+
boolean east = state.getValue(EAST_FENCE);
228+
boolean west = state.getValue(WEST_FENCE);
229+
switch (rotation){
230+
case CLOCKWISE_90 -> {
231+
north = state.getValue(WEST_FENCE);
232+
south = state.getValue(EAST_FENCE);
233+
east = state.getValue(NORTH_FENCE);
234+
west = state.getValue(SOUTH_FENCE);
235+
}
236+
case CLOCKWISE_180 -> {
237+
north = state.getValue(SOUTH_FENCE);
238+
south = state.getValue(NORTH_FENCE);
239+
east = state.getValue(WEST_FENCE);
240+
west = state.getValue(EAST_FENCE);
241+
}
242+
case COUNTERCLOCKWISE_90 -> {
243+
north = state.getValue(EAST_FENCE);
244+
south = state.getValue(WEST_FENCE);
245+
east = state.getValue(SOUTH_FENCE);
246+
west = state.getValue(NORTH_FENCE);
247+
}
248+
case NONE -> {
249+
north = state.getValue(NORTH_FENCE);
250+
south = state.getValue(SOUTH_FENCE);
251+
east = state.getValue(EAST_FENCE);
252+
west = state.getValue(WEST_FENCE);
253+
}
254+
}
255+
BlockState newState = defaultBlockState().setValue(NORTH_FENCE, north).setValue(SOUTH_FENCE, south).setValue(EAST_FENCE, east).setValue(WEST_FENCE, west);
256+
return newState;
257+
}
221258
}

common/src/main/java/com/github/talrey/createdeco/blocks/HullBlock.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.minecraft.world.level.BlockGetter;
66
import net.minecraft.world.level.block.Block;
77
import net.minecraft.world.level.block.DirectionalBlock;
8+
import net.minecraft.world.level.block.Rotation;
89
import net.minecraft.world.level.block.state.BlockState;
910
import net.minecraft.world.level.block.state.StateDefinition;
1011
import net.minecraft.world.phys.shapes.BooleanOp;
@@ -48,4 +49,9 @@ public BlockState getStateForPlacement (BlockPlaceContext ctx) {
4849
public VoxelShape getShape (BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) {
4950
return CUBE;
5051
}
52+
53+
@Override
54+
public BlockState rotate(BlockState state, Rotation rotation) {
55+
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)));
56+
}
5157
}

0 commit comments

Comments
 (0)