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

[1.21.4] Recipe priority system for solving overlaps in recipe ingredients and patterns. #1855

Merged
merged 11 commits into from
Mar 19, 2025
Prev Previous commit
Next Next commit
Merge branch '1.21.x' into recipe-priority-but-mutable
bconlon1 committed Feb 13, 2025
commit 3f2426b551f1f8a0b37fb20a5d2d8af8137782ac
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@
@ApiStatus.Internal
public class NeoForgeEventHandler {
private static LootModifierManager LOOT_MODIFIER_MANAGER;
private static RecipePriorityManager RECIPE_PRIORITY_MANAGER;
private static DataMapLoader DATA_MAP_LOADER;

@SubscribeEvent(priority = EventPriority.HIGH)
@@ -151,34 +152,24 @@ public void onCommandsRegister(RegisterCommandsEvent event) {
ConfigCommand.register(event.getDispatcher());
}

private static LootModifierManager INSTANCE;
private static RecipePriorityManager RECIPE_PRIORITY;
private static DataMapLoader DATA_MAPS;

@SubscribeEvent
public void onResourceReload(AddReloadListenerEvent event) {
INSTANCE = new LootModifierManager();
RECIPE_PRIORITY = new RecipePriorityManager();
event.addListener(INSTANCE);
event.addListener(RECIPE_PRIORITY);
event.addListener(DATA_MAPS = new DataMapLoader(event.getConditionContext(), event.getRegistryAccess()));
public void onResourceReload(AddServerReloadListenersEvent event) {
event.addListener(NeoForgeReloadListeners.LOOT_MODIFIERS, LOOT_MODIFIER_MANAGER = new LootModifierManager());
event.addListener(NeoForgeReloadListeners.RECIPE_PRIORITIES, RECIPE_PRIORITY_MANAGER = new RecipePriorityManager());
event.addListener(NeoForgeReloadListeners.DATA_MAPS, DATA_MAP_LOADER = new DataMapLoader(event.getConditionContext(), event.getRegistryAccess()));
event.addListener(NeoForgeReloadListeners.CREATIVE_TABS, CreativeModeTabRegistry.getReloadListener());
}

static LootModifierManager getLootModifierManager() {
if (LOOT_MODIFIER_MANAGER == null)
throw new IllegalStateException("Can not retrieve LootModifierManager until resources have loaded once.");
return INSTANCE;
return LOOT_MODIFIER_MANAGER;
}

public static RecipePriorityManager getRecipePriorityManager() {
if (RECIPE_PRIORITY == null)
if (RECIPE_PRIORITY_MANAGER == null)
throw new IllegalStateException("Can not retrieve RecipePriorityManager until resources have loaded once.");
return RECIPE_PRIORITY;
}

@SubscribeEvent
public void resourceReloadListeners(AddReloadListenerEvent event) {
event.addListener(CreativeModeTabRegistry.getReloadListener());
return RECIPE_PRIORITY_MANAGER;
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@ public class NeoForgeReloadListeners {
// Server Listeners
public static final ResourceLocation LOOT_MODIFIERS = key("loot_modifiers");

public static final ResourceLocation RECIPE_PRIORITIES = key("recipe_priorities");

public static final ResourceLocation DATA_MAPS = key("data_maps");

public static final ResourceLocation CREATIVE_TABS = key("creative_tabs");
You are viewing a condensed version of this merge commit. You can view the full changes here.