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

Be more specific about @Mod initializer order #145

Merged
merged 7 commits into from
May 26, 2024
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@

public class FMLJavaModLanguageProviderTest extends LauncherTest {
// Allows us to capture events received by mods loaded in the game layer
public static List<FMLClientSetupEvent> EVENTS = new ArrayList<>();
public static final List<FMLClientSetupEvent> EVENTS = new ArrayList<>();
public static final List<String> MESSAGES = new ArrayList<>();

@AfterEach
void tearDown() {
EVENTS.clear();
MESSAGES.clear();
}

/**
Expand Down Expand Up @@ -107,6 +109,40 @@ public EntryPoint(net.neoforged.bus.api.IEventBus modEventBus) {
assertThat(EVENTS).hasSize(1);
}

@Test
void testMultipleEntrypoints() throws Exception {
installation.setupProductionClient();

var testJar = installation.writeModJar("test.jar", SimulatedInstallation.createModsToml("testmod", "1.0"));
try (var compiler = RuntimeCompiler.create(testJar)) {
compiler.builder()
.addClass("testmod.EntryPoint", """
@net.neoforged.fml.common.Mod("testmod")
public class EntryPoint {
public EntryPoint() {
net.neoforged.fml.javafmlmod.FMLJavaModLanguageProviderTest.MESSAGES.add("common");
}
}
""")
.addClass("testmod.ClientEntryPoint", """
@net.neoforged.fml.common.Mod(value = "testmod", dist = net.neoforged.api.distmarker.Dist.CLIENT)
public class ClientEntryPoint {
public ClientEntryPoint() {
net.neoforged.fml.javafmlmod.FMLJavaModLanguageProviderTest.MESSAGES.add("client");
}
}
""")
.compile();
}

var result = launch("forgeclient");
loadMods(result);

ModLoader.dispatchParallelEvent("test", Runnable::run, Runnable::run, () -> {}, FMLClientSetupEvent::new);
Gaming32 marked this conversation as resolved.
Show resolved Hide resolved

assertThat(MESSAGES).isEqualTo(List.of("common", "client"));
}

@Test
void testErrorDuringEventDispatch() throws Exception {
installation.setupProductionClient();
Expand Down