Skip to content

Commit b103121

Browse files
committed
fix compile error + publishing
1 parent c34b9cd commit b103121

7 files changed

Lines changed: 107 additions & 21 deletions

File tree

fabric.gradle.kts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins {
1212
alias(libs.plugins.kotlin.serialization)
1313
alias(libs.plugins.atomicfu)
1414
id("net.fabricmc.fabric-loom")
15+
id("me.modmuss50.mod-publish-plugin")
1516
}
1617

1718
val stonecutter = extensions.getByName("stonecutter") as StonecutterBuildExtension
@@ -178,3 +179,40 @@ tasks.withType<ProcessResources>().configureEach {
178179
tasks.matching { it.name == "createMinecraftArtifacts" }.configureEach {
179180
dependsOn("stonecutterGenerate")
180181
}
182+
183+
val modVersion = property("mod.version") as String
184+
val modrinthMinecraftVersionOverride = mapOf(
185+
"26.1" to listOf("26.1", "26.1.1", "26.1.2")
186+
)
187+
val modrinthId = listOf("oneconfig.publish.modrinth", "publish.modrinth")
188+
.firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() }
189+
val modrinthToken = listOf("oneconfig.publish.modrinth.token", "publish.modrinth.token", "modrinth.token")
190+
.firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() }
191+
val minecraftVersion = modrinthMinecraftVersionOverride[mcVersion] ?: listOf(mcVersion)
192+
val publishJarTaskName = if ("remapJar" in tasks.names) "remapJar" else "jar"
193+
val changelogs = rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
194+
195+
publishMods {
196+
file = tasks.named<AbstractArchiveTask>(publishJarTaskName).flatMap { it.archiveFile }
197+
198+
displayName = modVersion
199+
version = "v$modVersion"
200+
changelog = changelogs
201+
type = STABLE
202+
203+
modLoaders.add("fabric")
204+
205+
dryRun = modrinthId == null || modrinthToken == null
206+
207+
if (modrinthId != null) {
208+
modrinth {
209+
projectId = modrinthId
210+
accessToken = modrinthToken.orEmpty()
211+
212+
minecraftVersions.addAll(minecraftVersion)
213+
214+
requires("oneconfig")
215+
requires("fabric-language-kotlin")
216+
}
217+
}
218+
}

fabric.obf.gradle.kts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins {
1212
alias(libs.plugins.kotlin.serialization)
1313
alias(libs.plugins.atomicfu)
1414
id("net.fabricmc.fabric-loom-remap")
15+
id("me.modmuss50.mod-publish-plugin")
1516
}
1617

1718
val stonecutter = extensions.getByName("stonecutter") as StonecutterBuildExtension
@@ -180,3 +181,40 @@ tasks.withType<ProcessResources>().configureEach {
180181
tasks.matching { it.name == "createMinecraftArtifacts" }.configureEach {
181182
dependsOn("stonecutterGenerate")
182183
}
184+
185+
val modVersion = property("mod.version") as String
186+
val modrinthMinecraftVersionOverride = mapOf(
187+
"26.1" to listOf("26.1", "26.1.1", "26.1.2")
188+
)
189+
val modrinthId = listOf("oneconfig.publish.modrinth", "publish.modrinth")
190+
.firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() }
191+
val modrinthToken = listOf("oneconfig.publish.modrinth.token", "publish.modrinth.token", "modrinth.token")
192+
.firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() }
193+
val minecraftVersion = modrinthMinecraftVersionOverride[mcVersion] ?: listOf(mcVersion)
194+
val publishJarTaskName = if ("remapJar" in tasks.names) "remapJar" else "jar"
195+
val changelogs = rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
196+
197+
publishMods {
198+
file = tasks.named<AbstractArchiveTask>(publishJarTaskName).flatMap { it.archiveFile }
199+
200+
displayName = modVersion
201+
version = "v$modVersion"
202+
changelog = changelogs
203+
type = STABLE
204+
205+
modLoaders.add("fabric")
206+
207+
dryRun = modrinthId == null || modrinthToken == null
208+
209+
if (modrinthId != null) {
210+
modrinth {
211+
projectId = modrinthId
212+
accessToken = modrinthToken.orEmpty()
213+
214+
minecraftVersions.addAll(minecraftVersion)
215+
216+
requires("oneconfig")
217+
requires("fabric-language-kotlin")
218+
}
219+
}
220+
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ mod.version=1.0.0
1616
mod.group=org.polyfrost
1717

1818
oneconfig_version=1.0.0
19+
20+
publish.modrinth=polyplus

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pluginManagement {
1616
id("net.fabricmc.fabric-loom") version "1.17-SNAPSHOT"
1717
id("net.fabricmc.fabric-loom-remap") version "1.17-SNAPSHOT"
1818
id("org.jetbrains.kotlinx.atomicfu") version "0.27.0"
19+
id("me.modmuss50.mod-publish-plugin") version "1.1.0"
1920
}
2021
}
2122

src/main/kotlin/org/polyfrost/polyplus/client/gui/PolyPlusMainMenuScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ internal fun mainMenuPanoramaEnabled(): Boolean {
406406
return PolyPlusConfig.mainMenuBackground == MainMenuBackground.PANORAMA
407407
}
408408

409-
private fun mcGuiScaleFactor(): Float {
409+
internal fun mcGuiScaleFactor(): Float {
410410
val mc = net.minecraft.client.Minecraft.getInstance()
411411
val current = mc.window.guiScale.toFloat()
412412
val auto = mc.window.calculateScale(0, mc.isEnforceUnicode).toFloat().coerceAtLeast(1f)

src/main/kotlin/org/polyfrost/polyplus/client/gui/PolyPlusOnboardingScreen.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class PolyPlusOnboardingScreen : ComposeScreen(RenderMode.CONTINUOUS) {
118118
buildList {
119119
add(OnboardingPage.LOOK_AND_FEEL)
120120
if (OnboardingFeatures.modsPageAvailable) add(OnboardingPage.MODS)
121-
add(OnboardingPage.COSMETICS)
121+
// add(OnboardingPage.COSMETICS)
122122
add(OnboardingPage.DONE)
123123
}
124124
}
@@ -148,7 +148,8 @@ class PolyPlusOnboardingScreen : ComposeScreen(RenderMode.CONTINUOUS) {
148148

149149
Theme {
150150
BoxWithConstraints(Modifier.fillMaxSize()) {
151-
val scale = minOf(maxWidth.value / DESIGN_WIDTH, maxHeight.value / DESIGN_HEIGHT)
151+
val scale = minOf(maxWidth.value / DESIGN_WIDTH, maxHeight.value / DESIGN_HEIGHT) *
152+
mcGuiScaleFactor() * UI_SCALE
152153
CompositionLocalProvider(LocalUiOversample provides (LocalUiOversample.current * scale.coerceAtLeast(1f))) {
153154
Box(
154155
Modifier
@@ -215,13 +216,18 @@ private fun LookAndFeelPage(
215216
onUiStyle: (Int) -> Unit,
216217
) {
217218
Header("Let’s configure the", "Look & Feel")
218-
SectionLabel("UI Colors", 140f)
219-
Row(Modifier.offset(232.dp, 172.dp), horizontalArrangement = Arrangement.spacedBy(18.dp)) {
219+
val colorsHeight = LABEL_HEIGHT + 32f
220+
val styleHeight = LABEL_HEIGHT + 155f
221+
val total = colorsHeight + SECTION_GAP + styleHeight
222+
var y = CONTENT_TOP + ((CONTENT_BOTTOM - CONTENT_TOP) - total) / 2f
223+
SectionLabel("UI Colors", y)
224+
Row(Modifier.offset(232.dp, (y + LABEL_HEIGHT).dp), horizontalArrangement = Arrangement.spacedBy(18.dp)) {
220225
ChoiceButton("Dark", MAIN_MENU_ASSETS + "moon-star.svg", !lightTheme, 198f) { onLightTheme(false) }
221226
ChoiceButton("Light", ONBOARDING_ASSETS + "sun.svg", lightTheme, 198f) { onLightTheme(true) }
222227
}
223-
SectionLabel("UI Style", 228f)
224-
Row(Modifier.offset(232.dp, 260.dp), horizontalArrangement = Arrangement.spacedBy(18.dp)) {
228+
y += colorsHeight + SECTION_GAP
229+
SectionLabel("UI Style", y)
230+
Row(Modifier.offset(232.dp, (y + LABEL_HEIGHT).dp), horizontalArrangement = Arrangement.spacedBy(18.dp)) {
225231
StyleCard("PolyGlass", uiStyle == 0, rounded = true) { onUiStyle(0) }
226232
StyleCard("Minecraft", uiStyle == 1, rounded = false) { onUiStyle(1) }
227233
}
@@ -548,6 +554,7 @@ private enum class OnboardingPage { LOOK_AND_FEEL, MODS, COSMETICS, DONE }
548554

549555
private const val DESIGN_WIDTH = 1920f
550556
private const val DESIGN_HEIGHT = 1080f
557+
private const val UI_SCALE = DESIGN_WIDTH / 1240f
551558
private const val PANEL_X = 520f
552559
private const val PANEL_Y = 210f
553560
private const val PANEL_WIDTH = 880f

src/main/kotlin/org/polyfrost/polyplus/client/gui/preview/PlayerPreviewRenderer.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,17 @@ object PlayerPreviewRenderer {
256256
bb.addVertex(px, py, 0f).setUv(tx, 1f - ty).setColor(255, 255, 255, a)
257257
}
258258

259+
private val mountOpacitySetter: java.lang.invoke.MethodHandle? = runCatching {
260+
val hook = Class.forName("dev.microcontrollers.mountopacity.hook.EntityRenderStateHook")
261+
java.lang.invoke.MethodHandles.lookup()
262+
.findVirtual(hook, "mountopacity\$setOpacity", java.lang.invoke.MethodType.methodType(Void.TYPE, Float::class.javaPrimitiveType))
263+
.asType(java.lang.invoke.MethodType.methodType(Void.TYPE, Any::class.java, Float::class.javaPrimitiveType))
264+
}.getOrNull()
265+
266+
private fun applyModCompat(state: Any) {
267+
mountOpacitySetter?.invokeExact(state, 100f)
268+
}
269+
259270
//? if >= 1.21.8 {
260271
private val LOG = org.slf4j.LoggerFactory.getLogger("polyplus/preview")
261272
private const val MAX_DIM = 512
@@ -630,22 +641,11 @@ object PlayerPreviewRenderer {
630641
}
631642
*///?}
632643

633-
private val mountOpacitySetter: java.lang.invoke.MethodHandle? = runCatching {
634-
val hook = Class.forName("dev.microcontrollers.mountopacity.hook.EntityRenderStateHook")
635-
java.lang.invoke.MethodHandles.lookup()
636-
.findVirtual(hook, "mountopacity\$setOpacity", java.lang.invoke.MethodType.methodType(Void.TYPE, Float::class.javaPrimitiveType))
637-
.asType(java.lang.invoke.MethodType.methodType(Void.TYPE, Any::class.java, Float::class.javaPrimitiveType))
638-
}.getOrNull()
639-
640-
private fun Any.applyModCompat() {
641-
mountOpacitySetter?.invokeExact(this, 100f)
642-
}
643-
644644
//? if >= 1.21.10 {
645645
private fun directState(skin: PlayerSkin): AvatarRenderState = AvatarRenderState().apply {
646646
(this as? org.polyfrost.polyplus.client.cosmetics.access.AvatarEmoteRenderAccess)
647647
?.`polyplus$bindEmoteController`(org.polyfrost.polyplus.client.emotes.playback.EmoteController())
648-
applyModCompat()
648+
applyModCompat(this)
649649
this.skin = skin
650650
mainArm = HumanoidArm.RIGHT
651651
leftArmPose = HumanoidModel.ArmPose.EMPTY
@@ -666,7 +666,7 @@ object PlayerPreviewRenderer {
666666
/*private fun directState(skin: PlayerSkin): AvatarRenderState = AvatarRenderState().apply {
667667
(this as? org.polyfrost.polyplus.client.cosmetics.access.AvatarEmoteRenderAccess)
668668
?.`polyplus$bindEmoteController`(org.polyfrost.polyplus.client.emotes.playback.EmoteController())
669-
applyModCompat()
669+
applyModCompat(this)
670670
this.skin = skin
671671
showHat = true
672672
showJacket = true
@@ -981,7 +981,7 @@ object PlayerPreviewRenderer {
981981
private fun legacyState(skin: PlayerSkin, yawDeg: Float): PlayerRenderState = PlayerRenderState().apply {
982982
(this as? org.polyfrost.polyplus.client.cosmetics.access.AvatarEmoteRenderAccess)
983983
?.`polyplus$bindEmoteController`(org.polyfrost.polyplus.client.emotes.playback.EmoteController())
984-
applyModCompat()
984+
applyModCompat(this)
985985
this.skin = skin
986986
showHat = true
987987
showJacket = true

0 commit comments

Comments
 (0)