|
14 | 14 | import net.minecraft.world.level.Level;
|
15 | 15 | import net.minecraft.world.level.block.Block;
|
16 | 16 | import net.minecraft.world.level.block.Blocks;
|
| 17 | +import net.minecraft.world.level.block.Rotation; |
17 | 18 | import net.minecraft.world.level.block.state.BlockState;
|
18 | 19 | import net.minecraft.world.level.block.state.StateDefinition;
|
19 | 20 | import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
@@ -218,4 +219,40 @@ public static boolean isEmpty (BlockState state) {
|
218 | 219 | public FluidState getFluidState(BlockState state) {
|
219 | 220 | return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
|
220 | 221 | }
|
| 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 | + } |
221 | 258 | }
|
0 commit comments