當前位置: 首頁>>代碼示例>>Java>>正文


Java IStringSerializable類代碼示例

本文整理匯總了Java中net.minecraft.util.IStringSerializable的典型用法代碼示例。如果您正苦於以下問題:Java IStringSerializable類的具體用法?Java IStringSerializable怎麽用?Java IStringSerializable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IStringSerializable類屬於net.minecraft.util包,在下文中一共展示了IStringSerializable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toVanilla

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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();
}
 
開發者ID:elytra,項目名稱:ThermionicsWorld,代碼行數:21,代碼來源:ItemBlockEquivalentState.java

示例2: PropertyEnum

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:18,代碼來源:PropertyEnum.java

示例3: registerVariantBlocks

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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());
	}
}
 
開發者ID:hea3ven,項目名稱:CommonUtils,代碼行數:21,代碼來源:ModInitializerClient.java

示例4: PropertyClass

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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);
	}
}
 
開發者ID:Deadrik,項目名稱:TFC2,代碼行數:20,代碼來源:PropertyClass.java

示例5: valueName

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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);
    }
}
 
開發者ID:Herobone,項目名稱:HeroUtils,代碼行數:12,代碼來源:BuildCraftProperty.java

示例6: registerModel

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:8,代碼來源:ModelHandler.java

示例7: registerModel

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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);
	}
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:8,代碼來源:ModelHandler.java

示例8: from

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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();
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:9,代碼來源:ResourceLibrary.java

示例9: getModelLocations

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
@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()]);
	
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:14,代碼來源:ItemSubtyped.java

示例10: getValueName

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:13,代碼來源:ConnectedParser.java

示例11: create

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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());
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:PropertyEnum.java

示例12: toLua

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
@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);
}
 
開發者ID:wizards-of-lua,項目名稱:wizards-of-lua,代碼行數:28,代碼來源:Converters.java

示例13: toLua

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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);
}
 
開發者ID:wizards-of-lua,項目名稱:wizards-of-lua,代碼行數:29,代碼來源:BlockPropertyConverter.java

示例14: registerSlabGroup

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:droidicus,項目名稱:AquaRegia,代碼行數:16,代碼來源:ModBlocks.java

示例15: registerBlocksItemModels

import net.minecraft.util.IStringSerializable; //導入依賴的package包/類
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"));
			}
		}
	}
}
 
開發者ID:hea3ven,項目名稱:CommonUtils,代碼行數:29,代碼來源:ModInitializerClient.java


注:本文中的net.minecraft.util.IStringSerializable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。