-
Notifications
You must be signed in to change notification settings - Fork 37
Update to support EventBus7 #129
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
base: 5.x
Are you sure you want to change the base?
Changes from all commits
ee773cb
bad92ba
f908362
19a2464
9233794
1eac749
3be40d8
02e70ea
337172a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,5 @@ min_mc_version = 1.20.6 | |
unsupported_mc_version = 1.22 | ||
|
||
# KOTLIN FOR FORGE VERSION | ||
kff_version=5.9.0 | ||
kff_max_version=6.0.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be 7.0.0, not 6.1.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've changed that |
||
kff_version=6.0.0 | ||
kff_max_version=7.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package net.minecraftforge.common; | ||
|
||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.eventbus.api.bus.BusGroup; | ||
|
||
public class MinecraftForge { | ||
public static final IEventBus EVENT_BUS = null; | ||
public static final BusGroup EVENT_BUS = null; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we now using @KotlinMod instead of @mod? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make it easier to distinguish, because the @mod annotation is part of the FML Loader, and it would be easier for KFF to have it's own annotation, as it's a separate loader. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package thedarkcolour.common | ||
|
||
import net.minecraftforge.api.distmarker.Dist | ||
import net.minecraftforge.eventbus.api.bus.BusGroup | ||
import net.minecraftforge.fml.Bindings | ||
import net.minecraftforge.fml.common.Mod | ||
import thedarkcolour.kotlinforforge.KotlinModLoadingContext | ||
import java.util.function.Supplier | ||
|
||
/** | ||
* This defines a Kotlin Mod Class | ||
* Any class found with this annotation applied will be loaded as a Mod. The instance that is loaded will | ||
* represent the mod to other Mods in the system. It will be sent various subclasses of [ModLifecycleEvent] | ||
* at pre-defined times during the loading of the game. | ||
* @author Chidoziealways | ||
* @since 6.0.0 | ||
*/ | ||
|
||
@Retention(AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.CLASS) | ||
public annotation class KotlinMod(val value: String) { | ||
|
||
public annotation class KotlinEventBusSubscriber( | ||
val value: Array<Dist> = [Dist.CLIENT, Dist.DEDICATED_SERVER], | ||
val modId: String = "", | ||
val bus: KotlinBus = KotlinBus.BOTH | ||
) { | ||
} | ||
} | ||
|
||
public enum class KotlinBus(public val eventBusSupplier: Supplier<BusGroup?>) { | ||
/** | ||
* The main BusGroup that most game events are fired on. | ||
*/ | ||
FORGE(Bindings.getForgeBus()), | ||
|
||
/** | ||
* The Mod-Specific event BusGroup, usually for mod lifecycle events. | ||
* @see KotlinModLoadingContext.getKBusGroup() | ||
*/ | ||
MOD({ KotlinModLoadingContext.get().getKBusGroup() }), | ||
|
||
/** | ||
* Both the [FORGE] and [MOD] buses. This is slower to register events in your class but | ||
* allows you to listen to events from different BusGroup types without needing separate classes annotated | ||
* with [thedarkcolour.common.KotlinMod.KotlinEventBusSubscriber]. | ||
*/ | ||
BOTH({null}); | ||
|
||
public fun bus(): Supplier<BusGroup?> = eventBusSupplier | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all of these random Gradle options? If these changes are just for your setup, please remove them from the PR