package net.aeronica.mods.mxtune.init;

import java.util.HashSet;
import java.util.Set;

import net.aeronica.mods.mxtune.blocks.ItemPiano;
import net.aeronica.mods.mxtune.items.ItemInstrument;
import net.aeronica.mods.mxtune.items.ItemMusicPaper;
import net.aeronica.mods.mxtune.items.ItemSheetMusic;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;

@SuppressWarnings("unused")
public class ModItems
{
    
    public static final ItemInstrument ITEM_INSTRUMENT = registerItem(new ItemInstrument(), "instrument");
    public static final ItemMusicPaper ITEM_MUSIC_PAPER = registerItem(new ItemMusicPaper(), "music_paper");
    public static final ItemSheetMusic ITEM_SHEET_MUSIC = registerItem(new ItemSheetMusic(), "sheet_music");
    public static final ItemPiano ITEM_SPINET_PIANO = registerItem(new ItemPiano(), "spinet_piano");
   
    @Mod.EventBusSubscriber
    public static class RegistrationHandler {
        protected static final Set<Item> ITEMS = new HashSet<>();

        /**
         * Register this mod's {@link Item}s.
         *
         * @param event The event
         */
        @SubscribeEvent
        public static void registerItems(RegistryEvent.Register<Item> event) {
            final Item[] items = {
                    ITEM_INSTRUMENT,
                    ITEM_MUSIC_PAPER,
                    ITEM_SHEET_MUSIC,
                    ITEM_SPINET_PIANO,
            };

            final IForgeRegistry<Item> registry = event.getRegistry();
            for (final Item item : items) {
                registry.register(item);
                ITEMS.add(item);
            }
        }
    }
        
    private static <T extends Item> T registerItem(T item, String name) {
        item.setRegistryName(name.toLowerCase());
        item.setTranslationKey(item.getRegistryName().toString());
        return item;
    }

    private static <T extends Item> T registerItem(T item) {
        String simpleName = item.getClass().getSimpleName();
        if (item instanceof ItemBlock) {
            simpleName = ((ItemBlock) item).getBlock().getClass().getSimpleName();
        }
        return registerItem(item, simpleName);
    }

}

@@ -37,107 +37,8 @@
 t;%0A%0A
-import java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport net.aeronica.mods.mxtune.blocks.ItemPiano;%0A
 impo
@@ -141,16 +141,65 @@
 cPaper;%0A
+import net.aeronica.mods.mxtune.items.ItemPiano;%0A
 import n
@@ -522,16 +522,65 @@
 istry;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 @Suppres
@@ -623,21 +623,16 @@
 Items%0A%7B%0A
-    %0A
     publ
@@ -2371,11 +2371,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Clean up