Skip to content

Commit

Permalink
fix forge 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion committed Sep 10, 2024
1 parent 7c87452 commit 9a21b6d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ base {
archivesName.set(rootProject.name)
}

val mixinsFile = property("mod.mixins").toString()
loom {
if (stonecutter.current.isActive) {
runConfigs.all {
Expand All @@ -36,6 +37,10 @@ loom {
}
}

if (loader == ModPlatform.FORGE) forge {
mixinConfigs(mixinsFile)
}

mixin { useLegacyMixinAp = false }
silentMojangMappingsLicense()
}
Expand Down Expand Up @@ -93,7 +98,6 @@ val modName = property("mod.name").toString()
val modDescription = property("mod.description").toString()
val mcVersionRange = property("vers.mcVersionRange").toString()
val icon = property("mod.icon").toString()
val mixinsFile = property("mod.mixins").toString()
val slug = property("mod.slug").toString()
tasks {
processResources {
Expand Down
35 changes: 19 additions & 16 deletions src/main/kotlin/dev/nyon/bbm/BetterBoatMovementEntrypoint.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.nyon.bbm

import dev.nyon.bbm.config.Config
import dev.nyon.bbm.config.config
import dev.nyon.bbm.config.migrate
import dev.nyon.bbm.config.serverConfig
import dev.nyon.konfig.config.config
Expand Down Expand Up @@ -40,7 +41,7 @@ object BetterBoatMovementEntrypoint : ModInitializer {
}
}
EnvType.SERVER -> {
serverConfig = dev.nyon.bbm.config.config
serverConfig = config

ServerPlayConnectionEvents.INIT.register { handler, _ ->
ServerPlayNetworking.send(handler.player, dev.nyon.bbm.config.config)
Expand All @@ -65,48 +66,47 @@ import thedarkcolour.kotlinforforge.neoforge.forge.DIST
import thedarkcolour.kotlinforforge.neoforge.forge.FORGE_BUS
/^? if >=1.20.5 {^/
/^import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent
import net.neoforged.neoforge.network.handling.DirectionalPayloadHandler^/
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent
import net.neoforged.neoforge.network.handling.DirectionalPayloadHandler
/^?} else {^/
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent
/^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 ^//^?}^/
typealias CSF = /^? if <1.20.5 {^/ /^net.neoforged.neoforge.client.ConfigScreenHandler.ConfigScreenFactory ^//^?} else {^/ net.neoforged.neoforge.client.gui.IConfigScreenFactory /^?}^/
@Mod("bbm")
object BetterBoatMovementEntrypoint {
init {
instantiateConfig(FMLLoader.getGamePath().resolve("config/better-boat-movement.json"))
/^? if >=1.20.5 {^/
/^MOD_BUS.addListener<RegisterPayloadHandlersEvent> { event ->
MOD_BUS.addListener<RegisterPayloadHandlersEvent> { event ->
val registrar = event.registrar("3")
registrar.playToClient(Config.packetType, Config.codec, DirectionalPayloadHandler(
{ config, _ ->
serverConfig = config
}, { _, _ -> }
))
}
^//^?} else {^/
MOD_BUS.addListener<RegisterPayloadHandlerEvent> { event ->
/^?} else {^/
/^MOD_BUS.addListener<RegisterPayloadHandlerEvent> { event ->
val registrar = event.registrar("3")
registrar.play(Config.identifier, FriendlyByteBuf.Reader{ buf -> Config(buf) }) { handler ->
handler.client { config, _ -> serverConfig = config }.server { _, _ -> }
}
}
/^?}^/
^//^?}^/
when (DIST) {
Dist.DEDICATED_SERVER -> {
serverConfig = dev.nyon.bbm.config.config
serverConfig = config
FORGE_BUS.addListener<PlayerLoggedInEvent> { event ->
val player = event.entity
if (player !is ServerPlayer) return@addListener
/^? if >=1.20.5 {^/ /^PacketDistributor.sendToPlayer(player, serverConfig!!)
^//^?} else {^/ PacketDistributor.PLAYER.with(player).send(serverConfig) /^?}^/
/^? if >=1.20.5 {^/ PacketDistributor.sendToPlayer(player, serverConfig!!)
/^?} else {^/ /^PacketDistributor.PLAYER.with(player).send(serverConfig) ^//^?}^/
}
}
Expand Down Expand Up @@ -160,7 +160,7 @@ object BetterBoatMovementEntrypoint {
when (DIST) {
Dist.DEDICATED_SERVER -> {
serverConfig = dev.nyon.bbm.config.config
serverConfig = config
FORGE_BUS.addListener<PlayerEvent.PlayerLoggedInEvent> { event ->
val player = event.entity
if (player !is ServerPlayer) return@addListener
Expand All @@ -177,9 +177,12 @@ object BetterBoatMovementEntrypoint {
else -> {}
}
// yacl 1.20.1 forge doesn't contains kotlin dsl
/^? if >1.20.1 {^/
ModLoadingContext.get().registerExtensionPoint(ConfigScreenFactory::class.java) {
ConfigScreenFactory { _, parent -> generateYaclScreen(parent) }
}
/^?}^/
}
}
*//*?}*/
Expand All @@ -190,5 +193,5 @@ private fun instantiateConfig(path: Path) {
3,
Config()
) { element, version -> migrate(element, version) }
dev.nyon.bbm.config.config = loadConfig()
config = loadConfig()
}

0 comments on commit 9a21b6d

Please sign in to comment.