@SuppressWarnings({"rawtypes", "unchecked"})
  private static boolean putMatchingProperty(
      final Map<IProperty, Comparable> map,
      final IBlockState blockState,
      final String name,
      final String value,
      final boolean strict)
      throws LocalizedException {
    for (final IProperty property : blockState.getPropertyNames()) {
      if (property.getName().equalsIgnoreCase(name)) {
        final Collection<Comparable> allowedValues = property.getAllowedValues();
        for (final Comparable allowedValue : allowedValues) {
          if (String.valueOf(allowedValue).equalsIgnoreCase(value)) {
            map.put(property, allowedValue);
            return true;
          }
        }
      }
    }

    if (strict) {
      throw new LocalizedException(
          Names.Messages.INVALID_PROPERTY_FOR_BLOCK,
          name + "=" + value,
          BLOCK_REGISTRY.getNameForObject(blockState.getBlock()));
    }

    return false;
  }
示例#2
0
  private IProperty getProperty(final IBlockState blockState, final String name) {
    for (final IProperty prop : (Set<IProperty>) blockState.getProperties().keySet()) {
      if (prop.getName().equals(name)) {
        return prop;
      }
    }

    return null;
  }
示例#3
0
  private <T extends Comparable<T>> String getNameHelper(IProperty<T> property) {

    return property.getName(getValue(property));
  }
 @Override
 public String getValueName(T value) {
   return property.getName(value);
 }
 @Override
 public String getAttributeName() {
   return property.getName();
 }