Skip to content

Commit

Permalink
Add FIRST/LAST constants, move client code
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadows-of-Fire committed Feb 5, 2025
1 parent 2601dc4 commit 8da5a7f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import net.neoforged.neoforge.client.model.UnbakedCompositeModel;
import net.neoforged.neoforge.client.model.item.DynamicFluidContainerModel;
import net.neoforged.neoforge.client.model.obj.ObjLoader;
import net.neoforged.neoforge.client.resources.VanillaClientListeners;
import net.neoforged.neoforge.client.textures.NamespacedDirectoryLister;
import net.neoforged.neoforge.common.ModConfigSpec;
import net.neoforged.neoforge.common.NeoForge;
Expand All @@ -68,7 +69,6 @@
import net.neoforged.neoforge.internal.BrandingControl;
import net.neoforged.neoforge.internal.versions.neoforge.NeoForgeVersion;
import net.neoforged.neoforge.resource.NeoForgeReloadListeners;
import net.neoforged.neoforge.resource.VanillaClientListeners;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
Expand Down Expand Up @@ -139,9 +139,9 @@ static void onRegisterReloadListeners(AddClientReloadListenerEvent event) {
event.addListener(NeoForgeReloadListeners.CLIENT_MOD_LOADING, ClientModLoader::onResourceReload);
event.addListener(NeoForgeReloadListeners.BRANDING, BrandingControl.resourceManagerReloadListener());

// These run before vanilla reload listeners, so we add them before LANGUAGE, the first vanilla one.
// These run before vanilla reload listeners.
event.addDependency(NeoForgeReloadListeners.CLIENT_MOD_LOADING, NeoForgeReloadListeners.BRANDING);
event.addDependency(NeoForgeReloadListeners.BRANDING, VanillaClientListeners.LANGUAGE);
event.addDependency(NeoForgeReloadListeners.BRANDING, VanillaClientListeners.FIRST);

event.addListener(NeoForgeReloadListeners.OBJ_LOADER, ObjLoader.INSTANCE);
event.addListener(NeoForgeReloadListeners.ENTITY_ANIMATIONS, AnimationLoader.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.neoforged.fml.LogicalSide;
import net.neoforged.fml.event.IModBusEvent;
import net.neoforged.neoforge.client.resources.VanillaClientListeners;
import net.neoforged.neoforge.event.SortedReloadListenerEvent;
import net.neoforged.neoforge.resource.VanillaClientListeners;
import org.jetbrains.annotations.ApiStatus;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.neoforge.resource;
package net.neoforged.neoforge.client.resources;

import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -91,6 +91,16 @@ public class VanillaClientListeners {

public static final ResourceLocation REGIONAL_COMPLIANCES = key(PeriodicNotificationManager.class);

/**
* Sentinel field that will always reference the first reload listener in the vanilla order.
*/
public static final ResourceLocation FIRST = LANGUAGE;

/**
* Sentinel field that will always reference the last reload listener in the vanilla order.
*/
public static final ResourceLocation LAST = REGIONAL_COMPLIANCES;

private static ResourceLocation key(Class<? extends PreparableReloadListener> cls) {
if (KNOWN_CLASSES.containsKey(cls)) {
// Prevent duplicate registration, in case we accidentally use the same class in two different fields.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) NeoForged and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package net.neoforged.neoforge.client.resources;

import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public class VanillaServerListeners {

public static final ResourceLocation ADVANCEMENTS = key(ServerAdvancementManager.class);

/**
* Sentinel field that will always reference the first reload listener in the vanilla order.
*/
public static final ResourceLocation FIRST = RECIPES;

/**
* Sentinel field that will always reference the last reload listener in the vanilla order.
*/
public static final ResourceLocation LAST = ADVANCEMENTS;

private static ResourceLocation key(Class<? extends PreparableReloadListener> cls) {
if (KNOWN_CLASSES.containsKey(cls)) {
// Prevent duplicate registration, in case we accidentally use the same class in two different fields.
Expand Down

0 comments on commit 8da5a7f

Please sign in to comment.