From 41690f6507eeb2843160bada74c6411a3fa3af70 Mon Sep 17 00:00:00 2001 From: 90 Date: Mon, 27 Jan 2025 14:40:43 +0000 Subject: [PATCH] Retrieve `RegistryAccess` directly from the server for caster tome registry --- src/main/java/com/hollingsworth/arsnouveau/ArsNouveau.java | 4 +--- .../arsnouveau/api/registry/CasterTomeRegistry.java | 4 +--- .../hollingsworth/arsnouveau/common/event/EventHandler.java | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hollingsworth/arsnouveau/ArsNouveau.java b/src/main/java/com/hollingsworth/arsnouveau/ArsNouveau.java index 1407bbf2b..dcf1787ad 100644 --- a/src/main/java/com/hollingsworth/arsnouveau/ArsNouveau.java +++ b/src/main/java/com/hollingsworth/arsnouveau/ArsNouveau.java @@ -1,6 +1,5 @@ package com.hollingsworth.arsnouveau; - import com.hollingsworth.arsnouveau.api.registry.*; import com.hollingsworth.arsnouveau.api.ritual.DispenserRitualBehavior; import com.hollingsworth.arsnouveau.client.registry.ClientHandler; @@ -23,7 +22,6 @@ import com.hollingsworth.arsnouveau.setup.registry.*; import com.hollingsworth.arsnouveau.setup.reward.Rewards; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.ComposterBlock; import net.minecraft.world.level.block.DispenserBlock; @@ -125,7 +123,7 @@ public void setup(final FMLCommonSetupEvent event) { NeoForge.EVENT_BUS.addListener((ServerStartedEvent e) -> { GenericRecipeRegistry.reloadAll(e.getServer().getRecipeManager()); - CasterTomeRegistry.reloadTomeData(e.getServer().getRecipeManager(), e.getServer().getLevel(Level.OVERWORLD)); + CasterTomeRegistry.reloadTomeData(e.getServer().getRecipeManager(), e.getServer().registryAccess()); BuddingConversionRegistry.reloadBuddingConversionRecipes(e.getServer().getRecipeManager()); ScryRitualRegistry.reloadScryRitualRecipes(e.getServer().getRecipeManager()); }); diff --git a/src/main/java/com/hollingsworth/arsnouveau/api/registry/CasterTomeRegistry.java b/src/main/java/com/hollingsworth/arsnouveau/api/registry/CasterTomeRegistry.java index 5360b8395..d22ea6bce 100644 --- a/src/main/java/com/hollingsworth/arsnouveau/api/registry/CasterTomeRegistry.java +++ b/src/main/java/com/hollingsworth/arsnouveau/api/registry/CasterTomeRegistry.java @@ -6,7 +6,6 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeManager; -import net.minecraft.world.level.Level; import java.util.ArrayList; import java.util.Collections; @@ -20,12 +19,11 @@ public static List> getTomeData(){ return Collections.unmodifiableList(TOME_DATA); } - public static List> reloadTomeData(RecipeManager recipeManager, Level level){ + public static List> reloadTomeData(RecipeManager recipeManager, RegistryAccess access){ var recipes = recipeManager.getAllRecipesFor(RecipeRegistry.CASTER_TOME_TYPE.get()); DungeonLootTables.CASTER_TOMES = new ArrayList<>(); TOME_DATA = new ArrayList<>(); TOME_DATA.addAll(recipes); - RegistryAccess access = level.registryAccess(); recipes.forEach(tome -> DungeonLootTables.CASTER_TOMES.add(() -> tome.value().getResultItem(access))); return TOME_DATA; } diff --git a/src/main/java/com/hollingsworth/arsnouveau/common/event/EventHandler.java b/src/main/java/com/hollingsworth/arsnouveau/common/event/EventHandler.java index 3aea832f5..8c8bd2477 100644 --- a/src/main/java/com/hollingsworth/arsnouveau/common/event/EventHandler.java +++ b/src/main/java/com/hollingsworth/arsnouveau/common/event/EventHandler.java @@ -111,7 +111,7 @@ protected void apply(Object pObject, ResourceManager pResourceManager, ProfilerF @Override public void tick(ServerTickEvent serverTickEvent) { GenericRecipeRegistry.reloadAll(serverTickEvent.getServer().getRecipeManager()); - CasterTomeRegistry.reloadTomeData(serverTickEvent.getServer().getRecipeManager(), serverTickEvent.getServer().getLevel(Level.OVERWORLD)); + CasterTomeRegistry.reloadTomeData(serverTickEvent.getServer().getRecipeManager(), serverTickEvent.getServer().registryAccess()); BuddingConversionRegistry.reloadBuddingConversionRecipes(serverTickEvent.getServer().getRecipeManager()); AlakarkinosConversionRegistry.reloadAlakarkinosRecipes(serverTickEvent.getServer().getRecipeManager()); ScryRitualRegistry.reloadScryRitualRecipes(serverTickEvent.getServer().getRecipeManager());