Skip to content

Commit 5178d5c

Browse files
authored
add API for GT Modules to subscribe to the Ore and Terrain Gen buses (#2735)
1 parent a46460d commit 5178d5c

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/main/java/gregtech/api/modules/IGregTechModule.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,35 @@ default void serverStopped(FMLServerStoppedEvent event) {}
5555
default void registerPackets() {}
5656

5757
/**
58-
* @return A list of classes to subscribe to the Forge event bus.
59-
* As the class gets subscribed, not any specific instance, event handlers must be static!
58+
* The class itself gets subscribed, instead of a class instance, so event handlers <strong>must</strong> be
59+
* {@code static}.
60+
*
61+
* @return A list of classes to subscribe to the Forge Event Bus,
62+
* {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
6063
*/
61-
@NotNull
62-
default List<Class<?>> getEventBusSubscribers() {
64+
default @NotNull List<Class<?>> getEventBusSubscribers() {
65+
return Collections.emptyList();
66+
}
67+
68+
/**
69+
* The class itself gets subscribed, instead of a class instance, so event handlers <strong>must</strong> be
70+
* {@code static}.
71+
*
72+
* @return A list of classes to subscribe to the Forge Terrain Gen Bus,
73+
* {@link net.minecraftforge.common.MinecraftForge#TERRAIN_GEN_BUS}.
74+
*/
75+
default @NotNull List<Class<?>> getTerrainGenBusSubscribers() {
76+
return Collections.emptyList();
77+
}
78+
79+
/**
80+
* The class itself gets subscribed, instead of a class instance, so event handlers <strong>must</strong> be
81+
* {@code static}.
82+
*
83+
* @return A list of classes to subscribe to the Forge Ore Gen Bus,
84+
* {@link net.minecraftforge.common.MinecraftForge#ORE_GEN_BUS}.
85+
*/
86+
default @NotNull List<Class<?>> getOreGenBusSubscribers() {
6387
return Collections.emptyList();
6488
}
6589

src/main/java/gregtech/modules/ModuleManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public void setup(ASMDataTable asmDataTable, File configDirectory) {
101101
for (Class<?> clazz : module.getEventBusSubscribers()) {
102102
MinecraftForge.EVENT_BUS.register(clazz);
103103
}
104+
for (Class<?> clazz : module.getTerrainGenBusSubscribers()) {
105+
MinecraftForge.TERRAIN_GEN_BUS.register(clazz);
106+
}
107+
for (Class<?> clazz : module.getOreGenBusSubscribers()) {
108+
MinecraftForge.ORE_GEN_BUS.register(clazz);
109+
}
104110
}
105111
}
106112

0 commit comments

Comments
 (0)