Skip to content

Commit

Permalink
Improve registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jan 21, 2025
1 parent 24e055d commit ec41e7e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/main/java/mod/emt/harkenscythe/HarkenScythe.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void init(FMLInitializationEvent event)
{
HSRegistry.registerAdvancements();
HSRegistry.registerTileEntities();
HSRegistry.registerRecipes();
HSCompatHandler.init();
LOGGER.info(NAME + " initialized");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/mod/emt/harkenscythe/init/HSBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class HSBlocks
@SubscribeEvent
public static void onRegisterBlocksEvent(@Nonnull final RegistryEvent.Register<Block> event)
{
HarkenScythe.LOGGER.info("Registering blocks...");

final IForgeRegistry<Block> registry = event.getRegistry();

// BLOCKS
Expand Down
19 changes: 5 additions & 14 deletions src/main/java/mod/emt/harkenscythe/init/HSItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
Expand All @@ -25,7 +24,7 @@
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;

import mod.emt.harkenscythe.HarkenScythe;
Expand Down Expand Up @@ -231,6 +230,8 @@ public class HSItems
@SubscribeEvent
public static void onRegisterItemsEvent(@Nonnull final RegistryEvent.Register<Item> event)
{
HarkenScythe.LOGGER.info("Registering items...");

final IForgeRegistry<Item> registry = event.getRegistry();

// ITEMS
Expand Down Expand Up @@ -336,22 +337,12 @@ public static void onRegisterItemsEvent(@Nonnull final RegistryEvent.Register<It
.forEach(block -> registry.register(HSRegistry.setup(new ItemBlock(block), block.getRegistryName())));
}

@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
{
final IForgeRegistry<IRecipe> registry = event.getRegistry();

// Third Party Mod Integration
if (Loader.isModLoaded("patchouli"))
{
registry.register(new ShapelessOreRecipe(null, reaper_guidebook, Items.BOOK, "essenceHarken").setRegistryName(HarkenScythe.MOD_ID, "reaper_guidebook"));
}
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onRegisterModelsEvent(@Nonnull final ModelRegistryEvent event)
{
HarkenScythe.LOGGER.info("Registering item models...");

// ITEM MODELS
for (final Item item : ForgeRegistries.ITEMS.getValues())
{
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/mod/emt/harkenscythe/init/HSRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
Expand All @@ -37,6 +38,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;

import mod.emt.harkenscythe.HarkenScythe;
Expand Down Expand Up @@ -105,7 +107,7 @@ public static void registerAdvancements()
}

@SubscribeEvent
public static void registerEnchantments(RegistryEvent.Register<Enchantment> event)
public static void registerEnchantments(@Nonnull final RegistryEvent.Register<Enchantment> event)
{
if (HSConfig.GENERAL.disableEnchantments) return;

Expand All @@ -122,7 +124,7 @@ public static void registerEnchantments(RegistryEvent.Register<Enchantment> even
}

@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityEntry> event)
public static void registerEntities(@Nonnull final RegistryEvent.Register<EntityEntry> event)
{
HarkenScythe.LOGGER.info("Registering entities...");

Expand Down Expand Up @@ -190,7 +192,7 @@ public static Biome[] getEntityBiomes(Class<? extends Entity> spawn)
}

@SubscribeEvent
public static void registerPotions(RegistryEvent.Register<Potion> event)
public static void registerPotions(@Nonnull final RegistryEvent.Register<Potion> event)
{
if (!HSConfig.GENERAL.disableEnchantments) event.getRegistry().register(HSPotions.BLEEDING);

Expand All @@ -206,7 +208,8 @@ public static void registerPotions(RegistryEvent.Register<Potion> event)
);
}

public static void registerRecipes()
@SubscribeEvent
public static void registerRecipes(@Nonnull final RegistryEvent.Register<IRecipe> event)
{
HarkenScythe.LOGGER.info("Registering ore dictionary entries...");

Expand All @@ -228,7 +231,9 @@ public static void registerRecipes()
OreDictionary.registerOre("ingotBiomass", HSItems.biomass);
OreDictionary.registerOre("ingotLivingmetal", HSItems.livingmetal_ingot);

HarkenScythe.LOGGER.info("Registering altar ritual recipes...");
HarkenScythe.LOGGER.info("Registering recipes...");

final IForgeRegistry<IRecipe> registry = event.getRegistry();

// Blood Altar
HSAltarRecipes.addBloodRecipe(HSItems.biomass_seed, HSItems.germinated_biomass_seed, 20);
Expand Down Expand Up @@ -270,13 +275,15 @@ public static void registerRecipes()
}

@SubscribeEvent
public static void registerSoundEvents(RegistryEvent.Register<SoundEvent> event)
public static void registerSoundEvents(@Nonnull final RegistryEvent.Register<SoundEvent> event)
{
HarkenScythe.LOGGER.info("Registering sound events...");

final IForgeRegistry<SoundEvent> registry = event.getRegistry();

for (HSSoundEvents soundEvents : HSSoundEvents.values())
{
event.getRegistry().register(soundEvents.getSoundEvent());
registry.register(soundEvents.getSoundEvent());
}
}

Expand All @@ -292,7 +299,7 @@ public static void registerTileEntities()

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void registerEntityRenderers(ModelRegistryEvent event)
public static void registerEntityRenderers(@Nonnull final ModelRegistryEvent event)
{
HarkenScythe.LOGGER.info("Registering entity renderers...");

Expand All @@ -310,7 +317,7 @@ public static void registerEntityRenderers(ModelRegistryEvent event)

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void registerTESRs(RegistryEvent<Block> event)
public static void registerTESRs(@Nonnull final RegistryEvent<Block> event)
{
HarkenScythe.LOGGER.info("Registering tile entity special renderers...");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"conditions": [
{
"type": "forge:mod_loaded",
"modid": "patchouli"
}
],
"type": "forge:ore_shapeless",
"ingredients": [
{
Expand Down

0 comments on commit ec41e7e

Please sign in to comment.