本文整理汇总了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();
}