aboutsummaryrefslogtreecommitdiff
path: root/src/example/kotlin/thedarkcolour/kotlinforforge
diff options
context:
space:
mode:
authorthedarkcolour <30441001+thedarkcolour@users.noreply.github.com>2020-06-20 17:47:55 -0700
committerthedarkcolour <30441001+thedarkcolour@users.noreply.github.com>2020-06-20 17:47:55 -0700
commit98458685ef50708edb3aebc4d72366d4bc41d71a (patch)
tree71623afce49865f09312af034df6d39bd4f3c058 /src/example/kotlin/thedarkcolour/kotlinforforge
parent7afdd597f4eb82de491fe37bd9b802f44d13d650 (diff)
downloadKotlinForForge-98458685ef50708edb3aebc4d72366d4bc41d71a.tar.gz
KotlinForForge-98458685ef50708edb3aebc4d72366d4bc41d71a.tar.bz2
KotlinForForge-98458685ef50708edb3aebc4d72366d4bc41d71a.zip
Update Kotlin for Forge 1.3.0
Diffstat (limited to 'src/example/kotlin/thedarkcolour/kotlinforforge')
-rw-r--r--src/example/kotlin/thedarkcolour/kotlinforforge/ExampleMod.kt80
-rw-r--r--src/example/kotlin/thedarkcolour/kotlinforforge/package.md7
-rw-r--r--src/example/kotlin/thedarkcolour/kotlinforforge/proxy/Proxies.kt20
-rw-r--r--src/example/kotlin/thedarkcolour/kotlinforforge/proxy/package.md12
4 files changed, 0 insertions, 119 deletions
diff --git a/src/example/kotlin/thedarkcolour/kotlinforforge/ExampleMod.kt b/src/example/kotlin/thedarkcolour/kotlinforforge/ExampleMod.kt
deleted file mode 100644
index af01493..0000000
--- a/src/example/kotlin/thedarkcolour/kotlinforforge/ExampleMod.kt
+++ /dev/null
@@ -1,80 +0,0 @@
-package thedarkcolour.kotlinforforge
-
-import net.minecraft.block.Block
-import net.minecraftforge.event.RegistryEvent
-import net.minecraftforge.eventbus.api.SubscribeEvent
-import net.minecraftforge.fml.common.Mod
-import net.minecraftforge.fml.event.server.FMLServerStartingEvent
-import thedarkcolour.kotlinforforge.forge.MOD_BUS
-import thedarkcolour.kotlinforforge.forge.lazySidedDelegate
-import thedarkcolour.kotlinforforge.proxy.ClientProxy
-import thedarkcolour.kotlinforforge.proxy.IProxy
-import thedarkcolour.kotlinforforge.proxy.ServerProxy
-
-/**
- * Example mod for anyone who'd like to see
- * how a mod would be made with Kotlin for Forge.
- *
- * This mod has a modid of "examplemod", listens
- * for the ``RegistryEvent.Register<Block>`` and
- * for the ``FMLServerStartingEvent``.
- *
- * It registers event listeners by adding event listeners
- * directly to the event buses KFF provides and
- * by using the ``@EventBusSubscriber`` annotation.
- */
-@Mod(ExampleMod.ID)
-object ExampleMod {
- /**
- * Your mod's ID
- */
- const val ID = "examplemod"
-
- /**
- * The sided proxy. Since we use a lazy sided delegate,
- * the supplier parameters are invoked only once.
- */
- private val proxy by lazySidedDelegate(::ClientProxy, ::ServerProxy)
-
- /**
- * Example of using the KotlinEventBus
- * to register a function reference.
- *
- * Event classes with a generic type
- * should be registered using ``addGenericListener``
- * instead of ``addListener``.
- */
- init {
- MOD_BUS.addGenericListener(::registerBlocks)
-
- proxy.modConstruction()
- }
-
- /**
- * Handle block registry here.
- */
- private fun registerBlocks(event: RegistryEvent.Register<Block>) {
- // ...
- }
-
- /**
- * Example of an object class using the
- * ``@Mod.EventBusSubscriber`` annotation
- * to automatically subscribe functions
- * to the forge event bus.
- *
- * Even though the ``Bus.FORGE`` event bus
- * is default, I think that it's still
- * a good practice to specify the bus explicitly.
- */
- @Mod.EventBusSubscriber(modid = ExampleMod.ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
- object EventHandler {
- /**
- * Handles things like registering commands.
- */
- @SubscribeEvent
- fun onServerStarting(event: FMLServerStartingEvent) {
- // ...
- }
- }
-} \ No newline at end of file
diff --git a/src/example/kotlin/thedarkcolour/kotlinforforge/package.md b/src/example/kotlin/thedarkcolour/kotlinforforge/package.md
deleted file mode 100644
index c9c1caa..0000000
--- a/src/example/kotlin/thedarkcolour/kotlinforforge/package.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# thedarkcolour.kotlinforforge
-This package contains an example main mod class
-for a mod using Kotlin for Forge.
-
-## ExampleMod
-Your main mod class should be an object declaration.
-It must be annotated with the @Mod annotation. \ No newline at end of file
diff --git a/src/example/kotlin/thedarkcolour/kotlinforforge/proxy/Proxies.kt b/src/example/kotlin/thedarkcolour/kotlinforforge/proxy/Proxies.kt
deleted file mode 100644
index 24c51b7..0000000
--- a/src/example/kotlin/thedarkcolour/kotlinforforge/proxy/Proxies.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package thedarkcolour.kotlinforforge.proxy
-
-/**
- * Common inheritor of both proxies.
- */
-interface IProxy {
- fun modConstruction()
-}
-
-class ClientProxy : IProxy {
- override fun modConstruction() {
- // run client code
- }
-}
-
-class ServerProxy : IProxy {
- override fun modConstruction() {
- // run server code
- }
-} \ No newline at end of file
diff --git a/src/example/kotlin/thedarkcolour/kotlinforforge/proxy/package.md b/src/example/kotlin/thedarkcolour/kotlinforforge/proxy/package.md
deleted file mode 100644
index bb57203..0000000
--- a/src/example/kotlin/thedarkcolour/kotlinforforge/proxy/package.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# thedarkcolour.kotlinforforge.proxy
-This package has example proxy classes.
-Proxies are used to provide common declarations with sided implementations.
-
-Forge no longer supports the proxy pattern.
-The ``@SidedProxy`` annotation was removed in 1.13+.
-This example shows a use case for the ``lazySidedDelegate``.
-It is recommended to use the ``runWhenOn`` and ``callWhenOn`` functions
-instead of proxies whenever possible.
-
-In this example, a proxy is instantiated lazily in the ``ExampleMod`` class.
-Proxies are not the only use for sided delegates. \ No newline at end of file