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

add API for GT Modules to subscribe to the Ore and Terrain Gen buses #2735

Merged
merged 3 commits into from
Feb 25, 2025
Merged
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
32 changes: 28 additions & 4 deletions src/main/java/gregtech/api/modules/IGregTechModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,35 @@ default void serverStopped(FMLServerStoppedEvent event) {}
default void registerPackets() {}

/**
* @return A list of classes to subscribe to the Forge event bus.
* As the class gets subscribed, not any specific instance, event handlers must be static!
* The class itself gets subscribed, instead of a class instance, so event handlers <strong>must</strong> be
* {@code static}.
*
* @return A list of classes to subscribe to the Forge Event Bus,
* {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
*/
@NotNull
default List<Class<?>> getEventBusSubscribers() {
default @NotNull List<Class<?>> getEventBusSubscribers() {
return Collections.emptyList();
}

/**
* The class itself gets subscribed, instead of a class instance, so event handlers <strong>must</strong> be
* {@code static}.
*
* @return A list of classes to subscribe to the Forge Terrain Gen Bus,
* {@link net.minecraftforge.common.MinecraftForge#TERRAIN_GEN_BUS}.
*/
default @NotNull List<Class<?>> getTerrainGenBusSubscribers() {
return Collections.emptyList();
}

/**
* The class itself gets subscribed, instead of a class instance, so event handlers <strong>must</strong> be
* {@code static}.
*
* @return A list of classes to subscribe to the Forge Ore Gen Bus,
* {@link net.minecraftforge.common.MinecraftForge#ORE_GEN_BUS}.
*/
default @NotNull List<Class<?>> getOreGenBusSubscribers() {
return Collections.emptyList();
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gregtech/modules/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public void setup(ASMDataTable asmDataTable, File configDirectory) {
for (Class<?> clazz : module.getEventBusSubscribers()) {
MinecraftForge.EVENT_BUS.register(clazz);
}
for (Class<?> clazz : module.getTerrainGenBusSubscribers()) {
MinecraftForge.TERRAIN_GEN_BUS.register(clazz);
}
for (Class<?> clazz : module.getOreGenBusSubscribers()) {
MinecraftForge.ORE_GEN_BUS.register(clazz);
}
}
}

Expand Down