Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion committed Oct 15, 2024
1 parent 4845015 commit 0ca0610
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 84 deletions.
20 changes: 9 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ repositories {
maven("https://maven.neoforged.net/releases/")
}

val yaclVersion = property("vers.deps.yacl").toString()
val flk: String = "${libs.versions.fabric.language.kotlin.orNull}${libs.versions.kotlin.orNull}"
val fapi: String by lazy { property("vers.deps.fapi").toString() }
val yacl: String by lazy { property("vers.deps.yacl").toString() }
val modmenu: String by lazy { property("vers.deps.modMenu").toString() }
dependencies {
minecraft("com.mojang:minecraft:$mcVersion")
Expand All @@ -74,6 +74,7 @@ dependencies {
modImplementation("net.fabricmc.fabric-api:fabric-api:$fapi")
modImplementation("net.fabricmc:fabric-language-kotlin:$flk")
modImplementation("com.terraformersmc:modmenu:$modmenu")
modImplementation("dev.isxander:yet-another-config-lib:$yacl")
} else {
if (loader == ModPlatform.FORGE) {
"forge"("net.minecraftforge:forge:$mcVersion-${property("vers.deps.fml")}")
Expand All @@ -83,16 +84,14 @@ dependencies {
implementation(libs.mixinextras.forge)
} else
"neoForge"("net.neoforged:neoforge:${property("vers.deps.fml")}")
implementation("thedarkcolour:kotlinforforge${if (loader == ModPlatform.NEOFORGE) "-neoforge" else ""}:${property("vers.deps.kff")}")
modImplementation("dev.nyon:KotlinLangForge:1.0.3-k${libs.versions.kotlin.orNull}-$mcVersion+${loader.name.lowercase()}")
}

modImplementation("dev.isxander:yet-another-config-lib:$yaclVersion")

modImplementation(libs.konfig)
include(libs.konfig)
}

val javaVersion = property("vers.javaVer").toString()
val javaVersion = if (stonecutter.eval(mcVersion, ">=1.20.6")) 21 else 17
val modId = property("mod.id").toString()
val modName = property("mod.name").toString()
val modDescription = property("mod.description").toString()
Expand All @@ -110,7 +109,7 @@ tasks {
"mc" to mcVersionRange,
"flk" to if (!isFabric) null else flk,
"fapi" to if (!isFabric) null else fapi,
"yacl" to yaclVersion,
"yacl" to if (!isFabric) null else yacl,
"modmenu" to if (!isFabric) null else modmenu,
"repo" to githubRepo,
"icon" to icon,
Expand Down Expand Up @@ -138,12 +137,12 @@ tasks {
}

withType<JavaCompile> {
options.release = javaVersion.toInt()
options.release = javaVersion
}

withType<KotlinCompile> {
compilerOptions {
jvmTarget = JvmTarget.fromTarget(javaVersion)
jvmTarget = JvmTarget.fromTarget(javaVersion.toString())
}
}
}
Expand Down Expand Up @@ -178,11 +177,10 @@ publishMods {
requires { slug = "fabric-api" }
requires { slug = "fabric-language-kotlin" }
optional { slug = "modmenu" }
if (stonecutter.compare(mcVersion, "1.20.1") >= 0) requires { slug = "yacl" }
} else {
requires { slug = "kotlin-for-forge" }
requires { slug = "kotlin-lang-forge" }
}

if (stonecutter.compare(mcVersion, "1.20.1") >= 0) requires { slug = "yacl" }
}

github {
Expand Down
5 changes: 3 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- add option to change the detection range of collisions
- automatically set to 0.5 blocks
- migrate to kotlin-lang-forge
- migrate all network namespaces from 'better-boat-movement' to 'bbm'
- remove config from forge environments
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
kotlin = "2.0.20"
kotlin = "2.0.21"
mod-publish = "0.5.+"
architectury-loom = "1.7-SNAPSHOT"
fabric-loader = "0.16.4"
fabric-language-kotlin = "1.12.1+kotlin."
fabric-loader = "0.16.7"
fabric-language-kotlin = "1.12.3+kotlin."
vineflower = "1.10.1"
konfig = "2.0.2-1.20.4"
mixinextras = "0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
46 changes: 13 additions & 33 deletions src/main/kotlin/dev/nyon/bbm/BetterBoatMovementEntrypoint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ object BetterBoatMovementEntrypoint : ModInitializer {
}

/*?} else if neoforge {*/
/*import dev.nyon.bbm.config.generateYaclScreen
/*import dev.nyon.klf.MOD_BUS
import net.minecraft.server.level.ServerPlayer
import net.neoforged.api.distmarker.Dist
import net.neoforged.fml.ModLoadingContext
import net.neoforged.fml.common.Mod
import net.neoforged.fml.loading.FMLLoader
import net.neoforged.neoforge.common.NeoForge
import net.neoforged.neoforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent
import net.neoforged.neoforge.event.entity.player.PlayerEvent.PlayerLoggedOutEvent
import net.neoforged.neoforge.network.PacketDistributor
import thedarkcolour.kotlinforforge.neoforge.forge.DIST
import thedarkcolour.kotlinforforge.neoforge.forge.FORGE_BUS
/^? if >=1.20.5 {^/
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent
Expand All @@ -72,9 +70,6 @@ import net.neoforged.neoforge.network.handling.DirectionalPayloadHandler
/^import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent
import net.minecraft.network.FriendlyByteBuf
^//^?}^/
import thedarkcolour.kotlinforforge.neoforge.forge.MOD_BUS
typealias CSF = /^? if <1.20.5 {^/ /^net.neoforged.neoforge.client.ConfigScreenHandler.ConfigScreenFactory ^//^?} else {^/ net.neoforged.neoforge.client.gui.IConfigScreenFactory /^?}^/
@Mod("bbm")
object BetterBoatMovementEntrypoint {
Expand All @@ -83,7 +78,7 @@ object BetterBoatMovementEntrypoint {
/^? if >=1.20.5 {^/
MOD_BUS.addListener<RegisterPayloadHandlersEvent> { event ->
val registrar = event.registrar("4")
val registrar = event.registrar("bbm").versioned("4")
registrar.playToClient(Config.packetType, Config.codec, DirectionalPayloadHandler(
{ config, _ ->
serverConfig = config
Expand All @@ -92,17 +87,17 @@ object BetterBoatMovementEntrypoint {
}
/^?} else {^/
/^MOD_BUS.addListener<RegisterPayloadHandlerEvent> { event ->
val registrar = event.registrar("4")
val registrar = event.registrar("bbm").versioned("4")
registrar.play(Config.identifier, FriendlyByteBuf.Reader{ buf -> Config(buf) }) { handler ->
handler.client { config, _ -> serverConfig = config }.server { _, _ -> }
}
}
^//^?}^/
when (DIST) {
when (FMLLoader.getDist()) {
Dist.DEDICATED_SERVER -> {
serverConfig = config
FORGE_BUS.addListener<PlayerLoggedInEvent> { event ->
NeoForge.EVENT_BUS.addListener<PlayerLoggedInEvent> { event ->
val player = event.entity
if (player !is ServerPlayer) return@addListener
/^? if >=1.20.5 {^/ PacketDistributor.sendToPlayer(player, serverConfig!!)
Expand All @@ -111,41 +106,33 @@ object BetterBoatMovementEntrypoint {
}
Dist.CLIENT -> {
FORGE_BUS.addListener<PlayerLoggedOutEvent> {
NeoForge.EVENT_BUS.addListener<PlayerLoggedOutEvent> {
serverConfig = null
}
}
else -> {}
}
ModLoadingContext.get().registerExtensionPoint(CSF::class.java) {
CSF { _, parent -> generateYaclScreen(parent) }
}
}
}
*//*?} else {*/
/*import dev.nyon.bbm.config.generateYaclScreen
import dev.nyon.bbm.extensions.resourceLocation
/*import dev.nyon.bbm.extensions.resourceLocation
import net.minecraft.server.level.ServerPlayer
import net.minecraftforge.api.distmarker.Dist
import net.minecraftforge.client.ConfigScreenHandler.ConfigScreenFactory
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.entity.player.PlayerEvent
import net.minecraftforge.fml.ModLoadingContext
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.loading.FMLLoader
import net.minecraftforge.network.NetworkDirection
import net.minecraftforge.network.NetworkRegistry
import net.minecraftforge.network.PacketDistributor
import thedarkcolour.kotlinforforge.forge.DIST
import thedarkcolour.kotlinforforge.forge.FORGE_BUS
import java.util.*
@Mod("bbm")
object BetterBoatMovementEntrypoint {
init {
instantiateConfig(FMLLoader.getGamePath().resolve("config/better-boat-movement.json"))
val channel = NetworkRegistry.newSimpleChannel(resourceLocation("better-boat-movement:channel"), { "4" }, { true }, { true })
val channel = NetworkRegistry.newSimpleChannel(resourceLocation("bbm:channel"), { "4" }, { true }, { true })
channel.registerMessage(
0,
Config::class.java,
Expand All @@ -158,31 +145,24 @@ object BetterBoatMovementEntrypoint {
Optional.of(NetworkDirection.PLAY_TO_CLIENT)
)
when (DIST) {
when (FMLLoader.getDist()) {
Dist.DEDICATED_SERVER -> {
serverConfig = config
FORGE_BUS.addListener<PlayerEvent.PlayerLoggedInEvent> { event ->
MinecraftForge.EVENT_BUS.addListener<PlayerEvent.PlayerLoggedInEvent> { event ->
val player = event.entity
if (player !is ServerPlayer) return@addListener
channel.send(PacketDistributor.PLAYER.with { player }, serverConfig)
}
}
Dist.CLIENT -> {
FORGE_BUS.addListener<PlayerEvent.PlayerLoggedOutEvent> {
MinecraftForge.EVENT_BUS.addListener<PlayerEvent.PlayerLoggedOutEvent> {
serverConfig = null
}
}
else -> {}
}
// yacl 1.20.1 forge doesn't contain kotlin dsl
/^? if >1.20.1 {^/
/^ModLoadingContext.get().registerExtensionPoint(ConfigScreenFactory::class.java) {
ConfigScreenFactory { _, parent -> generateYaclScreen(parent) }
}
^//^?}^/
}
}
*//*?}*/
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/dev/nyon/bbm/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class Config(
) : CustomPacketPayload {
companion object {
@Transient
val packetType: CustomPacketPayload.Type<Config> = CustomPacketPayload.Type(resourceLocation("better-boat-movement:sync")!!)
val packetType: CustomPacketPayload.Type<Config> = CustomPacketPayload.Type(resourceLocation("bbm:sync")!!)

@Transient
@Suppress("unused")
Expand Down Expand Up @@ -81,7 +81,7 @@ data class Config(
companion object {
@Transient
val packetType: PacketType<Config> = PacketType.create(
resourceLocation("better-boat-movement:sync")!!
resourceLocation("bbm:sync")!!
) { buffer ->
Config(
buffer.readFloat(),
Expand Down Expand Up @@ -128,7 +128,7 @@ data class Config(
) : CustomPacketPayload {
companion object {
@Transient
val identifier = resourceLocation("better-boat-movement:sync")!!
val identifier = resourceLocation("bbm:sync")!!
}
constructor(buf: FriendlyByteBuf) : this(
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/dev/nyon/bbm/config/ConfigScreen.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.nyon.bbm.config

/*? if fabric && >=1.20.1 {*/
import dev.isxander.yacl3.dsl.*
import dev.nyon.konfig.config.saveConfig
import net.minecraft.client.gui.screens.Screen
Expand Down Expand Up @@ -72,4 +73,5 @@ fun generateYaclScreen(parent: Screen?): Screen = YetAnotherConfigLib("bbm") {
}

save { saveConfig(config) }
}.generateScreen(parent)
}.generateScreen(parent)
/*?}*/
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modLoader = "kotlinforforge"
modLoader = "klf"
loaderVersion = "[1,)"
license = "LGPLv3"
license = "GPLv3"

issueTrackerURL = "https://github.com/${repo}/issues"

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modLoader = "kotlinforforge"
modLoader = "klf"
loaderVersion = "[1,)"
license = "GNU General Public License v3.0"
license = "GPLv3"

issueTrackerURL = "https://github.com/${repo}/issues"

Expand Down
2 changes: 1 addition & 1 deletion stonecutter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ tasks.register("postUpdate") {
color = color,
fields = listOf(
Field(
"Supported versions", stonecutter.versions.map { it.version }.toSet().joinToString(), false
"Supported versions", stonecutter.projects.map { it.property("vers.supportedMcVersions").toString().split(',') }.flatten().toSet().joinToString(), false
),
Field(
"Supported loaders", supportedLoaders.joinToString(), false
Expand Down
2 changes: 1 addition & 1 deletion versions/1.19.4-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
vers.mcVersion=1.19.4
vers.mcVersionRange=>=1.19.3
vers.supportedMcVersions=1.19.3,1.19.4

vers.deps.quiltmappings=1.19.4+build.9
vers.deps.fapi=0.87.2+1.19.4
vers.deps.yacl=3.5.0+1.20.1-fabric
vers.deps.modMenu=7.2.2
vers.javaVer=17

loom.platform=fabric
4 changes: 1 addition & 3 deletions versions/1.19.4-forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
vers.mcVersion=1.19.4
vers.mcVersionRange=>=1.19.3
vers.supportedMcVersions=1.19.3,1.19.4

vers.deps.quiltmappings=1.19.4+build.9
vers.deps.fml=45.3.3
vers.deps.yacl=3.5.0+1.20.1-forge
vers.deps.kff=4.11.0
vers.javaVer=17

loom.platform=forge
2 changes: 1 addition & 1 deletion versions/1.20.1-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
vers.mcVersion=1.20.1
vers.mcVersionRange=>=1.20
vers.supportedMcVersions=1.20,1.20.1,1.20.2

vers.deps.quiltmappings=1.20.1+build.9
vers.deps.fapi=0.92.2+1.20.1
vers.deps.yacl=3.5.0+1.20.1-fabric
vers.deps.modMenu=7.2.2
vers.javaVer=17

loom.platform=fabric
4 changes: 1 addition & 3 deletions versions/1.20.1-forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
vers.mcVersion=1.20.1
vers.mcVersionRange=>=1.20
vers.supportedMcVersions=1.20,1.20.1,1.20.2

vers.deps.quiltmappings=1.20.1+build.9
vers.deps.fml=47.2.16
vers.deps.yacl=3.5.0+1.20.1-forge
vers.deps.kff=4.11.0
vers.javaVer=17

loom.platform=forge
4 changes: 2 additions & 2 deletions versions/1.20.4-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
vers.mcVersion=1.20.4
vers.mcVersionRange=>=1.20.3
vers.supportedMcVersions=1.20.4
vers.supportedMcVersions=1.20.3,1.20.4

vers.deps.quiltmappings=1.20.4+build.3
vers.deps.fapi=0.97.1+1.20.4
vers.deps.yacl=3.5.0+1.20.4-fabric
vers.deps.modMenu=9.2.0-beta.2
vers.javaVer=17

loom.platform=fabric
6 changes: 2 additions & 4 deletions versions/1.20.4-neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
vers.mcVersion=1.20.4
vers.mcVersionRange=>=1.20.3
vers.supportedMcVersions=1.20.4
vers.supportedMcVersions=1.20.3,1.20.4

vers.deps.quiltmappings=1.20.4+build.3
vers.deps.fml=20.4.237
vers.deps.yacl=3.5.0+1.20.4-neoforge
vers.deps.kff=4.11.0
vers.javaVer=17

loom.platform=neoforge
Loading

0 comments on commit 0ca0610

Please sign in to comment.