Jump to content

[1.12] [Solved] Lang file not working with Blocks/ItemBlocks


Nayrisian

Recommended Posts

Description of the issue:

Textures, registration and item localisation all work correctly, but I am currently stuck on getting tiles to localise.

Here's a visual example of the issue...

Spoiler

04221a0ca6.png

3b78932938.png

As you can see from the pictures, my copper ingot works perfectly, but the tile (Copper ore) doesn't.

 

Here is the code stuff:

Spoiler

public class CopperOre extends Block {
    public CopperOre() {
        super(Material.ROCK);
        setRegistryName(new ResourceLocation(Ref.MOD_ID, Ref.COPPER_ORE));
        setUnlocalizedName(getRegistryName().getResourcePath());
    }

    @SideOnly(Side.CLIENT)
    public void initModel() {
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    }
}

public class CopperIngot extends Item {
    public CopperIngot() {
        setRegistryName(new ResourceLocation(Ref.MOD_ID, Ref.COPPER_INGOT));
        setUnlocalizedName(getRegistryName().getResourcePath());
    }

    @SideOnly(Side.CLIENT)
    public void initModel() {
        ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    }
}

public class ModBlocks {
    @GameRegistry.ObjectHolder(Ref.RESOURCE_PREFIX + Ref.COPPER_ORE)
    public static CopperOre copperOre;

    @SideOnly(Side.CLIENT)
    public static void initModels() {
        copperOre.initModel();
    }
}

public class ModItems {
    @GameRegistry.ObjectHolder(Ref.RESOURCE_PREFIX + Ref.COPPER_INGOT)
    public static CopperIngot copperIngot;

    @SideOnly(Side.CLIENT)
    public static void initModels() {
        copperIngot.initModel();
    }
}

public class Ref {
    public static final String MOD_ID = "tau";
    public static final String RESOURCE_PREFIX = Ref.MOD_ID + ":";
    public static final String NAME = "Tau mod";
    public static final String CLIENT_PROXY = "com.taunetwork.dev.tau.proxy.ClientProxy";
    public static final String SERVER_PROXY = "com.taunetwork.dev.tau.proxy.ServerProxy";

    public static final String COPPER_ORE = "copper_ore";
    public static final String COPPER_INGOT = "copper_ingot";
}

@Mod.EventBusSubscriber
public class CommonProxy {
    // Config instance
    public static Configuration config;

    public void preInit(FMLPreInitializationEvent event) {
        File directory = event.getModConfigurationDirectory();
        config = new Configuration(new File(directory.getPath(), "tau.cfg"));
        Config.readConfig();
    }

    public void init(FMLInitializationEvent event) {
    }

    public void postInit(FMLPostInitializationEvent event) {
        if (config.hasChanged()) {
            config.save();
        }
    }

    @SubscribeEvent
    public static void registerBlocks(RegistryEvent.Register<Block> event) {
        event.getRegistry().register(new CopperOre());
    }

    @SubscribeEvent
    public static void registerItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().register(new ItemBlock(ModBlocks.copperOre)
                .setRegistryName(ModBlocks.copperOre.getRegistryName())
                .setUnlocalizedName(ModBlocks.copperOre.getRegistryName().getResourcePath()));

        event.getRegistry().register(new CopperIngot());
    }
}

@Mod.EventBusSubscriber(Side.CLIENT)
public class ClientProxy extends CommonProxy {
    @Override
    public void preInit(FMLPreInitializationEvent e) {
        super.preInit(e);
    }

    @SubscribeEvent
    public static void registerModels(ModelRegistryEvent event) {
        ModBlocks.initModels();
        ModItems.initModels();
    }
}

public class ServerProxy extends CommonProxy {

}

Here is the directory in the IntelliJ IDE

Spoiler

63fbca57cc.png

And finally the main attraction...

en_us.lang

# Blocks
tile:copper_ore.name=Copper Ore
item:copper_ore.name=Copper Ore
block:copper_ore.name=Copper Ore
# Items
item.copper_ingot.name=Copper Ingot

 

I was testing with numerous ways of trying to get the localisation file to recognise the block but to no avail.

Note: I do not use the mod id of the mod in my localisation files because I pass in the registry path string, I would doubt blocks and items have different unlocalised names based on the same parameters inputted... But feel free to explain if they do.

 

[17:43:57] [main/INFO] [tau/tau]: Copper Ore unlocalised name: tile.copper_ore
[17:43:57] [main/INFO] [tau/tau]: Copper Ore registry name: tau:copper_ore
[17:43:57] [main/INFO] [tau/tau]: Copper Ore Item unlocalised name: tile.copper_ore
[17:43:57] [main/INFO] [tau/tau]: Copper Ore Item registry name: tau:copper_ore
[17:43:57] [main/INFO] [tau/tau]: Copper Ingot unlocalised name: item.copper_ingot
[17:43:57] [main/INFO] [tau/tau]: Copper Ingot registry name: tau:copper_ingot

Finally the registry names and unlocalised names of the blocks/items in question, outputted using the logger during post initialisation, for my own verification that I haven't missed anything when registering the objects.

 

On the same context as the post itself, is the technique I am using to register blocks better or the same as doing:

public CopperOre() {
    super(Material.ROCK);
    setRegistryName(new ResourceLocation(Ref.MOD_ID, Ref.COPPER_ORE));
    setUnlocalizedName(getRegistryName().toString());
}

Or does it not exactly matter for Forge conventions?

 

fml-client-latest.log

Edited by Nayrisian
Issue solved
Link to comment
Share on other sites

Just now, Nayrisian said:

Omg... I cannot believe I missed that. Thank you for that quick evaluation... xD

No problem.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.