Search in sources :

Example 1 with ImmutableDirectionalData

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);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Direction(org.spongepowered.api.util.Direction) ImmutableDirectionalData(org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData)

Example 2 with ImmutableDirectionalData

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);
}
Also used : Direction(org.spongepowered.api.util.Direction) ImmutableDirectionalData(org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData)

Example 3 with ImmutableDirectionalData

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);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Direction(org.spongepowered.api.util.Direction) ImmutableDirectionalData(org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData)

Example 4 with ImmutableDirectionalData

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);
}
Also used : ImmutablePoweredData(org.spongepowered.api.data.manipulator.immutable.block.ImmutablePoweredData) ImmutableAxisData(org.spongepowered.api.data.manipulator.immutable.block.ImmutableAxisData) Direction(org.spongepowered.api.util.Direction) ImmutableDirectionalData(org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData) Axis(org.spongepowered.api.util.Axis)

Example 5 with ImmutableDirectionalData

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);
}
Also used : Direction(org.spongepowered.api.util.Direction) ImmutableDirectionalData(org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData)

Aggregations

ImmutableDirectionalData (org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirectionalData)6 Direction (org.spongepowered.api.util.Direction)6 EnumFacing (net.minecraft.util.EnumFacing)3 ImmutableAxisData (org.spongepowered.api.data.manipulator.immutable.block.ImmutableAxisData)1 ImmutablePoweredData (org.spongepowered.api.data.manipulator.immutable.block.ImmutablePoweredData)1 Axis (org.spongepowered.api.util.Axis)1