コード例 #1
0
 @Override
 public <E> Optional<BlockState> getStateWithValue(
     IBlockState blockState, Key<? extends BaseValue<E>> key, E value) {
   if (key.equals(Keys.POWERED)) {
     return Optional.of(
         (BlockState) blockState.withProperty(BlockButton.POWERED, (Boolean) value));
   }
   if (key.equals(Keys.DIRECTION)) {
     final Direction dir = (Direction) value;
     return Optional.of(
         (BlockState) blockState.withProperty(BlockButton.FACING, DirectionResolver.getFor(dir)));
   }
   return super.getStateWithValue(blockState, key, value);
 }
コード例 #2
0
 @Override
 public <E> Optional<BlockState> getStateWithValue(
     IBlockState blockState, Key<? extends BaseValue<E>> key, E value) {
   if (key.equals(Keys.PISTON_TYPE)) {
     final BlockPistonExtension.EnumPistonType pistonType =
         (BlockPistonExtension.EnumPistonType) value;
     return Optional.of((BlockState) blockState.withProperty(BlockPistonMoving.TYPE, pistonType));
   }
   if (key.equals(Keys.DIRECTION)) {
     final Direction dir = (Direction) value;
     return Optional.of(
         (BlockState)
             blockState.withProperty(BlockPistonMoving.FACING, DirectionResolver.getFor(dir)));
   }
   return super.getStateWithValue(blockState, key, value);
 }
コード例 #3
0
 @Override
 public Optional<BlockState> getStateWithData(
     IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
   if (manipulator instanceof ImmutablePoweredData) {
     return Optional.of(
         (BlockState)
             blockState.withProperty(
                 BlockButton.POWERED, ((ImmutablePoweredData) manipulator).powered().get()));
   }
   if (manipulator instanceof ImmutableDirectionalData) {
     final Direction dir = ((ImmutableDirectionalData) manipulator).direction().get();
     return Optional.of(
         (BlockState) blockState.withProperty(BlockButton.FACING, DirectionResolver.getFor(dir)));
   }
   return super.getStateWithData(blockState, manipulator);
 }
コード例 #4
0
 @Override
 public Optional<BlockState> getStateWithData(
     IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
   if (manipulator instanceof ImmutablePistonData) {
     final BlockPistonExtension.EnumPistonType pistonType =
         (BlockPistonExtension.EnumPistonType)
             (Object) ((ImmutablePistonData) manipulator).type().get();
     return Optional.of((BlockState) blockState.withProperty(BlockPistonMoving.TYPE, pistonType));
   }
   if (manipulator instanceof ImmutableDirectionalData) {
     final Direction dir = ((ImmutableDirectionalData) manipulator).direction().get();
     return Optional.of(
         (BlockState)
             blockState.withProperty(BlockPistonMoving.FACING, DirectionResolver.getFor(dir)));
   }
   return super.getStateWithData(blockState, manipulator);
 }
コード例 #5
0
 private ImmutableDirectionalData getDirectionalData(IBlockState blockState) {
   return ImmutableDataCachingUtil.getManipulator(
       ImmutableSpongeDirectionalData.class,
       DirectionResolver.getFor(blockState.getValue(BlockPistonMoving.FACING)));
 }