0

My armor models/textures from the mod I'm making (Clothes.png and Clothes2.png) aren't displaying and instead i get a normal iron armor model. Why is this? This is my code:

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;
    }
}
}

UPDATED PART OF CODE (I'm getting an error at .itemID in the debugger, should i type something else there or what?)

    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;
Marcus
  • 25
  • 1
  • 4
  • Where does Scala come into this? When you step through your code with your debugger what do you see? I suspect the problem is not in the code you have shown. – Peter Lawrey Jul 14 '14 at 19:44
  • What is Scala? No, the debugger shows no errors. Neither does the log. That's why I'm confused. – Marcus Jul 14 '14 at 19:47
  • You have added tools for Scala which is another language. `import scala.tools.nsc.MainClass;` – Peter Lawrey Jul 14 '14 at 19:52
  • If you the debugger is not showing any errors, either you are not looking hard enough, you can't expect it to throw an exception for example, you have to be sure the values are right, but more likely the problem is somewhere else. – Peter Lawrey Jul 14 '14 at 19:53
  • 1
    I have no idea how that got in there, but i deleted it and there were no errors. – Marcus Jul 14 '14 at 19:55
  • But the problem persists. What more should I check/post? – Marcus Jul 14 '14 at 20:11
  • You could ask a Minecraft forum, or read the code called to see what it expects. – Peter Lawrey Jul 14 '14 at 20:24

1 Answers1

0

The problem is with your if clauses:

if(stack.getItem() == AoT.TrainingCorpsJacket || stack.getItem() == AoT.TrainingCorpsBoots)

And:

if(stack.getItem() == AoT.TrainingCorpsTrousers)

ItemStack#getItem() returns a net.minecraft.item.Item, which can't be compared using the reference comparison ==. They should be using:

stack.getItem().itemID == AoT.TrainingCorpsJacket.itemID

Which will compare whether they're registered as the same item. For more information, see Java == vs. equals().

Community
  • 1
  • 1
MrLore
  • 3,759
  • 2
  • 28
  • 36
  • @Marcus If you're getting an error on `itemID` (which one?) it's probably because `AoT.TrainingCorpsTrousers` isn't an item, make sure it is. – MrLore Jul 15 '14 at 13:43
  • I give up. I think going and learning java first, before trying to mod will be a wiser choice, won't it? Thanks for the help anyway! – Marcus Jul 16 '14 at 11:14