2015-07-31 3 views
0

Я пытаюсь добавить текстуру к элементу, но текстура просто не появляется. У меня есть текстура, и в правом каталоге файлов, но пока в игре она не отображается. Таким образом, я думаю, что это ошибка в моем коде.Текстуры не отображаются

Для файла всего класса, смотрите ниже:

package Moonstone; 

import cpw.mods.fml.common.Mod; 
import cpw.mods.fml.common.Mod.EventHandler; 
import cpw.mods.fml.common.event.FMLInitializationEvent; 
import cpw.mods.fml.common.event.FMLPostInitializationEvent; 
import cpw.mods.fml.common.event.FMLPreInitializationEvent; 
import cpw.mods.fml.common.registry.GameRegistry; 
import net.minecraft.creativetab.CreativeTabs; 
import net.minecraft.init.Items; 
import net.minecraft.item.Item; 
import net.minecraft.item.ItemStack; 
import net.minecraftforge.common.util.EnumHelper; 

@Mod(modid = "ms", name = "Moonstone", version = "1.0") 
public class MoonstoneMain { 
    public static Item moonstone; 

    @EventHandler 
    public void preInit(FMLPreInitializationEvent event) { 
     //All init 
     moonstone = new Moonstone().setUnlocalizedName("Moonstone").setTextureName("moonstone").setMaxStac kSize(64); 
     GameRegistry.registerItem(moonstone,  moonstone.getUnlocalizedName().substring(5)); 
    } 

    @EventHandler 
    public void init(FMLInitializationEvent event) { 
     //Proxy, TileEntity, entity, GUI and packet registering 
    } 

    @EventHandler 
    public void postInit(FMLPostInitializationEvent event) {  
    } 

    public static CreativeTabs tabMoonstone = new CreativeTabs("tabMoonstone"){ 
     @Override 
     public Item getTabIconItem(){ 
      return new ItemStack(Items.stick).getItem(); 
     } 
    }; 
} 

Для всего пункта, посмотрите ценам ниже

moonstone = new Moonstone().setUnlocalizedName("Moonstone").setTextureName("moonstone").setMaxStackSize(64);// I have tried with ms:moonstone and without, both don't work. 
GameRegistry.registerItem(moonstone, moonstone.getUnlocalizedName().substring(5)); 

ответ

0

Рекомендуемые изменения, но не обязательно:

First: 
When registering the item you should remove the .substring(5), 
having this in will name the item "Moons" instead of "Moonstone". 

Second: 
unlocalized names should always be lowercase and should be formatted 
as modid_itemname 

Third: 
Package names should be lowercase, package moonstone 

Fourth: 
Your should make a Refstrings.java file and put the modid, version and name in it 
package Moonstone 

public RefStrings{ 
    public static String NAME = "Moonstone"; 
    public static String MODID = "ms"; 
    public static String VERSION = "1.0"; 
} 

Необходимые изменения :

Your setTextureName should be passed "ms:moonstone" 

You didn't post your folder structure but it should look like this: 
src/main/java/Moonstone/MoonstoneMain.java 
src/main/resources/assests/ms/textures/items/moonstone.png 

Возможно, что некоторые из рекомендуемых изменений помогут решить проблему, minecraft может немного похудеть с наименованием.

Смежные вопросы