Block textures and block names not loading minecraft forge

走远了吗. 提交于 2019-12-24 16:48:00

问题


I am making a mod for minecraft but I can't get the textures to load:

Also the names dont show up correctly (tile.Yarrite Ore.Name instead of Yarrite Ore):

here is the code I used to Create the block(YarriteOre.java):

package com.NoNameYetMod.common;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;

public class YarriteOre extends Block{
    public YarriteOre(int id,Material mat) {
        super(mat);
        this.setCreativeTab(CreativeTabs.tabBlock);
    }

    @Override
    public void registerBlockIcons(IIconRegister p_149651_1_){
        this.blockIcon = p_149651_1_.registerIcon("NoNameYetMod:Yarrite Ore");
    }
}

and here is the mod.java file in which I register the block in the game:

package com.NoNameYetMod.common;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Metadata;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = "NoNameYetMod", name = "The \"No Name\" Yet Mod", version = "1.0.0 (Warning: Alpha!)")

public class NoNameYetMod{

    @Metadata
    public static ModMetadata meta;
    //Yarrite
    public static Block YarriteOre;
    int YarriteOreID = 1001;

    @EventHandler
    public void init(FMLPreInitializationEvent event){
        //Yarrit
        YarriteOre = new YarriteOre(YarriteOreID, Material.rock).setHardness(1.5F).setBlockName("Yarrite Ore");

}

I tried renaming the icon to Yarrite Ore, Yarrite and YarritOre but none of them work! does anybody know what I'm doing wrong?

EDIT: I also tried .Png and .JPeg files but non of them worked...

EDIT: I have the items in the src/main/resources/assets/NoNameYetMod/Textures/blocks folder.


回答1:


To fix the name all you have to do in create a file called en_US.lang in \main\resources\assets\MOD_ID\lang. The file is a basic text file, notepad can edit it, and you should put in the crazy name you see, its technical name, and then what you want it to be called in-game name. Here is an example:

tile.Yarrite Ore.Name = Yarrite Ore

Do the same for items, just use item.X instead of tile.X.

Are you using forge for 1.7 or 1.8, the way textures are loaded was changed by a great deal in 1.8? For 1.7 all you need to do is add this just after the line with super(mat);

this.setBlockTextureName("MODID" + ":" + "yarriteOre");

Replace yarriteOre with the image name. There's no need to add .png at the end of the line, Minecraft does that when looking for the image. For basic blocks texturing, you don't need the registerBlockIcons() method.

Here's a link to some great Minecraft modding tutorials, 1.3-1.8. I've used them before and the're great help.

Link



来源:https://stackoverflow.com/questions/28770905/block-textures-and-block-names-not-loading-minecraft-forge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!