This way of registering items is not exactly efficient.
EDIT: DaemonUmbra seems to have read my mind lol.
Read my code!
package com.mods.propane865.undergrounddiscovery;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.mods.propane865.undergrounddiscovery.items.CustomAxeItem;
import com.mods.propane865.undergrounddiscovery.items.CustomPickaxeItem;
import com.mods.propane865.undergrounddiscovery.lists.ArmorMaterialList;
import com.mods.propane865.undergrounddiscovery.lists.BlockList;
import com.mods.propane865.undergrounddiscovery.lists.ItemList;
import com.mods.propane865.undergrounddiscovery.lists.ToolMaterialList;
import com.mods.propane865.undergrounddiscovery.world.OreGeneration;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.BlockItem;
import net.minecraft.item.HoeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.SwordItem;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@Mod("undergrounddiscovery")
public class Main
{
public static Main instance;
public static final String MODID = "undergrounddiscovery";
private static final Logger LOGGER = LogManager.getLogger(MODID);
public static final ItemGroup MORE_METALS = new MoreMetals();
public Main()
{
instance = this;
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries);
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event)
{
OreGeneration.setupOreGeneration();
LOGGER.info("Setup method registered.");
}
private void clientRegistries(final FMLClientSetupEvent event)
{
LOGGER.info("clientRegistries method registered.");
}
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents
{
@SubscribeEvent
public static void registerItems(final RegistryEvent.Register<Item> event)
{
event.getRegistry().registerAll
(
ItemList.copper_ingot = new Item(new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_ingot")),
ItemList.copper_block = new BlockItem(BlockList.copper_block, new Item.Properties().group(MORE_METALS)).setRegistryName(BlockList.copper_block.getRegistryName()),
ItemList.copper_ore = new BlockItem(BlockList.copper_ore, new Item.Properties().group(MORE_METALS)).setRegistryName(BlockList.copper_ore.getRegistryName()),
ItemList.copper_axe = new CustomAxeItem(ToolMaterialList.copper, 0.0f, -3.1f, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_axe")),
ItemList.copper_hoe = new HoeItem(ToolMaterialList.copper, -3.0f, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_hoe")),
ItemList.copper_pickaxe = new CustomPickaxeItem(ToolMaterialList.copper, (int) -3.0f, -3.0f, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_pickaxe")),
ItemList.copper_shovel = new ShovelItem(ToolMaterialList.copper, -4.0f, -3.0f, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_shovel")),
ItemList.copper_sword = new SwordItem(ToolMaterialList.copper, (int) -1.0f, -2.4f, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_sword")),
ItemList.copper_helmet = new ArmorItem(ArmorMaterialList.copper, EquipmentSlotType.HEAD, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_helmet")),
ItemList.copper_chestplate = new ArmorItem(ArmorMaterialList.copper, EquipmentSlotType.CHEST, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_chestplate")),
ItemList.copper_leggings = new ArmorItem(ArmorMaterialList.copper, EquipmentSlotType.LEGS, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_leggings")),
ItemList.copper_boots = new ArmorItem(ArmorMaterialList.copper, EquipmentSlotType.FEET, new Item.Properties().group(MORE_METALS)).setRegistryName(location("copper_boots"))
);
LOGGER.info("Items registered.");
}
@SubscribeEvent
public static void registerBlocks(final RegistryEvent.Register<Block> event)
{
event.getRegistry().registerAll
(
BlockList.copper_block = new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.METAL)).setRegistryName(location("copper_block")),
BlockList.copper_ore = new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(1.5f, 2.0f).lightValue(0).sound(SoundType.STONE)).setRegistryName(location("copper_ore"))
);
LOGGER.info("Blocks registered.");
}
private static ResourceLocation location(String name)
{
return new ResourceLocation(MODID, name);
}
}
}
NOTE: My code is for 1.14.3 and above ONLY!