Skip to content

Commit 00e565c

Browse files
committed
Kotlinify
1 parent 07b2071 commit 00e565c

File tree

11 files changed

+73
-81
lines changed

11 files changed

+73
-81
lines changed

src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java src/main/java/org/polyfrost/example/mixin/Mixin_Minecraft_Example.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
/**
1010
* An example Mixin using SpongePowered's Mixin library
1111
*
12-
* @see Mixin
13-
* @see Inject
12+
* @see org.spongepowered.asm.mixin.Mixin
13+
* @see org.spongepowered.asm.mixin.injection.Inject
1414
*/
1515
@Mixin(Minecraft.class)
16-
public class MinecraftMixin {
16+
// Class naming convention: Mixin_[OriginalClassName]_[SimplifiedDescription]
17+
public class Mixin_Minecraft_Example {
1718

1819
@Inject(method = "<init>", at = @At(value = "RETURN"))
1920
private void examplemod$onStartGame(CallbackInfo ci) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.polyfrost.example
2+
3+
object ExampleConstants {
4+
5+
// Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin.
6+
const val ID = "@MOD_ID@"
7+
const val NAME = "@MOD_NAME@"
8+
const val VERSION = "@MOD_VERSION@"
9+
10+
}

src/main/kotlin/org/polyfrost/example/ExampleMod.kt

-29
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.polyfrost.example.client
2+
3+
import net.minecraftforge.fml.common.Mod
4+
import org.polyfrost.example.ExampleConstants
5+
import org.polyfrost.oneconfig.api.commands.v1.CommandManager
6+
7+
@Mod(modid = ExampleConstants.ID, name = ExampleConstants.NAME, version = ExampleConstants.VERSION, modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter")
8+
object ExampleClient {
9+
10+
@Mod.EventHandler
11+
fun initialize() {
12+
ExampleConfig.preload()
13+
CommandManager.registerCommand(ExampleCommand)
14+
}
15+
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.polyfrost.example.client
2+
3+
import org.polyfrost.example.ExampleConstants
4+
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command
5+
import org.polyfrost.oneconfig.utils.v1.dsl.openUI
6+
7+
@Command(value = [ExampleConstants.ID], description = "Access the ${ExampleConstants.NAME} GUI.")
8+
object ExampleCommand {
9+
10+
@Command
11+
private fun main() {
12+
ExampleConfig.openUI()
13+
}
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.polyfrost.example.client
2+
3+
import org.polyfrost.example.ExampleConstants
4+
import org.polyfrost.oneconfig.api.config.v1.Config
5+
import org.polyfrost.oneconfig.api.config.v1.annotations.Dropdown
6+
import org.polyfrost.oneconfig.api.config.v1.annotations.Slider
7+
import org.polyfrost.oneconfig.api.config.v1.annotations.Switch
8+
9+
object ExampleConfig : Config("${ExampleConstants.ID}.json", ExampleConstants.NAME, Category.OTHER) {
10+
11+
@JvmStatic
12+
@Switch(title = "Example Switch")
13+
var exampleSwitch = false // The default value for the boolean Switch
14+
15+
@JvmStatic
16+
@Slider(title = "Example Slider", min = 0f, max = 100f, step = 10f)
17+
var exampleSlider = 50f // The default value for the float Slider
18+
19+
@Dropdown(title = "Example Dropdown", options = ["Option 1", "Option 2", "Option 3", "Option 4"])
20+
var exampleDropdown = 1 // Default option (in this case, "Option 2")
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.polyfrost.example.client
2+
3+
// TODO: for nextdayy
4+
object ExampleHud {
5+
}

src/main/kotlin/org/polyfrost/example/command/ExampleCommand.kt

-21
This file was deleted.

src/main/kotlin/org/polyfrost/example/config/ExampleConfig.kt

-22
This file was deleted.

src/main/kotlin/org/polyfrost/example/hud/ExampleHud.kt

-5
This file was deleted.

src/main/resources/mixins.examplemod.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"maxShiftBy": 5
88
},
99
"client": [
10-
"MinecraftMixin"
10+
"Mixin_Minecraft_Example"
1111
],
1212
"verbose": true
1313
}

0 commit comments

Comments
 (0)