我正在制作的mod(Clothes.png和Clothes2.png)中的盔甲模型/纹理没有显示,而是我获得了正常的铁甲模型。为什么是这样?这是我的代码:
package com.example.AoT;
import javax.swing.text.html.parser.Entity;
import scala.tools.nsc.MainClass;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
public class ArmorTC extends ItemArmor{
public ArmorTC(int i, ArmorMaterial armorTC, int id, int placement) {
super(armorTC, id, placement);
setCreativeTab(CreativeTabs.tabCombat);
if (placement == 1){
this.setTextureName(AoT.MODID + ":TrainingCorpsJacket");
}
else if (placement == 2){
this.setTextureName(AoT.MODID + ":TrainingCorpsTrousers");
}
else if (placement == 3){
this.setTextureName(AoT.MODID + ":TrainingCorpsBoots");
}
}
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (stack.getItem() == AoT.TrainingCorpsJacket || stack.getItem() == AoT.TrainingCorpsBoots) {
return AoT.MODID + ":textures/models/armor/Clothes.png";
}
if (stack.getItem() == AoT.TrainingCorpsTrousers) {
return AoT.MODID + ":textures/models/armor/Clothes2.png";
} else {
return null;
}
}
}
更新的代码部分(我在调试器中的.itemID上收到错误,我应该在那里输入其他内容还是什么?)
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (stack.getItem().itemID == AoT.TrainingCorpsJacket.itemID || stack.getItem().itemID == AoT.TrainingCorpsBoots.itemID) {
return AoT.MODID + ":textures/models/armor/clothes.png";
}
if (stack.getItem().itemID == AoT.TrainingCorpsTrousers.itemID) {
return AoT.MODID + ":textures/models/armor/clothes2.png";
} else {
return null;
答案 0 :(得分:0)
问题在于您的if
条款:
if(stack.getItem() == AoT.TrainingCorpsJacket || stack.getItem() == AoT.TrainingCorpsBoots)
和
if(stack.getItem() == AoT.TrainingCorpsTrousers)
ItemStack#getItem()
会返回net.minecraft.item.Item
,无法使用参考比较==
进行比较。他们应该使用:
stack.getItem().itemID == AoT.TrainingCorpsJacket.itemID
将比较他们是否注册为同一项目。有关详细信息,请参阅Java == vs. equals()。