Probably a common issue with a simple fix, but i cannot figure it out, the copper ingot texture & name are not registering in testing.
I'm following TechnoVision's 1.15.2 modding tutorials, for reference.
Here's the 16x16 png texture for the ingot, which I have put in src/main/resources/assets/necessarytechnology/textures/items:
It's file shares the same name as the item, copper_ingot.
NecessaryTechonology.java, which is in src/main/java/com.cyphon.necessarytechnology
package com.cyphon.necessarytechnology;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import util.RegistryHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.stream.Collectors;
@Mod("necessarytechnology")
public class NecessaryTechnology
{
private static final Logger LOGGER = LogManager.getLogger();
public static final String MOD_ID = "necessarytechnology";
public NecessaryTechnology() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
RegistryHandler.init();
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event)
{
LOGGER.info("HELLO FROM PREINIT");
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
}
private void doClientStuff(final FMLClientSetupEvent event) {
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
}
private void enqueueIMC(final InterModEnqueueEvent event)
{
InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
}
private void processIMC(final InterModProcessEvent event)
{
LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.getMessageSupplier().get()).
collect(Collectors.toList()));
}
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
LOGGER.info("HELLO from server starting");
}
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {
@SubscribeEvent
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
LOGGER.info("HELLO from Register Block");
}
}
}
ItemBase.java, which is in src/main/java/items:
package items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
public class ItemBase extends Item {
public ItemBase() {
super(new Item.Properties().group(ItemGroup.MATERIALS));
}
}
RegistryHandler.java, which is in src/main/java/util:
package util;
import com.cyphon.necessarytechnology.NecessaryTechnology;
import items.ItemBase;
import net.minecraft.item.Item;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
public class RegistryHandler {
public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, NecessaryTechnology.MOD_ID);
public static void init() {ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());}
// Items
public static final RegistryObject<Item> COPPER_INGOT = ITEMS.register("copper_ingot", ItemBase::new);
}
en_us.json, which is in src/main/resources/assets/necessarytechnology/lang:
{
"item.necessarytechnology.copper_ingot": "Copper Ingot"
}
copper_ingot.json, which is in src/main/resources/assets/necessarytechnology/models/item:
{
"parent": "item/generated",
"textures": {
"layer0": "necessarytechnology:items/copper_ingot"
}
}
Thanks in advance!