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

IdMappingEvent can't be posted successfully #2041

Open
zomb-676 opened this issue Mar 22, 2025 · 5 comments
Open

IdMappingEvent can't be posted successfully #2041

zomb-676 opened this issue Mar 22, 2025 · 5 comments
Labels
triage Needs triaging and confirmation

Comments

@zomb-676
Copy link

Minecraft Version: 1.21.4

NeoForge Version: 21.4.91-beta

changelog here https://neoforged.net/changelog/ don't show information that may have fixed this

Steps to Reproduce:
subscribe the IdMappingEvent(on forge bus)

Description of issue:
The IdMappingEvent can't be posted successfully, the reason is as follows

The forge bus is an EventBus that is shutdown when created
as startShutdown is called

public class NeoForge {
/**
* The NeoForge event bus, used for most events.
* Also known as the "game" bus.
*/
public static final IEventBus EVENT_BUS = BusBuilder.builder().startShutdown().classChecker(eventType -> {
if (IModBusEvent.class.isAssignableFrom(eventType)) {
throw new IllegalArgumentException("IModBusEvent events are not allowed on the common NeoForge bus! Use a mod bus instead.");
}
}).build();
}

the bus is enabled at this place
it is too late for IdMappingEvent, as here we have almost complete mod loading and are collecting ModLoadingIssue

public static Runnable completeModLoading(Runnable initialScreensTask) {
List<ModLoadingIssue> warnings = ModLoader.getLoadingIssues();
boolean showWarnings = true;
try {
showWarnings = NeoForgeConfig.CLIENT.showLoadWarnings.get();
} catch (NullPointerException | IllegalStateException e) {
// We're in an early error state, config is not available. Assume true.
}
if (error != null) {
// Double check we have the langs loaded for forge
LanguageHook.loadBuiltinLanguages();
File dumpedLocation = CrashReportExtender.dumpModLoadingCrashReport(LOGGER, error.getIssues(), mc.gameDirectory);
// Ignore incoming initial screens task, the subsequent screens are unreachable in an error state
return () -> mc.setScreen(new LoadingErrorScreen(error.getIssues(), dumpedLocation, () -> {}));
}
// We can finally start the game eventbus up
NeoForge.EVENT_BUS.start();

but the event IdMappingEvent is fired at this place, where the freezeData is called
where the mod loading Message is still REGISTERING, the bus still shutdown and haven't be started

protected static void begin(Runnable periodicTask, boolean datagen) {
var syncExecutor = ModWorkManager.syncExecutor();
ModLoader.gatherAndInitializeMods(syncExecutor, ModWorkManager.parallelExecutor(), periodicTask);
ModLoader.runInitTask("Registry initialization", syncExecutor, periodicTask, () -> {
RegistryManager.postNewRegistryEvent();
GameData.unfreezeData();
GameData.postRegisterEvents();
GameData.freezeData();

@zomb-676 zomb-676 added the triage Needs triaging and confirmation label Mar 22, 2025
@Technici4n
Copy link
Member

As far as I can tell, this event is quite useless. It is fired a single time right after registries are frozen, and with no remaps. We should probably remove it in 1.21.5?

@marchermans
Copy link
Contributor

As far as I can tell, this event is quite useless. It is fired a single time right after registries are frozen, and with no remaps. We should probably remove it in 1.21.5?

This is an amazingly usefull event during porting and migrations!
If this event is broken we have a problem. Its main purpose is to allow modders to migrate registry values from one key to another, kind of like aliases.

Do we have any kind of alternative for this system?

@Technici4n
Copy link
Member

The alternative is to use aliases. 😛 Known registry entries are not saved to disk anymore since the registry rework, so I don't see how this event could possibly work.

@zomb-676
Copy link
Author

I noticed this event because I wanted to do something after completing all the registries.
Perhaps this event should be renamed into a better name.

I just noticed that MissingMappingsEvent has disappeared, so is that event replaced by DeferredRegister#addAlias?

@Technici4n
Copy link
Member

I noticed this event because I wanted to do something after completing all the registries. Perhaps this event should be renamed into a better name.

Have you tried FMLCommonSetupEvent?

I just noticed that MissingMappingsEvent has disappeared, so is that event replaced by DeferredRegister#addAlias?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs triaging and confirmation
Projects
None yet
Development

No branches or pull requests

3 participants