Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Minecraft 1.7.2有效设置纹理_Java_Textures_Minecraft - Fatal编程技术网

Java Minecraft 1.7.2有效设置纹理

Java Minecraft 1.7.2有效设置纹理,java,textures,minecraft,Java,Textures,Minecraft,我在每个单独的文件中设置纹理,这是一种无效的设置方式 this.setUnlocalizedName("ItemName"); this.setTextureName("MyModName:ItemName"); 这种方式对我来说是有意义的,但不起作用: this.setUnlocalizedName("ItemName"); this.setTextureName(OtherClassName.MODID + ":" + this.getUnlocalizedName()); “Other

我在每个单独的文件中设置纹理,这是一种无效的设置方式

this.setUnlocalizedName("ItemName");
this.setTextureName("MyModName:ItemName");
这种方式对我来说是有意义的,但不起作用:

this.setUnlocalizedName("ItemName");
this.setTextureName(OtherClassName.MODID + ":" + this.getUnlocalizedName());
“OtherClassName.MODID”是指另一个包含“MyModName”的类中的变量 getUnlocalizedName()获取已声明为“ItemName”的UnlocalizedName


有什么帮助吗?我不知道为什么它不起作用

getUnlocalizedName
有点奇怪-它返回传递给
setUnlocalizedName
的字符串,但开头带有“item.”。使用除臭代码的乐趣

这将有助于:

String name = "ItemName";
this.setUnlocalizedName(name);
this.setTextureName(OtherClassName.MODID + ":" + name);

请注意,它的效率不如“运行速度更快”,但如果您大量更改项目名称,则写入速度可能会更快。

我是否可以在删除“.item”后使用“.substring(5)”来删除“.item”?编辑:“.子字符串(5)不能正常工作。嗯,它不起作用,我有这个。setUnlocalizedName(“鹅卵石混合物”);this.setTextureName(MoreEquipment.MODID+this.getUnlocalizedName().substring(5));'啊,谢谢你!我知道我会错过这样的东西。为了使它更高效,我创建了另一个类,并为它提供了一个方法:public class SetTexture{public SetTexture(Item ItemName){ItemName.settextername(MoreEquipment.MODID+):“+ItemName.getUnlocalizedName().substring(5)}”它可以工作,但参数传递不起作用,我知道我需要传递'ItemName',但我不确定如何传递它现在我有:
public class SetTextureClass{public static void SetTexture(Item ItemName){ItemName.settexterName(MoreEquipment.MODID+”:“+ItemName.getUnlocalizedName().substring(5));}}
我用它来命名:
settexterClass.SetTexture(MoreEquipment.cobblestoneMixed);
settexterClass是方法所在的类。没有错误,但加载时游戏崩溃。帮助???