本文整理匯總了Java中net.minecraft.util.IStringSerializable.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java IStringSerializable.getName方法的具體用法?Java IStringSerializable.getName怎麽用?Java IStringSerializable.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.IStringSerializable
的用法示例。
在下文中一共展示了IStringSerializable.getName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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());
}
}
示例2: 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);
}
}
示例3: 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();
}
}
示例4: 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);
}
示例5: 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"));
}
}
}
}
示例6: getVariantName
import net.minecraft.util.IStringSerializable; //導入方法依賴的package包/類
public static String getVariantName(IStringSerializable variant) {
return "variant=" + variant.getName();
}