Не отображается текстура предмета в инвентаре

Версия Minecraft
1.7.10
37
1
0
Сделал смену текстуры при пкм и в руке текстура меняется, а вот в слоте "эмо" текстура постоянно
Java:
public class ItemXpHolder extends Item {

    

    private IIcon[] icons = new IIcon[2];

    private String texturename = "randommagics:XpHolder";

    

    public ItemXpHolder() {

        super();

        

        this.setTextureName("randommagics:XpHolder_0");

        this.setCreativeTab(Init.TabRandomMagics);

        this.setUnlocalizedName("ItemXpHolder");

        this.setMaxStackSize(1);

    }

    

    public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)

    {

        if(player.isSneaking()) {

            int xp;

            if(itemstack.hasTagCompound())

                xp = itemstack.getTagCompound().getInteger("xp");

            else

                xp = 0;

            List ents = getXPOrbs(player.posX, player.posY, player.posZ, player.getEntityWorld());

            for(int i = 0; i < ents.size(); i++) {

                EntityXPOrb orb = (EntityXPOrb)ents.get(i);

                orb.setDead();

                xp += 1;

            }

            if(!itemstack.hasTagCompound()) {

                NBTTagCompound nbt = new NBTTagCompound();

                itemstack.setTagCompound(nbt);

            }

            itemstack.getTagCompound().setInteger("xp", xp);

        }

        else {

        if(!itemstack.hasTagCompound()) {

            NBTTagCompound nbt = new NBTTagCompound();

            itemstack.setTagCompound(nbt);

        }

        int xp = itemstack.stackTagCompound.getInteger("xp");

        if(xp == 0) {

            xp = player.experienceTotal;

            player.addExperienceLevel(-(player.experienceLevel + 1));

        }

        else {

            player.addExperience(xp);

            xp = 0;

        }

        itemstack.stackTagCompound.setInteger("xp", xp);

        }

        return itemstack;

    }

    

    public void addInformation(ItemStack itemstack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) {

        if(itemstack.hasTagCompound()) {

            int xp = itemstack.stackTagCompound.getInteger("xp");

            list.add(1, String.valueOf(xp));

        }

    }

    

    public void registerIcons(IIconRegister reg) {

        for (int i = 0; i < 2; i ++) {

            this.icons[i] = reg.registerIcon(this.texturename + "_" + i);

        }

    }

    

    public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

    {

        if(stack.hasTagCompound() && stack.getTagCompound().getInteger("xp") > 0)

            return icons[1];

        else

            return icons[0];

    }

}
2018-05-27_20.21.00.png
 

timaxa007

Модератор
5,831
409
672
Потому-что этот метод с такими аргументами, больше предназначаться для лука, в руке натягивается, а в инвентаре стандартная иконка.
Тебе нужен getIcon(ItemStack stack, int pass).
 

timaxa007

Модератор
5,831
409
672
37
1
0
Java:
public class Init{

    public static Item ItemXpHolder;
    
    public static void init()
    {
        ItemXpHolder = new ItemXpHolder();
        GameRegistry.registerItem(ItemXpHolder, "ItemXpHolder");
    }
    
    public static CreativeTabs TabRandomMagics = new TabRandomMagics(CreativeTabs.getNextID(), "RandomMagics");
}
Java:
public class Main {

    @Mod.Instance
    public static Main instance;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        Init.init();
    }

    @EventHandler
    public void init(FMLInitializationEvent event) {
        
    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
        BookTab.setup();
        Researches.Research();
    }
}
 
Java:
public class Main {
    @Mod.Instance
    public static Main instance;
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {  

    }
    @EventHandler
    public void init(FMLInitializationEvent event) {
       Init.init();
    }
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
        BookTab.setup();
        Researches.Research();
    }
}
Так попробуй
 
Сверху