Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve RegistryAccess directly from the server for caster tome registry #1609

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/main/java/com/hollingsworth/arsnouveau/ArsNouveau.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,12 +19,11 @@ public static List<RecipeHolder<CasterTomeData>> getTomeData(){
return Collections.unmodifiableList(TOME_DATA);
}

public static List<RecipeHolder<CasterTomeData>> reloadTomeData(RecipeManager recipeManager, Level level){
public static List<RecipeHolder<CasterTomeData>> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down