Minecraft modding 1.7.10纹理没有显示

时间:2014-07-14 16:04:52

标签: java textures minecraft

我正在制作一个mod,我收到了这个错误:

  

使用缺少的纹理,无法加载null:textures / items / TrainingCorpsBoots.png   java.io.FileNotFoundException:null:textures / items / TrainingCorpsBoots.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.TrainingCorpsJacket + ":TrainingCorpsJacket");
}   
else if (placement == 2){
        this.setTextureName(AoT.TrainingCorpsTrousers + ":TrainingCorpsTrousers");
}       
else if (placement == 3){
            this.setTextureName(AoT.TrainingCorpsBoots + ":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;
    }
}
}

我改变了这部分

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");

1 个答案:

答案 0 :(得分:1)

当你致电setTextureName()时,你正在传递它:

AoT.TrainingCorpsBoots + ":TrainingCorpsBoots"

由于它是一个项目,TrainingCorpsBoots部分将扩展为:

TrainingCorpsBoots
TrainingCorpsBoots.png
textures/items/TrainingCorpsBoots.png

您自己传递冒号(:),因此AoT.TrainingCorpsBoots必须null

您应该使用:

this.setTextureName(AoT.MODID + ":TrainingCorpsBoots");

并确保该文件位于mymod/textures/items/TrainingCorpsBoots.png(其中mymod是指定的AoT.MODID