I'm currently developing a Minecraft mod using NeoForge, and I've encountered an issue when registering a custom item. After adding my texture file for the item, I receive the following error when trying to run the client:
Execution failed for task ':generateModMetadata'.
Could not copy file 'C:\Users\casro\Documents\Minecraft Modding\NeoForge\NeoForge-FalloutMc\src\main\templates\assets\falloutmc\texures\item\nuka_cola.png' to 'C:\Users\casro\Documents\Minecraft Modding\NeoForge\NeoForge-FalloutMc\build\generated\sources\modMetadata\assets\falloutmc\texures\item\nuka_cola.png'.Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript30.groovy: 8: token recognition error at: '\t' @ line 8, column 38.
{3D� ��#��!��-i�l�����a�e�{�m�a���$ �R.���ɇ�d#�J8?;��,�]'I�V�$�c������&�f�u�=����s�j��W(�� �^�ʔ��������i���D�K�r*U����c}�;I�_�(�V#GA��0���C7�[���� �K���tS��a��]Z9�%iƢ��/)�8�3Ay��ݺ�a�[��~5���� IEND�B`�""");
^
Additionally, I noticed that my project directory contains a templates folder instead of a resources folder. When I rename the templates folder to resources, the client runs, but I encounter this new error:
File C:\Users\********\Documents\Minecraft Modding\NeoForge\NeoForge-FalloutMc\build\classes\java\main is not a valid mod file
com.electronwill.nightconfig.core.io.ParsingException: Invalid bare key: '${mod_id}'
Here is the screen i get when i renamed the templates folder to resources:
I've attached the full crash report and latest log here: Crash-Report and Latest Log
Maybe these parts of my code might help:
(Main mod file) FalloutMc.java:
package net.cassis2310.falloutmc;
import net.cassis2310.falloutmc.item.ModItems;
import org.slf4j.Logger;
import com.mojang.logging.LogUtils;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.event.server.ServerStartingEvent;
// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(FalloutMc.MOD_ID)
public class FalloutMc
{
public static final String MOD_ID = "falloutmc";
private static final Logger LOGGER = LogUtils.getLogger();
// The constructor for the mod class is the first code that is run when your mod is loaded.
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
public FalloutMc(IEventBus modEventBus, ModContainer modContainer)
{
// Register the commonSetup method for modloading
modEventBus.addListener(this::commonSetup);
// Register ourselves for server and other game events we're interested in.
// Note that this is necessary if and only if we want *this* class (ExampleMod) to respond directly to events.
// Don't add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.
NeoForge.EVENT_BUS.register(this);
ModItems.register(modEventBus);
// Register the item to a creative tab
modEventBus.addListener(this::addCreative);
// Register our mod's ModConfigSpec so that FML can create and load the config file for us
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
}
private void commonSetup(final FMLCommonSetupEvent event)
{
//
}
// Add the example block item to the building blocks tab
private void addCreative(BuildCreativeModeTabContentsEvent event)
{
//
}
// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event)
{
//;
}
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
@EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientModEvents
{
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event)
{
//
}
}
}
(Registry) ModItems.java:
package net.cassis2310.falloutmc.item;
import net.cassis2310.falloutmc.FalloutMc;
import net.minecraft.world.item.Item;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;
public class ModItems {
public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(FalloutMc.MOD_ID);
public static final DeferredItem<Item> NUKA_COLA = ITEMS.register("nuka_cola",
() -> new Item(new Item.Properties()));
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
}
}
(Item Model) nuka_cola.json:
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "falloutmc:item/nuka_cola"
}
}
I have am using the latest ModDevGradle MDK from NeoForge.
Any help or guidance would be greatly appreciated.
Don't put assets and data in the templates folder, use the resources folder