use of org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData in project SpongeCommon by SpongePowered.
the class MixinBlockBannerHanging method getStateWithData.
@Override
public Optional<BlockState> getStateWithData(IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
if (manipulator instanceof ImmutableDirectionalData) {
final Direction direction = ((ImmutableDirectionalData) manipulator).direction().get();
final EnumFacing facing = DirectionResolver.getFor(direction);
return Optional.of((BlockState) blockState.withProperty(BlockBanner.FACING, facing));
}
return super.getStateWithData(blockState, manipulator);
}
use of org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData in project SpongeCommon by SpongePowered.
the class MixinBlockBannerStanding method getStateWithData.
@Override
public Optional<BlockState> getStateWithData(IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
if (manipulator instanceof ImmutableDirectionalData) {
final Direction direction = ((ImmutableDirectionalData) manipulator).direction().get();
final int intDirection = (direction.ordinal() + 8) % 16;
return Optional.of((BlockState) blockState.withProperty(BlockBanner.ROTATION, intDirection));
}
return super.getStateWithData(blockState, manipulator);
}
use of org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData in project SpongeCommon by SpongePowered.
the class MixinBlockHorizontal method getStateWithData.
@Override
public Optional<BlockState> getStateWithData(IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
if (manipulator instanceof ImmutableDirectionalData) {
final Direction direction = ((ImmutableDirectionalData) manipulator).direction().get();
final EnumFacing facing = DirectionResolver.getFor(direction);
return Optional.of((BlockState) blockState.withProperty(BlockHorizontal.FACING, facing));
}
return super.getStateWithData(blockState, manipulator);
}
use of org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData 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);
}
use of org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData in project SpongeCommon by SpongePowered.
the class MixinBlockStandingSign method getStateWithData.
@Override
public Optional<BlockState> getStateWithData(IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
if (manipulator instanceof ImmutableDirectionalData) {
final Direction direction = ((ImmutableDirectionalData) manipulator).direction().get();
final int intDirection = (direction.ordinal() + 8) % 16;
return Optional.of((BlockState) blockState.withProperty(BlockStandingSign.ROTATION, intDirection));
}
return super.getStateWithData(blockState, manipulator);
}
Aggregations