Skip to content

Commit

Permalink
Kotlinify
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Jan 17, 2025
1 parent a70d728 commit ae8eff5
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @see Inject
*/
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
// Class naming convention: Mixin_[OriginalClassName]_[SimplifiedDescription]
public class Mixin_MinecraftClient_Example {

@Inject(method = "<init>", at = @At(value = "RETURN"))
private void examplemod$onStartGame(CallbackInfo ci) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/org/polyfrost/example/ExampleConstants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.polyfrost.example

object ExampleConstants {

// Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin.
const val ID = "@MOD_ID@"
const val NAME = "@MOD_NAME@"
const val VERSION = "@MOD_VERSION@"

}
26 changes: 0 additions & 26 deletions src/main/kotlin/org/polyfrost/example/ExampleMod.kt

This file was deleted.

13 changes: 13 additions & 0 deletions src/main/kotlin/org/polyfrost/example/client/ExampleClient.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.polyfrost.example.client

import net.fabricmc.api.ClientModInitializer
import org.polyfrost.oneconfig.api.commands.v1.CommandManager

object ExampleClient : ClientModInitializer {

override fun onInitializeClient() {
ExampleConfig.preload()
CommandManager.registerCommand(ExampleCommand)
}

}
15 changes: 15 additions & 0 deletions src/main/kotlin/org/polyfrost/example/client/ExampleCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.polyfrost.example.client

import org.polyfrost.example.ExampleConstants
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command
import org.polyfrost.oneconfig.utils.v1.dsl.openUI

@Command(value = [ExampleConstants.ID], description = "Access the ${ExampleConstants.NAME} GUI.")
object ExampleCommand {

@Command
private fun main() {
ExampleConfig.openUI()
}

}
22 changes: 22 additions & 0 deletions src/main/kotlin/org/polyfrost/example/client/ExampleConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.polyfrost.example.client

import org.polyfrost.example.ExampleConstants
import org.polyfrost.oneconfig.api.config.v1.Config
import org.polyfrost.oneconfig.api.config.v1.annotations.Dropdown
import org.polyfrost.oneconfig.api.config.v1.annotations.Slider
import org.polyfrost.oneconfig.api.config.v1.annotations.Switch

object ExampleConfig : Config("${ExampleConstants.ID}.json", ExampleConstants.NAME, Category.OTHER) {

@JvmStatic
@Switch(title = "Example Switch")
var exampleSwitch = false // The default value for the boolean Switch

@JvmStatic
@Slider(title = "Example Slider", min = 0f, max = 100f, step = 10f)
var exampleSlider = 50f // The default value for the float Slider

@Dropdown(title = "Example Dropdown", options = ["Option 1", "Option 2", "Option 3", "Option 4"])
var exampleDropdown = 1 // Default option (in this case, "Option 2")

}
5 changes: 5 additions & 0 deletions src/main/kotlin/org/polyfrost/example/client/ExampleHud.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.polyfrost.example.client

// TODO: for nextdayy
object ExampleHud {
}
21 changes: 0 additions & 21 deletions src/main/kotlin/org/polyfrost/example/command/ExampleCommand.kt

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/kotlin/org/polyfrost/example/config/ExampleConfig.kt

This file was deleted.

5 changes: 0 additions & 5 deletions src/main/kotlin/org/polyfrost/example/hud/ExampleHud.kt

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"client": [
{
"adapter": "kotlin",
"value": "org.polyfrost.example.ExampleMod"
"value": "org.polyfrost.example.client.ExampleClient"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mixins.examplemod.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"maxShiftBy": 5
},
"client": [
"MinecraftClientMixin"
"Mixin_MinecraftClient_Example"
],
"verbose": true
}

0 comments on commit ae8eff5

Please sign in to comment.