Add rotation and mirror code to FullyDirectionalBlock

This commit is contained in:
Mrbysco 2024-03-11 19:16:44 +01:00
parent 62ff6acddb
commit b3bac386ad

View file

@ -3,6 +3,8 @@ package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -29,6 +31,16 @@ public abstract class FullyDirectionalBlock extends BlockBase {
return this.stateDefinition.getOwner().defaultBlockState().setValue(FACING, Direction.NORTH);
}
@Override
public BlockState rotate(BlockState pState, Rotation pRotation) {
return pState.setValue(FACING, pRotation.rotate(pState.getValue(FACING)));
}
@Override
public BlockState mirror(BlockState pState, Mirror pMirror) {
return pState.rotate(pMirror.getRotation(pState.getValue(FACING)));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);