Exemple #1
0
  private IBlockState flipBlock(final IBlockState blockState, final EnumFacing axis, boolean forced)
      throws FlipException {
    final IProperty propertyFacing = getProperty(blockState, "facing");
    if (propertyFacing instanceof PropertyDirection) {
      final Comparable value = blockState.getValue(propertyFacing);
      if (value instanceof EnumFacing) {
        final EnumFacing facing = getFlippedFacing(axis, (EnumFacing) value);
        if (propertyFacing.getAllowedValues().contains(facing)) {
          return blockState.withProperty(propertyFacing, facing);
        }
      }
    } else if (propertyFacing instanceof PropertyEnum) {
      if (BlockLever.EnumOrientation.class.isAssignableFrom(propertyFacing.getValueClass())) {
        final BlockLever.EnumOrientation orientation =
            (BlockLever.EnumOrientation) blockState.getValue(propertyFacing);
        final BlockLever.EnumOrientation orientationRotated =
            getFlippedLeverFacing(axis, orientation);
        if (propertyFacing.getAllowedValues().contains(orientationRotated)) {
          return blockState.withProperty(propertyFacing, orientationRotated);
        }
      }
    } else if (propertyFacing != null) {
      Reference.logger.error(
          "'{}': found 'facing' property with unknown type {}",
          BLOCK_REGISTRY.getNameForObject(blockState.getBlock()),
          propertyFacing.getClass().getSimpleName());
    }

    if (!forced && propertyFacing != null) {
      throw new FlipException(
          "'%s' cannot be flipped across '%s'",
          BLOCK_REGISTRY.getNameForObject(blockState.getBlock()), axis);
    }

    return blockState;
  }
 @Override
 public Class<T> getValueClass() {
   return property.getValueClass();
 }
Exemple #3
0
  private <T extends Comparable<T>> void defaultStateHelper(
      RenderState state, IProperty<T> property, Comparable<?> value) {

    state.withProperty(property, property.getValueClass().cast(value));
  }