Port to 1.19.4

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2023-04-28 16:00:28 +02:00
parent 3d5b6133e5
commit 7574605480
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
18 changed files with 74 additions and 65 deletions

View File

@ -1,6 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.modrinth.minotaur.ModrinthExtension import com.modrinth.minotaur.ModrinthExtension
import com.modrinth.minotaur.request.VersionType import masecla.modrinth4j.model.version.ProjectVersion.VersionType
import com.modrinth.minotaur.dependencies.DependencyType import com.modrinth.minotaur.dependencies.DependencyType
import net.fabricmc.loom.LoomGradleExtension import net.fabricmc.loom.LoomGradleExtension
@ -33,9 +33,9 @@ val sourceJavaVer: String = javaVer
val kotlinVer: String by rootProject val kotlinVer: String by rootProject
val kotlinSplitVersion = kotlinVer.split('.') val kotlinSplitVersion = kotlinVer.split('.')
val serializationVer: String by rootProject val serializationVer: String by rootProject
val mcBase: String = (rootProject.property("minecraft") as String).also { val minecraftVersion: String = (rootProject.property("minecraft") as String).also {
architectury { minecraft = it } architectury { minecraft = it }
}.substring(0..3) }
val kotlinX: String = "org.jetbrains.kotlinx" val kotlinX: String = "org.jetbrains.kotlinx"
subprojects { subprojects {
@ -51,7 +51,7 @@ subprojects {
apply(plugin = "org.jetbrains.kotlin.plugin.serialization") apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
extensions.configure<LoomGradleExtension>("loom") { extensions.configure<LoomGradleExtension>("loom") {
mappingsDep = layered { mappingsDep = layered {
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.18.2:2022.03.13") officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.19.3:2023.03.12")
} }
silentMojangMappingsLicense() silentMojangMappingsLicense()
val refmap = "snowygui-${project.name}-refmap.json" val refmap = "snowygui-${project.name}-refmap.json"
@ -76,7 +76,7 @@ subprojects {
implementation("$kotlinX:kotlinx-serialization-json:$serializationVer") implementation("$kotlinX:kotlinx-serialization-json:$serializationVer")
listOf( listOf(
"com.typesafe:config:1.4.2", "com.typesafe:config:1.4.2",
"io.github.config4k:config4k:0.4.2", "io.github.config4k:config4k:0.5.0",
"com.github.Vatuu:discord-rpc:1.6.2" "com.github.Vatuu:discord-rpc:1.6.2"
).forEach { implementation(it); shadowC(it) { isTransitive = false; exclude("com.sun.jna") } } ).forEach { implementation(it); shadowC(it) { isTransitive = false; exclude("com.sun.jna") } }
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}") "minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
@ -86,7 +86,7 @@ subprojects {
extensions.configure<ModrinthExtension>("modrinth") { extensions.configure<ModrinthExtension>("modrinth") {
projectId.set("OuGyGg6A") projectId.set("OuGyGg6A")
syncBodyFrom.set("$rootDir/README.md") syncBodyFrom.set("$rootDir/README.md")
gameVersions.add(mcBase) gameVersions.add(minecraftVersion)
if (project.name == "forge") dependencies.add(com.modrinth.minotaur.dependencies.VersionDependency("Bxm9xbNJ", DependencyType.REQUIRED)) // Kotlinforforge dependency if (project.name == "forge") dependencies.add(com.modrinth.minotaur.dependencies.VersionDependency("Bxm9xbNJ", DependencyType.REQUIRED)) // Kotlinforforge dependency
versionNumber.set(rootProject.version.toString() + "-${project.name}") versionNumber.set(rootProject.version.toString() + "-${project.name}")
versionType.set(VersionType.ALPHA.name) versionType.set(VersionType.ALPHA.name)
@ -134,6 +134,7 @@ subprojects {
flattenpackagehierarchy("$group.snowygui") flattenpackagehierarchy("$group.snowygui")
allowaccessmodification() allowaccessmodification()
adaptclassstrings() adaptclassstrings()
dontnote() // This is needed to silence warnings about duplicate classes
"$group.**".also { dontnote(it); dontwarn(it) } "$group.**".also { dontnote(it); dontwarn(it) }
// kotlinx-serialization related configuration: // kotlinx-serialization related configuration:
@ -169,9 +170,9 @@ subprojects {
dependsOn(shrinkJar) dependsOn(shrinkJar)
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
archiveBaseName.set(shadowJar.archiveBaseName) archiveBaseName.set(shadowJar.archiveBaseName)
archiveVersion.set("[${rootProject.version}+$mcBase]") archiveVersion.set("[${rootProject.version}+$minecraftVersion]")
archiveClassifier.set(this@subprojects.name) archiveClassifier.set(this@subprojects.name)
input.set(shrinkedJar) inputFile.set(shrinkedJar)
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars")) if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
} }
getByName("modrinth").dependsOn(build) getByName("modrinth").dependsOn(build)
@ -206,7 +207,7 @@ allprojects {
"-Xbackend-threads=0", "-Xno-param-assertions", "-Xno-call-assertions", "-Xbackend-threads=0", "-Xno-param-assertions", "-Xno-call-assertions",
"-opt-in=kotlin.RequiresOptIn", "-Xextended-compiler-checks", "-Xassertions=jvm", "-progressive" "-opt-in=kotlin.RequiresOptIn", "-Xextended-compiler-checks", "-Xassertions=jvm", "-progressive"
) )
jvmTarget = if (javaVer.toInt() < 9) "1.$javaVer" else javaVer jvmTarget = javaVer
languageVersion = (kotlinSplitVersion[0] + '.' + (kotlinSplitVersion[1].toShort() + 1).toString()) languageVersion = (kotlinSplitVersion[0] + '.' + (kotlinSplitVersion[1].toShort() + 1).toString())
apiVersion = "${kotlinSplitVersion[0]}.${kotlinSplitVersion[1]}" apiVersion = "${kotlinSplitVersion[0]}.${kotlinSplitVersion[1]}"
} }
@ -216,7 +217,7 @@ allprojects {
encoding = "UTF-8" encoding = "UTF-8"
isFork = true isFork = true
release.set(javaVer.toInt()) release.set(javaVer.toInt())
sourceCompatibility = "11" sourceCompatibility = sourceJavaVer
targetCompatibility = javaVer targetCompatibility = javaVer
} }
} }
@ -228,7 +229,7 @@ allprojects {
} }
val modProperties = mapOf( val modProperties = mapOf(
"mod_version" to (rootProject.version as String), "mod_version" to (rootProject.version as String),
"minecraft_version" to mcBase, "minecraft_version" to minecraftVersion,
"java_version" to javaVer, "java_version" to javaVer,
"mod_group" to this@allprojects.group, "mod_group" to this@allprojects.group,
"fabric_kotlin" to rootProject.property("fabric_language_kotlin"), "fabric_kotlin" to rootProject.property("fabric_language_kotlin"),

View File

@ -1,4 +1,4 @@
architectury { common(false); injectInjectables = false } architectury { common("fabric", "forge"); injectInjectables = false }
dependencies { dependencies {
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}") modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
modImplementation("me.shedaniel.cloth:cloth-config:${rootProject.property("clothconfig_version")}") { modImplementation("me.shedaniel.cloth:cloth-config:${rootProject.property("clothconfig_version")}") {

View File

@ -0,0 +1,11 @@
package fr.username404.snowygui.mixins;
import net.minecraft.client.OptionInstance;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(OptionInstance.class)
public interface OptionValueAccessor {
@Accessor("value")
void setValue(Object value);
}

View File

@ -19,6 +19,11 @@ abstract class Element(
open var x = xOrigin; open var y = yOrigin open var x = xOrigin; open var y = yOrigin
fun isWithinBounds(coordinateX: Double, coordinateY: Double, offsetWidth: Double = 0.0, offsetHeight: Double = 0.0): Boolean = fun isWithinBounds(coordinateX: Double, coordinateY: Double, offsetWidth: Double = 0.0, offsetHeight: Double = 0.0): Boolean =
(coordinateX in x..(x + width + offsetWidth)) && (coordinateY in y..(y + height + offsetHeight)) (coordinateX in x..(x + width + offsetWidth)) && (coordinateY in y..(y + height + offsetHeight))
@JvmField
protected var focused = false
override fun isFocused() = focused
override fun setFocused(boolean: Boolean) { focused = boolean }
companion object { companion object {
private var caughtError: Boolean = false private var caughtError: Boolean = false
fun fromRenderable(r: Renderable, x: Double, y: Double, width: Int, height: Int): Element { fun fromRenderable(r: Renderable, x: Double, y: Double, width: Int, height: Int): Element {

View File

@ -10,8 +10,8 @@ import net.arikia.dev.drpc.DiscordRPC as discord_rpc
object DiscordRPC: ButtonImpl() { object DiscordRPC: ButtonImpl() {
private val RPCHandlers: DiscordEventHandlers = DiscordEventHandlers.Builder().build() private val RPCHandlers: DiscordEventHandlers = DiscordEventHandlers.Builder().build()
private val RichPresence: DiscordRichPresence.Builder = DiscordRichPresence private val RichPresence: DiscordRichPresence.Builder = DiscordRichPresence
.Builder("Playing Minecraft ${Minecraft.getInstance().game.version.name}") .Builder("Playing Minecraft ${Minecraft.getInstance().launchedVersion}")
.setDetails("Launched with ${Minecraft.getInstance().launchedVersion}") .setDetails("Launched with ${Minecraft.getInstance().versionType}")
.setBigImage("icon", "SnowyGUI") .setBigImage("icon", "SnowyGUI")
override fun execAction() { override fun execAction() {
if (toggled) discord_rpc.discordUpdatePresence(RichPresence.build()) if (toggled) discord_rpc.discordUpdatePresence(RichPresence.build())

View File

@ -1,5 +1,6 @@
package fr.username404.snowygui.gui.feature package fr.username404.snowygui.gui.feature
import fr.username404.snowygui.mixins.OptionValueAccessor
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
@ButtonInfo(Category.MISC) @ButtonInfo(Category.MISC)
@ -8,13 +9,11 @@ object GammaBoost: ButtonImpl() {
private var oldGamma = 0.0 private var oldGamma = 0.0
override fun execAction() { override fun execAction() {
with(Minecraft.getInstance().options) { with(Minecraft.getInstance().options) {
val gamma = gamma().get(); val gamma = gamma().get()
gamma().set( (gamma() as OptionValueAccessor).setValue(if (toggled) {
if (toggled) { if (gamma < boost) oldGamma = gamma
if (gamma < boost) oldGamma = gamma boost
boost } else oldGamma)
} else oldGamma
)
} }
} }
} }

View File

@ -15,10 +15,10 @@ data class Macro(
override var title: String = command override var title: String = command
): ButtonImpl() { ): ButtonImpl() {
override fun execAction(): Unit = with(Minecraft.getInstance().player!!) { override fun execAction(): Unit = with(Minecraft.getInstance().player!!) {
chat( connection.sendCommand(
"/$command".let { command.let {
if (it.startsWith("/say") && !hasPermissions(2)) { if (it.startsWith("say") && !hasPermissions(2)) {
it.drop(5) it.drop(4)
} else it } else it
} }
) )

View File

@ -24,12 +24,10 @@ object RenderingUtil {
} }
fun prepareDraw() { fun prepareDraw() {
colorShader() colorShader()
RenderSystem.disableTexture()
RenderSystem.enableBlend() RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc() RenderSystem.defaultBlendFunc()
} }
fun endDraw() { fun endDraw() {
RenderSystem.enableTexture()
RenderSystem.disableBlend() RenderSystem.disableBlend()
} }
fun drawRectangle( fun drawRectangle(

View File

@ -6,7 +6,8 @@
"KeysAccessor", "KeysAccessor",
"KeyMappings", "KeyMappings",
"EndTickMixin", "EndTickMixin",
"TitleScreenMixin" "TitleScreenMixin",
"OptionValueAccessor"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1

View File

@ -23,7 +23,7 @@ dependencies {
exclude(group = Groups.FabricApi, module = "fabric-api-base") exclude(group = Groups.FabricApi, module = "fabric-api-base")
exclude(group = Groups.FabricApi, module = "fabric-resource-loader-v0") exclude(group = Groups.FabricApi, module = "fabric-resource-loader-v0")
} }
implementation(project(path = ":common")) { isTransitive = false } implementation(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
add("developmentFabric", project(path = ":common")) { isTransitive = false } add("developmentFabric", project(path = ":common")) { isTransitive = false }
shadowC(project(path = ":common", configuration = "transformProductionFabric")) { isTransitive = false } shadowC(project(path = ":common", configuration = "transformProductionFabric")) { isTransitive = false }
} }

View File

@ -12,6 +12,7 @@ import kotlin.io.path.exists
import kotlin.io.path.isDirectory import kotlin.io.path.isDirectory
import kotlin.io.path.listDirectoryEntries import kotlin.io.path.listDirectoryEntries
import kotlin.io.path.pathString import kotlin.io.path.pathString
import kotlin.jvm.optionals.getOrNull
class FabricInit: Snowy(), ClientModInitializer { class FabricInit: Snowy(), ClientModInitializer {
override fun onInitializeClient() { override fun onInitializeClient() {
@ -23,8 +24,8 @@ class FabricInit: Snowy(), ClientModInitializer {
} }
) )
} }
override val annotatedButtons = FabricLoader.getInstance().allMods.map { override val annotatedButtons = FabricLoader.getInstance().allMods.mapNotNull {
it.getPath(FeaturePackage.replace('.', '/')) it.findPath(FeaturePackage.replace('.', '/')).getOrNull()
}.filter { it.exists() && it.isDirectory() }.flatMap { buttonsDirectory -> }.filter { it.exists() && it.isDirectory() }.flatMap { buttonsDirectory ->
mutableSetOf<Class<out ButtonImpl>>().apply { mutableSetOf<Class<out ButtonImpl>>().apply {
buttonsDirectory.listDirectoryEntries("*.class").forEach { file -> buttonsDirectory.listDirectoryEntries("*.class").forEach { file ->

View File

@ -6,15 +6,9 @@ import net.fabricmc.loader.api.FabricLoader
@JvmField @JvmField
var isOkZoomerPresent: Boolean = FabricLoader.getInstance().isModLoaded("okzoomer") var isOkZoomerPresent: Boolean = FabricLoader.getInstance().isModLoaded("okzoomer")
private val okZoomerPairs by lazy { private val okZoomerPairs by lazy {
try { with(Class.forName("io.github.ennuil.okzoomer.utils.ZoomUtils").getDeclaredField("ZOOMER_ZOOM")) {
with(Class.forName("io.github.joaoh1.okzoomer.client.utils.ZoomUtils")) { get(null).javaClass.run {
(getField("zoomDivisor") to null) to (getField("zoomState") to null) (getDeclaredField("zoomDivisor") to this@with.get(null)) to (getDeclaredField("zoom") to this@with.get(null))
}
} catch (e: ClassNotFoundException) {
with(Class.forName("io.github.ennuil.okzoomer.utils.ZoomUtils").getDeclaredField("zoomerZoom")) {
get(null).javaClass.run {
(getDeclaredField("zoomDivisor") to this@with.get(null)) to (getDeclaredField("zoom") to this@with.get(null))
}
} }
}.apply { first.first.isAccessible = true; second.first.isAccessible = true; } }.apply { first.first.isAccessible = true; second.first.isAccessible = true; }
} }
@ -22,7 +16,7 @@ private val okZoomerPairs by lazy {
fun fabricZoom() { fun fabricZoom() {
try { try {
with(okZoomerPairs) { with(okZoomerPairs) {
first.run { first.setDouble(second, Zoom.zoomFactor) } first.run { first.setFloat(second, Zoom.zoomFactor.toFloat()) }
second.run { first.setBoolean(second, Zoom.toggled) } second.run { first.setBoolean(second, Zoom.toggled) }
} }
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -7,7 +7,7 @@ dependencies {
forge("net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.property("forge_version")}.+") forge("net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.property("forge_version")}.+")
implementation("thedarkcolour:kotlinforforge:${rootProject.property("kotlinforforge")}") implementation("thedarkcolour:kotlinforforge:${rootProject.property("kotlinforforge")}")
modApi("me.shedaniel.cloth:cloth-config-forge:${rootProject.property("clothconfig_version")}") modApi("me.shedaniel.cloth:cloth-config-forge:${rootProject.property("clothconfig_version")}")
implementation(project(path = ":common")) { isTransitive = false } implementation(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
add("developmentForge", project(path = ":common")) { isTransitive = false } add("developmentForge", project(path = ":common")) { isTransitive = false }
shadowC(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false } shadowC(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
}; loom { }; loom {

View File

@ -7,7 +7,7 @@ import fr.username404.snowygui.gui.feature.ButtonImpl
import net.minecraftforge.fml.ModList import net.minecraftforge.fml.ModList
import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
import net.minecraftforge.client.ConfigGuiHandler import net.minecraftforge.client.ConfigScreenHandler
import net.minecraftforge.forgespi.language.ModFileScanData import net.minecraftforge.forgespi.language.ModFileScanData
import org.objectweb.asm.Type import org.objectweb.asm.Type
import thedarkcolour.kotlinforforge.forge.FORGE_BUS import thedarkcolour.kotlinforforge.forge.FORGE_BUS
@ -20,8 +20,8 @@ class ForgeInit: Snowy() {
private fun initSetup(event: FMLClientSetupEvent) = atInit() private fun initSetup(event: FMLClientSetupEvent) = atInit()
private fun configSetup(event: FMLClientSetupEvent) { private fun configSetup(event: FMLClientSetupEvent) {
LOADING_CONTEXT.registerExtensionPoint( LOADING_CONTEXT.registerExtensionPoint(
ConfigGuiHandler.ConfigGuiFactory::class.java ConfigScreenHandler.ConfigScreenFactory::class.java
) { ConfigGuiHandler.ConfigGuiFactory { _, parent -> configScreenParent = parent; SnowyConfigScreen } } ) { ConfigScreenHandler.ConfigScreenFactory { _, parent -> configScreenParent = parent; SnowyConfigScreen } }
} }
override val annotatedButtons = ModList.get() // Forge-specific reflection override val annotatedButtons = ModList.get() // Forge-specific reflection
.allScanData .allScanData

View File

@ -1,15 +1,13 @@
package fr.username404.snowygui.forge package fr.username404.snowygui.forge
import fr.username404.snowygui.EventSnowy import fr.username404.snowygui.EventSnowy
import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.client.event.RenderGuiEvent
import net.minecraftforge.eventbus.api.SubscribeEvent import net.minecraftforge.eventbus.api.SubscribeEvent
object HudHandler: EventSnowy { object HudHandler: EventSnowy {
override val type: String = "HudRender" override val type: String = "HudRender"
@SubscribeEvent @SubscribeEvent
fun handleRendering(event: RenderGameOverlayEvent.Post) { fun handleRendering(event: RenderGuiEvent.Post) {
if (event.type == RenderGameOverlayEvent.ElementType.ALL) { fire(event.poseStack)
fire(event.matrixStack)
}
} }
} }

View File

@ -1,12 +1,12 @@
package fr.username404.snowygui.forge package fr.username404.snowygui.forge
import fr.username404.snowygui.gui.feature.Zoom import fr.username404.snowygui.gui.feature.Zoom
import net.minecraftforge.client.event.EntityViewRenderEvent import net.minecraftforge.client.event.ComputeFovModifierEvent
import net.minecraftforge.eventbus.api.SubscribeEvent import net.minecraftforge.eventbus.api.SubscribeEvent
object ZoomHandler { object ZoomHandler {
@SubscribeEvent @SubscribeEvent
fun onFOVEvent(event: EntityViewRenderEvent.FieldOfView) { fun onFOVEvent(event: ComputeFovModifierEvent) {
if (Zoom.toggled) event.fov = Zoom.getNewZoom(event.fov) if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier.toDouble()).toFloat()
} }
} }

View File

@ -7,16 +7,16 @@ org.gradle.parallel=true
org.gradle.unsafe.configuration-cache=on org.gradle.unsafe.configuration-cache=on
org.gradle.vfs.watch=true org.gradle.vfs.watch=true
minecraft=22w16b minecraft=1.19.4
forge_version=39.1 forge_version=45.0
kotlinforforge=3.1.0 kotlinforforge=4.1.0
kotlinVer=1.6.0 kotlinVer=1.8.20
kotlin_coroutines_version=1.5.0 kotlin_coroutines_version=1.7.0-RC
serializationVer=1.2.1 serializationVer=1.5.0
fabric_loader_version=0.11.7 fabric_loader_version=0.14.19
fabric_language_kotlin=1.7.0+kotlin.1.6.0 fabric_language_kotlin=1.9.3+kotlin.1.8.20
fabric_resource_loader_version=0.4.24+ec94c6f6e0 fabric_resource_loader_version=0.11.4+bd913b0d4e
fabric_rendering_api_version=1.10.9+ec94c6f6e0 fabric_rendering_api_version=2.1.1+8f878217f4
fabric_api_base_version=0.4.5+ec94c6f6e0 fabric_api_base_version=0.4.5+ec94c6f6e0
clothconfig_version=7.0.60 clothconfig_version=10.0.96
modmenu_version=3.0.1 modmenu_version=6.2.1

View File

@ -11,6 +11,7 @@ pluginManagement {
include("common") include("common")
include("fabric") include("fabric")
include("forge")
rootProject.name = "SnowyGUI" rootProject.name = "SnowyGUI"