Java 类net.minecraft.util.IStringSerializable 实例源码

项目:ThermionicsWorld    文件:ItemBlockEquivalentState.java   
public static String toVanilla(IBlockState state) {
    StringBuilder result = new StringBuilder();
    Set<Entry<IProperty<?>, Comparable<?>>> entries = state.getProperties().entrySet();
    Iterator<Entry<IProperty<?>, Comparable<?>>> iter = entries.iterator();
    while(iter.hasNext()) {
        Entry<IProperty<?>, Comparable<?>> entry = iter.next();
        result.append(entry.getKey().getName());
        result.append('=');
        Comparable<?> value = entry.getValue();
        if (value instanceof IStringSerializable) {
            result.append(((IStringSerializable)value).getName());
        } else {
            result.append(entry.getValue().toString());
        }

        if (iter.hasNext()) result.append(',');
    }

    return result.toString();
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
项目:BaseClient    文件:PropertyEnum.java   
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
项目:BaseClient    文件:PropertyEnum.java   
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
项目:Thermionics    文件:ItemBlockEquivalentState.java   
public static String toVanilla(IBlockState state) {
    StringBuilder result = new StringBuilder();
    Set<Entry<IProperty<?>, Comparable<?>>> entries = state.getProperties().entrySet();
    Iterator<Entry<IProperty<?>, Comparable<?>>> iter = entries.iterator();
    while(iter.hasNext()) {
        Entry<IProperty<?>, Comparable<?>> entry = iter.next();
        result.append(entry.getKey().getName());
        result.append('=');
        Comparable<?> value = entry.getValue();
        if (value instanceof IStringSerializable) {
            result.append(((IStringSerializable)value).getName());
        } else {
            result.append(entry.getValue().toString());
        }

        if (iter.hasNext()) result.append(',');
    }

    return result.toString();
}
项目:Backmemed    文件:PropertyEnum.java   
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
项目:CustomWorldGen    文件:PropertyEnum.java   
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
项目:CommonUtils    文件:ModInitializerClient.java   
private void registerVariantBlocks(ProxyModBase proxy) {
    for (InfoBlock block : proxy.blocks) {
        if (!(block instanceof InfoBlockVariant))
            continue;
        InfoBlockVariant blockVar = (InfoBlockVariant) block;
        List<String> variants = Lists.newArrayList();
        for (Object metalObj : blockVar.getVariantProp().getAllowedValues()) {
            IStringSerializable value = (IStringSerializable) metalObj;
            String name = proxy.getModId() + ":" + value.getName() + blockVar.getVariantSuffix();
            variants.add(name);
        }
        ModelBakery.registerItemVariants(Item.getItemFromBlock(block.getBlock()),
                variants.stream().map(ResourceLocation::new).toArray(ResourceLocation[]::new));

        ModelLoader.setCustomStateMapper(block.getBlock(),
                (new StateMap.Builder()).withName(blockVar.getVariantProp())
                        .withSuffix(blockVar.getVariantSuffix())
                        .build());
    }
}
项目:TFC2    文件:PropertyClass.java   
protected PropertyClass(String name, Class valueClass, Collection allowedValues) 
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);
    Iterator iterator = allowedValues.iterator();

    while (iterator.hasNext())
    {
        IStringSerializable oenum = (IStringSerializable)iterator.next();
        String s1 = oenum.getName();

        if (this.nameToValue.containsKey(s1))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s1 + "\'");
        }

        this.nameToValue.put(s1, oenum);
    }
}
项目:TFC2    文件:PropertyClass.java   
protected PropertyClass(String name, Class valueClass, Collection allowedValues) 
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);
    Iterator iterator = allowedValues.iterator();

    while (iterator.hasNext())
    {
        IStringSerializable oenum = (IStringSerializable)iterator.next();
        String s1 = oenum.getName();

        if (this.nameToValue.containsKey(s1))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s1 + "\'");
        }

        this.nameToValue.put(s1, oenum);
    }
}
项目:ExpandedRailsMod    文件:PropertyEnum.java   
protected PropertyEnum(String name, Class<T> valueClass, Collection<T> allowedValues)
{
    super(name, valueClass);
    this.allowedValues = ImmutableSet.copyOf(allowedValues);

    for (T t : allowedValues)
    {
        String s = ((IStringSerializable)t).getName();

        if (this.nameToValue.containsKey(s))
        {
            throw new IllegalArgumentException("Multiple values have the same name \'" + s + "\'");
        }

        this.nameToValue.put(s, t);
    }
}
项目:HeroUtils    文件:BuildCraftProperty.java   
protected String valueName(Object value) {
    if (value == null) {
        return "null";
    } else if (value instanceof IStringSerializable) {
        return ((IStringSerializable) value).getName();
    } else if (value instanceof Enum) {
        return ((Enum<?>) value).name().toLowerCase(Locale.ROOT);
    } else {
        return value.toString().toLowerCase(Locale.ROOT);
    }
}
项目:Bewitchment    文件:ModelHandler.java   
public static <T extends Enum<T> & IStringSerializable> void registerModel(Item item, Class<T> clazz) {
    for (T t : clazz.getEnumConstants()) {
        ResourceLocation location = new ResourceLocation(item.getRegistryName() + "_" + t.getName());
        ModelResourceLocation modelResourceLocation = new ModelResourceLocation(location, "inventory");
        ModelLoader.setCustomModelResourceLocation(item, t.ordinal(), modelResourceLocation);
    }
}
项目:Solar    文件:ModelHandler.java   
public static <T extends Enum<T> & IStringSerializable> void registerModel(Item item, Class<T> clazz) {
    for(T t : clazz.getEnumConstants()) {
        ResourceLocation location = new ResourceLocation(item.getRegistryName() + "_" + t.getName());
        ModelResourceLocation modelResourceLocation = new ModelResourceLocation(location, "inventory");
        ModelLoader.setCustomModelResourceLocation(item, t.ordinal(), modelResourceLocation);
    }
}
项目:Solar    文件:ResourceLibrary.java   
public static <T extends Enum<T> & IStringSerializable> ImmutableMap<T, ResourceLocation> from(Class<T> clazz, String name, Function<String, ResourceLocation> function) {
    ImmutableMap.Builder<T, ResourceLocation> builder = ImmutableMap.builder();
    T[] enums = clazz.getEnumConstants();
    for(T enu : enums) {
        builder.put(enu, function.apply(name + enu.getName()));
    }
    return builder.build();
}
项目:Thermionics    文件:ItemSubtyped.java   
@Override
public String[] getModelLocations() {
    ArrayList<String> variants = new ArrayList<String>();
    for(Enum<T> t : enumValues) {
        if (t instanceof IStringSerializable) {
            variants.add(id + "." + ((IStringSerializable)t).getName() );
        } else {
            variants.add(id + "." + t.name().toLowerCase());
        }
    }
    return variants.toArray(new String[variants.size()]);

}
项目:Backmemed    文件:ConnectedParser.java   
private static Object getValueName(Comparable p_getValueName_0_)
{
    if (p_getValueName_0_ instanceof IStringSerializable)
    {
        IStringSerializable istringserializable = (IStringSerializable)p_getValueName_0_;
        return istringserializable.getName();
    }
    else
    {
        return p_getValueName_0_.toString();
    }
}
项目:CustomWorldGen    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz)
{
    /**
     * Create a new PropertyEnum with all Enum constants of the given class that match the given Predicate.
     */
    return create(name, clazz, Predicates.<T>alwaysTrue());
}
项目:CustomWorldGen    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Predicate<T> filter)
{
    /**
     * Create a new PropertyEnum with the specified values
     */
    return create(name, clazz, Collections2.<T>filter(Lists.newArrayList(clazz.getEnumConstants()), filter));
}
项目:CustomWorldGen    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, T... values)
{
    /**
     * Create a new PropertyEnum with the specified values
     */
    return create(name, clazz, Lists.newArrayList(values));
}
项目:wizards-of-lua    文件:Converters.java   
@Override
public <T> Object toLua(T value) throws ConversionException {
  checkNotNull(value, "value==null!");

  if (value instanceof TableData) {
    TableData data = (TableData) value;
    return tableDataConverter.toLua(data);
  }

  @SuppressWarnings("unchecked")
  Class<T> javaClass = (Class<T>) value.getClass();
  LuaClass<T, ?> cls = getByJavaClass(javaClass);
  if (cls != null) {
    return cls.getLuaInstance(value);
  }
  if (value instanceof Enum) {
    Enum<?> vEnum = (Enum<?>) value;
    if (vEnum instanceof IStringSerializable) {
      return ByteString.of(((IStringSerializable) vEnum).getName());
    }
    return ByteString.of(vEnum.name());
  }
  if (value instanceof IStringSerializable) {
    return ByteString.of(((IStringSerializable) value).getName());
  }
  return super.toLua(value);
}
项目:wizards-of-lua    文件:BlockPropertyConverter.java   
public static Object toLua(Comparable<?> obj) {
  if (obj instanceof IStringSerializable) {
    IStringSerializable s = (IStringSerializable) obj;
    return s.getName();
  }
  if (obj instanceof Enum) {
    Enum<?> e = (Enum<?>) obj;
    return e.name();
  }
  if (obj instanceof String) {
    String str = (String) obj;
    if ("true".equals(obj)) {
      return true;
    }
    if ("false".equals(obj)) {
      return false;
    }
    Object result = Ints.tryParse(str);
    if (result != null) {
      return result;
    }
    result = Doubles.tryParse(str);
    if (result != null) {
      return result;
    }
  }
  return Conversions.canonicalRepresentationOf(obj);
}
项目:AquaRegia    文件:ModBlocks.java   
/**
 * Register a group of slab blocks
 *
 * @param slabGroup The slab group
 */
@SuppressWarnings("unchecked")
private static <
        VARIANT extends Enum<VARIANT> & IStringSerializable,
        VARIANTS extends Iterable<VARIANT> & IStringSerializable,
        SLAB extends BlockSlabAquaRegia<VARIANT, VARIANTS, SLAB>
        > void registerSlabGroup(BlockSlabAquaRegia.SlabGroup<VARIANT, VARIANTS, SLAB> slabGroup) {
    registerBlock(slabGroup.singleSlab, slab -> new ItemSlab(slab, slabGroup.singleSlab, slabGroup.doubleSlab));
    registerBlock(slabGroup.doubleSlab, null); // No item form for the double slab
    slabGroup.setItem((ItemSlab) Item.getItemFromBlock(slabGroup.singleSlab));
}
项目:CommonUtils    文件:ModInitializerClient.java   
private void registerBlocksItemModels(ProxyModBase proxy) {
    for (InfoBlock block : proxy.blocks) {
        if (block instanceof InfoBlockVariant) {
            InfoBlockVariant blockVar = (InfoBlockVariant) block;
            for (Object valueObj : blockVar.getVariantProp().getAllowedValues()) {
                IStringSerializable value = (IStringSerializable) valueObj;
                String name = proxy.getModId() + ":" + value.getName() + blockVar.getVariantSuffix();
                ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block.getBlock()),
                        blockVar.getMeta(value), new ModelResourceLocation(name, "inventory"));
            }
        } else {
            ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(block.getBlock()),
                    new SimpleItemMeshDefinition(proxy.getModId() + ":" + block.getName()));
        }
    }
    for (InfoItem item : proxy.items) {
        if (item.getVariants() == null) {
            ModelLoader.setCustomMeshDefinition(item.getItem(),
                    new SimpleItemMeshDefinition(item.getDomain() + ":" + item.getName()));
        } else {
            int i = 0;
            for (String variant : item.getVariants()) {
                ModelLoader.setCustomModelResourceLocation(item.getItem(), i++,
                        new ModelResourceLocation(item.getDomain() + ":" + variant, "inventory"));
            }
        }
    }
}
项目:UsefulNullifiers    文件:ModRenderers.java   
private static <T extends Enum<T> & IStringSerializable> void registerVariantsDefaulted(
        Block b, Class<T> enumclazz, String variantHeader)
{
    Item item = Item.getItemFromBlock(b);
    for (T e : enumclazz.getEnumConstants())
    {
        String variantName = variantHeader + "="
                + e.getName().toLowerCase();
        ModelLoader.setCustomModelResourceLocation(item, e.ordinal(),
                new ModelResourceLocation(b.getRegistryName(),
                        variantName));
    }
}
项目:ExpandedRailsMod    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz)
{
    /**
     * Create a new PropertyEnum with all Enum constants of the given class that match the given Predicate.
     */
    return create(name, clazz, Predicates.<T>alwaysTrue());
}
项目:ExpandedRailsMod    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Predicate<T> filter)
{
    /**
     * Create a new PropertyEnum with the specified values
     */
    return create(name, clazz, Collections2.<T>filter(Lists.newArrayList(clazz.getEnumConstants()), filter));
}
项目:ExpandedRailsMod    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, T... values)
{
    /**
     * Create a new PropertyEnum with the specified values
     */
    return create(name, clazz, Lists.newArrayList(values));
}
项目:Bewitchment    文件:ModelHandler.java   
public static <T extends Enum<T> & IStringSerializable> void registerModel(Block block, Class<T> clazz) {
    Item item = Item.getItemFromBlock(block);
    if (item == Items.AIR) throw new UnsupportedOperationException("This block has no Item!");
    registerModel(item, clazz);
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
/**
 * Get the name for the given value.
 */
public String getName(T value)
{
    return ((IStringSerializable)value).getName();
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz)
{
    return create(name, clazz, Predicates.<T>alwaysTrue());
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Predicate<T> filter)
{
    return create(name, clazz, Collections2.<T>filter(Lists.newArrayList(clazz.getEnumConstants()), filter));
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, T... values)
{
    return create(name, clazz, Lists.newArrayList(values));
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Collection<T> values)
{
    return new PropertyEnum(name, clazz, values);
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
/**
 * Get the name for the given value.
 */
public String getName(T value)
{
    return ((IStringSerializable)value).getName();
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz)
{
    return create(name, clazz, Predicates.<T>alwaysTrue());
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Predicate<T> filter)
{
    return create(name, clazz, Collections2.<T>filter(Lists.newArrayList(clazz.getEnumConstants()), filter));
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, T... values)
{
    return create(name, clazz, Lists.newArrayList(values));
}
项目:DecompiledMinecraft    文件:PropertyEnum.java   
public static <T extends Enum<T> & IStringSerializable> PropertyEnum<T> create(String name, Class<T> clazz, Collection<T> values)
{
    return new PropertyEnum(name, clazz, values);
}