我正在制作国防部,但出现此错误:


  使用缺少的纹理,无法加载null:textures / items / TrainingCorpsBoots.png
  java.io.FileNotFoundException:null:纹理/物品/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");

最佳答案

调用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(其中mymodAoT.MODID分配给的文件)。

08-06 21:27