Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions fabric.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ tasks.jar {
}
}

val serializationProvidedByFlk = setOf(
"org.jetbrains.kotlinx:kotlinx-serialization-core",
"org.jetbrains.kotlinx:kotlinx-serialization-json",
"org.jetbrains.kotlinx:kotlinx-serialization-cbor",
)

dependencies {
minecraft("com.mojang:minecraft:${versionCatalog("common$catalogVersion").findVersion("minecraft").get()}")

Expand All @@ -139,6 +145,7 @@ dependencies {

catalogLib("fabric-api")?.let { implementation(it) { isTransitive = true } }
catalogLib("fabric-loader")?.let { implementation(it) { isTransitive = true } }
catalogLib("fabric-language-kotlin")?.let { implementation(it) { isTransitive = false } }

catalogLib("sodium")?.let { compileOnly(it) { isTransitive = false } }

Expand All @@ -149,6 +156,7 @@ dependencies {

sentryShade(libs.sentry)
implementation(files(relocateSentry.flatMap { it.archiveFile }))
implementation(libs.bundles.serialization)
implementation(libs.bundles.ktor.client)
implementation(libs.bundles.ktor.server)
implementation(libs.bundles.ktor.serialization)
Expand All @@ -160,15 +168,19 @@ dependencies {
run {
val bundledRoots = libs.bundles.ktor.client.get() +
libs.bundles.ktor.server.get() +
libs.bundles.ktor.serialization.get()
libs.bundles.ktor.serialization.get() +
libs.bundles.serialization.get()
val closure = configurations.detachedConfiguration(
*bundledRoots.map { dependencies.create(it) }.toTypedArray()
)

fun key(group: String?, name: String) = "$group:${name.removeSuffix("-jvm")}"

closure.resolvedConfiguration.resolvedArtifacts.forEach { art ->
val id = art.moduleVersion.id
if (id.group != "org.jetbrains.kotlin") {
dependencies.include("${id.group}:${id.name}:${id.version}")
}
if (id.group == "org.jetbrains.kotlin") return@forEach
if (key(id.group, id.name) in serializationProvidedByFlk) return@forEach
dependencies.include("${id.group}:${id.name}:${id.version}")
}
}

Expand Down
20 changes: 16 additions & 4 deletions fabric.obf.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ tasks.jar {
}
}

val serializationProvidedByFlk = setOf(
"org.jetbrains.kotlinx:kotlinx-serialization-core",
"org.jetbrains.kotlinx:kotlinx-serialization-json",
"org.jetbrains.kotlinx:kotlinx-serialization-cbor",
)

dependencies {
minecraft("com.mojang:minecraft:${versionCatalog("common$catalogVersion").findVersion("minecraft").get()}")

Expand All @@ -147,6 +153,7 @@ dependencies {

catalogLib("fabric-api")?.let { modImplementation(it) { isTransitive = true } }
catalogLib("fabric-loader")?.let { modImplementation(it) { isTransitive = true } }
catalogLib("fabric-language-kotlin")?.let { modImplementation(it) { isTransitive = false } }

catalogLib("sodium")?.let { modCompileOnly(it) { isTransitive = false } }

Expand All @@ -157,6 +164,7 @@ dependencies {

sentryShade(libs.sentry)
implementation(files(relocateSentry.flatMap { it.archiveFile }))
implementation(libs.bundles.serialization)
implementation(libs.bundles.ktor.client)
implementation(libs.bundles.ktor.server)
implementation(libs.bundles.ktor.serialization)
Expand All @@ -168,15 +176,19 @@ dependencies {
run {
val bundledRoots = libs.bundles.ktor.client.get() +
libs.bundles.ktor.server.get() +
libs.bundles.ktor.serialization.get()
libs.bundles.ktor.serialization.get() +
libs.bundles.serialization.get()
val closure = configurations.detachedConfiguration(
*bundledRoots.map { dependencies.create(it) }.toTypedArray()
)

fun key(group: String?, name: String) = "$group:${name.removeSuffix("-jvm")}"

closure.resolvedConfiguration.resolvedArtifacts.forEach { art ->
val id = art.moduleVersion.id
if (id.group != "org.jetbrains.kotlin") {
dependencies.include("${id.group}:${id.name}:${id.version}")
}
if (id.group == "org.jetbrains.kotlin") return@forEach
if (key(id.group, id.name) in serializationProvidedByFlk) return@forEach
dependencies.include("${id.group}:${id.name}:${id.version}")
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle/fabric.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[versions]
loom = "1.16-SNAPSHOT"
loader = "0.19.2"
language-kotlin = "1.13.13+kotlin.2.4.10"

[libraries]
fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "loader" }
fabric-loader-junit = { module = "net.fabricmc:fabric-loader-junit", version.ref = "loader" }
fabric-language-kotlin = { module = "net.fabricmc:fabric-language-kotlin", version.ref = "language-kotlin" }

[plugins]
loom-remap = {id = "net.fabricmc.fabric-loom-remap", version.ref = "loom"}
Expand Down
10 changes: 10 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
kotlin = "2.3.0"
kotlinx-serialization = "2.3.0"
kotlinx-serialization-runtime = "1.11.0"
atomicfu = "0.27.0"
ktor = "3.3.1"
sentry = "7.18.0"
Expand All @@ -22,6 +23,10 @@ ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-conte
ktor-server-websockets = { group = "io.ktor", name = "ktor-server-websockets", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" }

kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core-jvm", version.ref = "kotlinx-serialization-runtime" }
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json-jvm", version.ref = "kotlinx-serialization-runtime" }
kotlinx-serialization-json-io = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json-io-jvm", version.ref = "kotlinx-serialization-runtime" }

mixin-extras = { module = "io.github.llamalad7:mixinextras-common", version.ref = "mixin-extras" }
mixin-squared = { module = "com.github.bawnorton.mixinsquared:mixinsquared-common", version.ref = "mixin-squared" }
polymixin = { module = "org.polyfrost:polymixin", version.ref = "polymixin" }
Expand All @@ -34,6 +39,11 @@ junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jun
ktor-client = ["ktor-client-core", "ktor-client-cio", "ktor-client-content-negotiation"]
ktor-server = ["ktor-server-websockets"]
ktor-serialization = ["ktor-serialization-kotlinx-json"]
serialization = [
"kotlinx-serialization-core",
"kotlinx-serialization-json",
"kotlinx-serialization-json-io",
]

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object PolyPlusClient {
//? if >= 1.21.1
step("pet entities") { PetEntities.register() }
//? if >= 1.21.1
EmoteWheelKeybind.register()
step("emote wheel keybind") { EmoteWheelKeybind.register() }

step("websocket") {
PolyConnection.initialize {
Expand Down
14 changes: 14 additions & 0 deletions src/main/kotlin/org/polyfrost/polyplus/client/PolyPlusSentry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,26 @@ object PolyPlusSentry {
return false
}

private val locallyHandled = ThreadLocal.withInitial { 0 }

fun <T> handlingLocally(block: () -> T): T {
val depth = locallyHandled.get()
locallyHandled.set(depth + 1)
return try {
block()
} finally {
locallyHandled.set(depth)
}
}

@JvmStatic
fun captureCrashReport(title: String?, throwable: Throwable) {
if (!PrivacyConsent.allowsOnlineServices()) return
initialize()
val hub = activeHub() ?: return

if (locallyHandled.get() > 0) return

val description = if (title.isNullOrBlank()) throwable.toString() else "$title: $throwable"
if (isIgnoredCrashReport(description) || isNeverReported(throwable)) {
PolyPlusCrashLogUploader.recordIgnoredCrash(throwable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ object CosmeticStore {
types: List<String> = emptyList(),
tags: List<String> = emptyList(),
collection: Int? = null,
reportFailures: Boolean = true,
): Result<CosmeticSearchResponse> = runCatching {
PolyPlusClient.HTTP.get("${PolyPlusConfig.apiUrl}/cosmetics/search") {
parameter("page", page.coerceAtLeast(1))
Expand All @@ -46,7 +47,7 @@ object CosmeticStore {
if (tags.isNotEmpty()) parameter("tags", tags.joinToString(","))
if (collection != null) parameter("collection", collection)
}.body<CosmeticSearchResponse>()
}.onFailure { reportFailure("Failed to search cosmetics", it) }
}.onFailure { if (reportFailures) reportFailure("Failed to search cosmetics", it) }

private var cachedStockedTypes: List<CosmeticType>? = null

Expand All @@ -57,14 +58,18 @@ object CosmeticStore {
val stocked = coroutineScope {
types.map { type ->
async {
val result = search(page = 1, perPage = 1, types = listOf(type.serializedName))
if (result.isSuccess) anySucceeded = true
val count = result.getOrNull()?.pagination?.totalItems
type.takeIf { count == null || count > 0 }
val response = search(
page = 1,
perPage = 1,
types = listOf(type.serializedName),
reportFailures = false,
).getOrNull() ?: return@async null
anySucceeded = true
type.takeIf { response.pagination.totalItems > 0 }
}
}.awaitAll()
}.filterNotNull()
if (!anySucceeded) return stocked
if (!anySucceeded) return types
return stocked.also { cachedStockedTypes = it }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ import org.polyfrost.oneconfig.api.event.v1.eventHandler
import org.polyfrost.oneconfig.api.event.v1.events.TickEvent
import org.polyfrost.polyplus.PolyPlusConstants
import org.polyfrost.polyplus.client.gui.EmoteWheelScreen
import java.util.concurrent.atomic.AtomicBoolean

object EmoteWheelKeybind {
private val logger = LogManager.getLogger("polyplus/emote-wheel")
private lateinit var keyMapping: KeyMapping

private val registered = AtomicBoolean(false)

fun isHeld(): Boolean {
val key = InputConstants.getKey(keyMapping.saveString())
if (key.type == InputConstants.Type.MOUSE) {
Expand All @@ -35,6 +38,8 @@ object EmoteWheelKeybind {
}

fun register() {
if (!registered.compareAndSet(false, true)) return

val mapping = KeyMapping(
"key.polyplus.emote_wheel",
InputConstants.Type.KEYSYM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,11 @@ object PlayerPreviewRenderer {
previewCape = capeOverride(source)?.let { ClientAsset.ResourceTexture(it).texturePath() }
renderingPreview = true
try {
val level = mc.level
if (level != null && mc.cameraEntity != null) renderEntity(mc, level, source, yawDeg, w, h, modelScale, verticalAnchor)
else renderDirect(mc, source, yawDeg, w, h, modelScale, verticalAnchor)
org.polyfrost.polyplus.client.PolyPlusSentry.handlingLocally {
val level = mc.level
if (level != null && mc.cameraEntity != null) renderEntity(mc, level, source, yawDeg, w, h, modelScale, verticalAnchor)
else renderDirect(mc, source, yawDeg, w, h, modelScale, verticalAnchor)
}
} catch (t: Throwable) {
LOG.error("[preview] entity submit failed; skipping frame", t)
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"fabric-api": "*",
"fabricloader": ">=0.16.0",
"java": ">=21",
"fabric-language-kotlin": ">=1.13.8",
"fabric-language-kotlin": ">=1.13.13",
"oneconfigv1": ">=1.1.2"
}
}