use of org.spongepowered.api.data.manipulator.immutable.block.ImmutablePoweredData in project SpongeCommon by SpongePowered.
the class MixinBlockLever method getStateWithData.
@Override
public Optional<BlockState> getStateWithData(IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
if (manipulator instanceof ImmutablePoweredData) {
return Optional.of((BlockState) blockState.withProperty(BlockLever.POWERED, ((ImmutablePoweredData) manipulator).powered().get()));
}
if (manipulator instanceof ImmutableDirectionalData) {
final Direction dir = ((ImmutableDirectionalData) manipulator).direction().get();
final Axis axis = this.getAxisFromOrientation(blockState.getValue(BlockLever.FACING));
return Optional.of((BlockState) blockState.withProperty(BlockLever.FACING, DirectionResolver.getAsOrientation(dir, axis)));
}
if (manipulator instanceof ImmutableAxisData) {
final Axis axis = ((ImmutableAxisData) manipulator).axis().get();
final Direction dir = DirectionResolver.getFor(blockState.getValue(BlockLever.FACING));
return Optional.of((BlockState) blockState.withProperty(BlockLever.FACING, DirectionResolver.getAsOrientation(dir, axis)));
}
return super.getStateWithData(blockState, manipulator);
}
Aggregations