Skip to content
Merged
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
101 changes: 79 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import net.ornithemc.ploceus.api.PloceusGradleExtensionApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("dev.kikugie.loom-back-compat")
id("org.jetbrains.kotlin.jvm") version "2.4.10"
id("net.fabricmc.fabric-loom-remap") version "1.17-SNAPSHOT" apply false
id("ploceus") version "1.17.4" apply false
id("dev.deftu.gradle.bloom") version "0.2.0"
id("me.modmuss50.mod-publish-plugin") version "2.2.0"
}

val isOrnithe = stonecutter.current.version == "1.8.9"
val ploceus = if (isOrnithe) {
pluginManager.apply("net.fabricmc.fabric-loom-remap")
pluginManager.apply("ploceus")

configurations.configureEach {
exclude(group = "org.lwjgl.lwjgl")
}

extensions.getByType<PloceusGradleExtensionApi>().apply {
setIntermediaryGeneration(2)
}
} else {
null
}

val modid: String = sc.properties["mod.id"]
val modname: String = sc.properties["mod.name"]
val modversion: String = sc.properties["mod.version"]
val moddescription: String = sc.properties["mod.description"]
val mcversion: String = sc.current.version
val versionrange: String = sc.properties.getOrNull<String>("mod.mc_compat") ?: mcversion
val loaderversion: String = sc.properties["deps.fabric_loader"]
val oneconfigversion: String = sc.properties["deps.oneconfig"]
val fapiversion: String = sc.properties["deps.fabric_api"]
val loader = if (isOrnithe) "ornithe" else "fabric"

version = "$modversion+$mcversion"
base.archivesName = modname
base.archivesName = modid

val requiredJava: JavaVersion = when {
sc.current.parsed >= "26.1" -> JavaVersion.VERSION_25
else -> JavaVersion.VERSION_21
sc.current.parsed >= "1.20.5" -> JavaVersion.VERSION_21
sc.current.parsed >= "1.18" -> JavaVersion.VERSION_17
sc.current.parsed >= "1.17" -> JavaVersion.VERSION_16
else -> JavaVersion.VERSION_25
}

val compatibleVersions: List<String> = sc.properties.rawOrNull("mod", "mc_releases")
Expand All @@ -44,6 +65,9 @@ repositories {
name = "Sonatype Snapshots"
content { includeGroup("net.kyori") }
}
maven("https://maven.cloverclient.com/releases") {
content { includeGroup("pl.tomgirl") }
}
strictMaven("https://maven.deftu.dev/releases", "Deftu", "dev.deftu")
strictMaven("https://maven.terraformersmc.com/", "TerraformersMC", "com.terraformersmc")
strictMaven("https://maven.fabricmc.net/", "FabricMC", "net.fabricmc")
Expand All @@ -53,30 +77,54 @@ repositories {

dependencies {
minecraft("com.mojang:minecraft:$mcversion")
loomx.applyMojangMappings()
if (isOrnithe) {
mappings(ploceus!!.layeredMappings {
mappings("net.ornithemc:feather-gen2:$mcversion+build.${sc.properties["feather_version"] as String}:v2") {
containsUnpick()
}
mappings(rootProject.file("mappings/feather-overrides.tiny"))

})
} else {
loomx.applyMojangMappings()
}

modImplementation("net.fabricmc:fabric-loader:$loaderversion")
modImplementation("org.polyfrost.oneconfig:$mcversion-fabric:$oneconfigversion")
for (module in arrayOf("config", "config-impl", "events", "utils")) {
modImplementation("org.polyfrost.oneconfig:$mcversion-$loader:$oneconfigversion")
for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils", "hud")) {
implementation("org.polyfrost.oneconfig:$module:$oneconfigversion")
}

for (module in arrayOf(
"fabric-command-api-v2",
"fabric-screen-api-v1",
"fabric-resource-loader-v0",
"fabric-transitive-access-wideners-v1",
"fabric-lifecycle-events-v1"
)) {
modImplementation(fabricApi.module(module, fapiversion))
if (!isOrnithe) {
val fapiversion: String = sc.properties["deps.fabric_api"]
modImplementation("net.fabricmc.fabric-api:fabric-api:$fapiversion")
}

testImplementation("org.junit.jupiter:junit-jupiter:${sc.properties.get<String>("deps.junit")}")
testImplementation("net.fabricmc:fabric-loader-junit:$loaderversion")
}

sourceSets.main { // here's my easy workaround for mixins on each version
if (stonecutter.eval(stonecutter.current.version, "=1.8.9")) {
java.exclude("org/polyfrost/redaction/mixin/client/*.java")
java.exclude("org/polyfrost/redaction/mixin/client/accessor/*.java")
} else {
java.exclude("**/mixin/client/legacy/**")
}
}

tasks.withType<JavaCompile> {
if (stonecutter.eval(stonecutter.current.version, "=1.8.9")) {
exclude("org/polyfrost/redaction/mixin/client/*.java")
exclude("org/polyfrost/redaction/mixin/client/accessor/*.java")
} else {
exclude("**/mixin/client/legacy/**")
}
}

loom {
fabricModJsonPath = rootProject.file("src/main/resources/fabric.mod.json")
if (!isOrnithe) fabricModJsonPath = rootProject.file("src/main/resources/fabric.mod.json")
else fabricModJsonPath = rootProject.file("src/main/resources/ornithe.mod.json")

decompilerOptions.named("vineflower") {
options.put("mark-corresponding-synthetics", "1")
Expand Down Expand Up @@ -132,16 +180,25 @@ tasks {
val props = mapOf(
"mod_id" to modid,
"mod_name" to modname,
"mod_description" to (findProperty("mod_description") ?: "Redaction Mod"),
"mod_version" to modversion,
"mod_description" to moddescription,
"mc_compat" to versionrange,
"loader_version" to loaderversion,
"oneconfig_version" to oneconfigversion
)

inputs.properties(props)

filesMatching("fabric.mod.json") { expand(props) }
filesMatching("mixins.*.json") { expand("java" to "JAVA_${requiredJava.majorVersion}") }
if (isOrnithe) {
exclude("fabric.mod.json")
exclude("mixins.*.json")
rename("ornithe.mod.json", "fabric.mod.json")
filesMatching("ornithe.mod.json") { expand(props) }
} else {
exclude("ornithe.mod.json")
exclude("legacy-mixins.json")
filesMatching("fabric.mod.json") { expand(props) }
}
}

jar {
Expand All @@ -162,10 +219,10 @@ tasks {
}
}

val modrinthId = listOf("publish.modrinth.id", "publish.modrinth")
val modrinthId = listOf("oneconfig.publish.modrinth", "publish.modrinth")
.firstNotNullOfOrNull { sc.properties.getOrNull<String>(it) ?: findProperty(it)?.toString() }
?.takeIf { it.isNotBlank() }
val modrinthToken = listOf("publish.modrinth.token", "modrinth.token")
val modrinthToken = listOf("oneconfig.publish.modrinth.token", "publish.modrinth.token", "modrinth.token")
.firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() }

val changelogs = rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
Expand Down Expand Up @@ -209,4 +266,4 @@ publishMods {
requires("oneconfig", "fabric-api", "fabric-language-kotlin")
}
}
}
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true
# cus of bloom we cant use configuration cache
# org.gradle.configuration-cache=true
org.gradle.configureondemand=true
mod_version=1.0.0
minecraft_version=1.8.9
feather_version=2
fabric_version=0.19.3
18 changes: 18 additions & 0 deletions mappings/feather-overrides.tiny
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tiny 2 0 intermediary named
c net/minecraft/client/Minecraft net/minecraft/client/Minecraft
m (Lnet/minecraft/unmapped/C_85740840;)V m_52715402 setScreen
c net/minecraft/unmapped/C_23708450 net/minecraft/client/KeyMapping
m ()Z m_70603120 isDown
c net/minecraft/unmapped/C_76792751 net/minecraft/client/Options
f Lnet/minecraft/unmapped/C_23708450; f_50204069 keySprint
f Lnet/minecraft/unmapped/C_23708450; f_89071996 keyShift
f Lnet/minecraft/unmapped/C_23708450; f_94470987 keyJump
c net/minecraft/unmapped/C_57778754 net/minecraft/client/player/LocalPlayer
f I f_61582337 sprintTriggerTime
c net/minecraft/unmapped/C_88014908 net/minecraft/client/multiplayer/ClientPacketListener
c net/minecraft/unmapped/C_06007608$C_36868821 net/minecraft/world/level/GameType
m (Lnet/minecraft/unmapped/C_81721916;)V m_88990945 updatePlayerAbilities
c net/minecraft/unmapped/C_74425583 net/minecraft/world/entity/LivingEntity
m ()V m_11642923 aiStep
c net/minecraft/unmapped/C_81721916 net/minecraft/world/entity/player/Abilities
f Z f_63336874 instabuild
5 changes: 3 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
maven("https://maven.fabricmc.net/")
maven("https://maven.ornithemc.net/releases")
maven("https://maven.kikugie.dev/releases") { name = "KikuGie Releases" }
maven("https://maven.kikugie.dev/snapshots") { name = "KikuGie Snapshots" }
maven("https://maven.deftu.dev/releases")
Expand All @@ -22,11 +23,11 @@ plugins {

stonecutter {
create(rootProject) {
versions("1.21.1", "1.21.4", "1.21.5", "1.21.8", "1.21.10", "1.21.11", "26.1", "26.2")
versions("1.8.9", "1.21.1", "1.21.4", "1.21.5", "1.21.8", "1.21.10", "1.21.11", "26.1", "26.2")

vcsVersion = "26.2"
}
}

// Configures the root project Gradle name based on the value in `stonecutter.properties.toml`
rootProject.name = sc.properties["mod.name"]
rootProject.name = sc.properties["mod.name"]
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package org.polyfrost.redaction.client.features

//? if >1.8.9 {
import net.minecraft.client.AttackIndicatorStatus
import net.minecraft.client.DeltaTracker
import net.minecraft.client.gui.GuiGraphicsExtractor
import net.minecraft.client.gui.screens.ChatScreen
import net.minecraft.resources.Identifier
import net.minecraft.world.entity.HumanoidArm
import net.minecraft.world.entity.player.Player
import org.polyfrost.oneconfig.utils.v1.dsl.mc
import org.polyfrost.redaction.client.RedactionConfig
import org.polyfrost.redaction.mixin.client.accessor.HudAccessor
import org.polyfrost.redaction.mixin.client.accessor.SpectatorGuiAccessor
import net.minecraft.client.gui.spectator.categories.SpectatorPage
//?} else {
/*
import net.minecraft.client.gui.GuiElement
import net.minecraft.entity.living.player.PlayerEntity
import org.polyfrost.redaction.client.RedactionConfig
*///?}
import org.polyfrost.oneconfig.utils.v1.dsl.mc

import kotlin.math.roundToInt

object BlackBar {
//? if >1.8.9 {
private val HOTBAR_ATTACK_INDICATOR_BACKGROUND_SPRITE = Identifier.withDefaultNamespace("hud/hotbar_attack_indicator_background")
private val HOTBAR_ATTACK_INDICATOR_PROGRESS_SPRITE = Identifier.withDefaultNamespace("hud/hotbar_attack_indicator_progress")

Expand Down Expand Up @@ -205,6 +214,7 @@ object BlackBar {
//? if 1.21.1
//com.mojang.blaze3d.systems.RenderSystem.disableBlend()
}
//?}

private fun lerp(start: Float, end: Float, delta: Float): Float {
return start + (end - start) * delta.coerceIn(0f, 1f)
Expand All @@ -215,4 +225,24 @@ object BlackBar {
val a = ((argb ushr 24) * alphaMultiplier).toInt()
return (argb and 0x00FFFFFF) or (a shl 24)
}
//? if 1.8.9 {
/*
fun render(player: PlayerEntity) {
val scaledWidth = mc.window.guiScaledWidth
val scaledHeight = mc.window.guiScaledHeight
val y = scaledHeight - 22
val x = scaledWidth / 2 - 90 + player.inventory.selectedSlot * 20

if (RedactionConfig.blackbarColor.alpha != 0) {
drawRectEnhanced(0, y, scaledWidth, 22, RedactionConfig.blackbarColor.argb)
}
if (RedactionConfig.blackbarItemColor.alpha != 0) {
drawRectEnhanced(x, y, 22, 22, RedactionConfig.blackbarItemColor.argb)
}
}

fun drawRectEnhanced(x: Int, y: Int, width: Int, height: Int, color: Int) {
GuiElement.fill(x, y, width + x, height + y, color)
}
*///?}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ object ServerManager {
}

private fun saveLastServerIp() {
//? if >1.8.9 {
if (mc.singleplayerServer == null || mc.singleplayerServer!!.isPublished) { // Skip unpublished singleplayer worlds
RedactionConfig.lastServerIP = mc.currentServer?.ip ?: ""
RedactionConfig.lastServerJoined = true
RedactionConfig.save()
}
//?} else {

/*if (!mc.isSingleplayer) {
RedactionConfig.lastServerIP = mc.currentServerEntry?.ip ?: ""
RedactionConfig.lastServerJoined = true
RedactionConfig.save()
}
*///?}
}

private fun cacheServerNames() {
Expand Down
Loading