我在每个单独的文件中设置纹理,这是一种低效的设置方法
this.setUnlocalizedName("ItemName");
this.setTextureName("MyModName:ItemName");
这种方式对我来说是有意义的,但行不通:
this.setUnlocalizedName("ItemName");
this.setTextureName(OtherClassName.MODID + ":" + this.getUnlocalizedName());
"OtherClassName。MODID'引用了另一个类中包含'MyModName'的变量this.getUnlocalizedName()获取已声明的UnlocalizedName, 'ItemName'
帮忙吗?我不知道为什么它不起作用。
getUnlocalizedName
有点奇怪-它返回您传递给setUnlocalizedName
的字符串,但以"item."开头。使用去混淆代码的乐趣…
可以:
String name = "ItemName";
this.setUnlocalizedName(name);
this.setTextureName(OtherClassName.MODID + ":" + name);
请注意,它不是更高效,在运行更快,但它可能会更快,如果你改变项目名称很多。