Port to 1.19.4
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
3d5b6133e5
commit
7574605480
|
@ -1,6 +1,6 @@
|
|||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
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 net.fabricmc.loom.LoomGradleExtension
|
||||
|
||||
|
@ -33,9 +33,9 @@ val sourceJavaVer: String = javaVer
|
|||
val kotlinVer: String by rootProject
|
||||
val kotlinSplitVersion = kotlinVer.split('.')
|
||||
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 }
|
||||
}.substring(0..3)
|
||||
}
|
||||
val kotlinX: String = "org.jetbrains.kotlinx"
|
||||
|
||||
subprojects {
|
||||
|
@ -51,7 +51,7 @@ subprojects {
|
|||
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
|
||||
extensions.configure<LoomGradleExtension>("loom") {
|
||||
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()
|
||||
val refmap = "snowygui-${project.name}-refmap.json"
|
||||
|
@ -76,7 +76,7 @@ subprojects {
|
|||
implementation("$kotlinX:kotlinx-serialization-json:$serializationVer")
|
||||
listOf(
|
||||
"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"
|
||||
).forEach { implementation(it); shadowC(it) { isTransitive = false; exclude("com.sun.jna") } }
|
||||
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
|
||||
|
@ -86,7 +86,7 @@ subprojects {
|
|||
extensions.configure<ModrinthExtension>("modrinth") {
|
||||
projectId.set("OuGyGg6A")
|
||||
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
|
||||
versionNumber.set(rootProject.version.toString() + "-${project.name}")
|
||||
versionType.set(VersionType.ALPHA.name)
|
||||
|
@ -134,6 +134,7 @@ subprojects {
|
|||
flattenpackagehierarchy("$group.snowygui")
|
||||
allowaccessmodification()
|
||||
adaptclassstrings()
|
||||
dontnote() // This is needed to silence warnings about duplicate classes
|
||||
"$group.**".also { dontnote(it); dontwarn(it) }
|
||||
|
||||
// kotlinx-serialization related configuration:
|
||||
|
@ -169,9 +170,9 @@ subprojects {
|
|||
dependsOn(shrinkJar)
|
||||
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
||||
archiveBaseName.set(shadowJar.archiveBaseName)
|
||||
archiveVersion.set("[${rootProject.version}+$mcBase]")
|
||||
archiveVersion.set("[${rootProject.version}+$minecraftVersion]")
|
||||
archiveClassifier.set(this@subprojects.name)
|
||||
input.set(shrinkedJar)
|
||||
inputFile.set(shrinkedJar)
|
||||
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
|
||||
}
|
||||
getByName("modrinth").dependsOn(build)
|
||||
|
@ -206,7 +207,7 @@ allprojects {
|
|||
"-Xbackend-threads=0", "-Xno-param-assertions", "-Xno-call-assertions",
|
||||
"-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())
|
||||
apiVersion = "${kotlinSplitVersion[0]}.${kotlinSplitVersion[1]}"
|
||||
}
|
||||
|
@ -216,7 +217,7 @@ allprojects {
|
|||
encoding = "UTF-8"
|
||||
isFork = true
|
||||
release.set(javaVer.toInt())
|
||||
sourceCompatibility = "11"
|
||||
sourceCompatibility = sourceJavaVer
|
||||
targetCompatibility = javaVer
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +229,7 @@ allprojects {
|
|||
}
|
||||
val modProperties = mapOf(
|
||||
"mod_version" to (rootProject.version as String),
|
||||
"minecraft_version" to mcBase,
|
||||
"minecraft_version" to minecraftVersion,
|
||||
"java_version" to javaVer,
|
||||
"mod_group" to this@allprojects.group,
|
||||
"fabric_kotlin" to rootProject.property("fabric_language_kotlin"),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
architectury { common(false); injectInjectables = false }
|
||||
architectury { common("fabric", "forge"); injectInjectables = false }
|
||||
dependencies {
|
||||
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
|
||||
modImplementation("me.shedaniel.cloth:cloth-config:${rootProject.property("clothconfig_version")}") {
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -19,6 +19,11 @@ abstract class Element(
|
|||
open var x = xOrigin; open var y = yOrigin
|
||||
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))
|
||||
|
||||
@JvmField
|
||||
protected var focused = false
|
||||
override fun isFocused() = focused
|
||||
override fun setFocused(boolean: Boolean) { focused = boolean }
|
||||
companion object {
|
||||
private var caughtError: Boolean = false
|
||||
fun fromRenderable(r: Renderable, x: Double, y: Double, width: Int, height: Int): Element {
|
||||
|
|
|
@ -10,8 +10,8 @@ import net.arikia.dev.drpc.DiscordRPC as discord_rpc
|
|||
object DiscordRPC: ButtonImpl() {
|
||||
private val RPCHandlers: DiscordEventHandlers = DiscordEventHandlers.Builder().build()
|
||||
private val RichPresence: DiscordRichPresence.Builder = DiscordRichPresence
|
||||
.Builder("Playing Minecraft ${Minecraft.getInstance().game.version.name}")
|
||||
.setDetails("Launched with ${Minecraft.getInstance().launchedVersion}")
|
||||
.Builder("Playing Minecraft ${Minecraft.getInstance().launchedVersion}")
|
||||
.setDetails("Launched with ${Minecraft.getInstance().versionType}")
|
||||
.setBigImage("icon", "SnowyGUI")
|
||||
override fun execAction() {
|
||||
if (toggled) discord_rpc.discordUpdatePresence(RichPresence.build())
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package fr.username404.snowygui.gui.feature
|
||||
|
||||
import fr.username404.snowygui.mixins.OptionValueAccessor
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
@ButtonInfo(Category.MISC)
|
||||
|
@ -8,13 +9,11 @@ object GammaBoost: ButtonImpl() {
|
|||
private var oldGamma = 0.0
|
||||
override fun execAction() {
|
||||
with(Minecraft.getInstance().options) {
|
||||
val gamma = gamma().get();
|
||||
gamma().set(
|
||||
if (toggled) {
|
||||
if (gamma < boost) oldGamma = gamma
|
||||
boost
|
||||
} else oldGamma
|
||||
)
|
||||
val gamma = gamma().get()
|
||||
(gamma() as OptionValueAccessor).setValue(if (toggled) {
|
||||
if (gamma < boost) oldGamma = gamma
|
||||
boost
|
||||
} else oldGamma)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,10 +15,10 @@ data class Macro(
|
|||
override var title: String = command
|
||||
): ButtonImpl() {
|
||||
override fun execAction(): Unit = with(Minecraft.getInstance().player!!) {
|
||||
chat(
|
||||
"/$command".let {
|
||||
if (it.startsWith("/say") && !hasPermissions(2)) {
|
||||
it.drop(5)
|
||||
connection.sendCommand(
|
||||
command.let {
|
||||
if (it.startsWith("say") && !hasPermissions(2)) {
|
||||
it.drop(4)
|
||||
} else it
|
||||
}
|
||||
)
|
||||
|
|
|
@ -24,12 +24,10 @@ object RenderingUtil {
|
|||
}
|
||||
fun prepareDraw() {
|
||||
colorShader()
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
}
|
||||
fun endDraw() {
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.disableBlend()
|
||||
}
|
||||
fun drawRectangle(
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
"KeysAccessor",
|
||||
"KeyMappings",
|
||||
"EndTickMixin",
|
||||
"TitleScreenMixin"
|
||||
"TitleScreenMixin",
|
||||
"OptionValueAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
@ -23,7 +23,7 @@ dependencies {
|
|||
exclude(group = Groups.FabricApi, module = "fabric-api-base")
|
||||
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 }
|
||||
shadowC(project(path = ":common", configuration = "transformProductionFabric")) { isTransitive = false }
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import kotlin.io.path.exists
|
|||
import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.listDirectoryEntries
|
||||
import kotlin.io.path.pathString
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
class FabricInit: Snowy(), ClientModInitializer {
|
||||
override fun onInitializeClient() {
|
||||
|
@ -23,8 +24,8 @@ class FabricInit: Snowy(), ClientModInitializer {
|
|||
}
|
||||
)
|
||||
}
|
||||
override val annotatedButtons = FabricLoader.getInstance().allMods.map {
|
||||
it.getPath(FeaturePackage.replace('.', '/'))
|
||||
override val annotatedButtons = FabricLoader.getInstance().allMods.mapNotNull {
|
||||
it.findPath(FeaturePackage.replace('.', '/')).getOrNull()
|
||||
}.filter { it.exists() && it.isDirectory() }.flatMap { buttonsDirectory ->
|
||||
mutableSetOf<Class<out ButtonImpl>>().apply {
|
||||
buttonsDirectory.listDirectoryEntries("*.class").forEach { file ->
|
||||
|
|
|
@ -6,15 +6,9 @@ import net.fabricmc.loader.api.FabricLoader
|
|||
@JvmField
|
||||
var isOkZoomerPresent: Boolean = FabricLoader.getInstance().isModLoaded("okzoomer")
|
||||
private val okZoomerPairs by lazy {
|
||||
try {
|
||||
with(Class.forName("io.github.joaoh1.okzoomer.client.utils.ZoomUtils")) {
|
||||
(getField("zoomDivisor") to null) to (getField("zoomState") to 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))
|
||||
}
|
||||
with(Class.forName("io.github.ennuil.okzoomer.utils.ZoomUtils").getDeclaredField("ZOOMER_ZOOM")) {
|
||||
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; }
|
||||
}
|
||||
|
@ -22,7 +16,7 @@ private val okZoomerPairs by lazy {
|
|||
fun fabricZoom() {
|
||||
try {
|
||||
with(okZoomerPairs) {
|
||||
first.run { first.setDouble(second, Zoom.zoomFactor) }
|
||||
first.run { first.setFloat(second, Zoom.zoomFactor.toFloat()) }
|
||||
second.run { first.setBoolean(second, Zoom.toggled) }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
|
|
@ -7,7 +7,7 @@ dependencies {
|
|||
forge("net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.property("forge_version")}.+")
|
||||
implementation("thedarkcolour:kotlinforforge:${rootProject.property("kotlinforforge")}")
|
||||
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 }
|
||||
shadowC(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
|
||||
}; loom {
|
||||
|
|
|
@ -7,7 +7,7 @@ import fr.username404.snowygui.gui.feature.ButtonImpl
|
|||
import net.minecraftforge.fml.ModList
|
||||
import net.minecraftforge.fml.common.Mod
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
|
||||
import net.minecraftforge.client.ConfigGuiHandler
|
||||
import net.minecraftforge.client.ConfigScreenHandler
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData
|
||||
import org.objectweb.asm.Type
|
||||
import thedarkcolour.kotlinforforge.forge.FORGE_BUS
|
||||
|
@ -20,8 +20,8 @@ class ForgeInit: Snowy() {
|
|||
private fun initSetup(event: FMLClientSetupEvent) = atInit()
|
||||
private fun configSetup(event: FMLClientSetupEvent) {
|
||||
LOADING_CONTEXT.registerExtensionPoint(
|
||||
ConfigGuiHandler.ConfigGuiFactory::class.java
|
||||
) { ConfigGuiHandler.ConfigGuiFactory { _, parent -> configScreenParent = parent; SnowyConfigScreen } }
|
||||
ConfigScreenHandler.ConfigScreenFactory::class.java
|
||||
) { ConfigScreenHandler.ConfigScreenFactory { _, parent -> configScreenParent = parent; SnowyConfigScreen } }
|
||||
}
|
||||
override val annotatedButtons = ModList.get() // Forge-specific reflection
|
||||
.allScanData
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package fr.username404.snowygui.forge
|
||||
|
||||
import fr.username404.snowygui.EventSnowy
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent
|
||||
import net.minecraftforge.client.event.RenderGuiEvent
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
|
||||
object HudHandler: EventSnowy {
|
||||
override val type: String = "HudRender"
|
||||
@SubscribeEvent
|
||||
fun handleRendering(event: RenderGameOverlayEvent.Post) {
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
|
||||
fire(event.matrixStack)
|
||||
}
|
||||
fun handleRendering(event: RenderGuiEvent.Post) {
|
||||
fire(event.poseStack)
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package fr.username404.snowygui.forge
|
||||
|
||||
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
|
||||
|
||||
object ZoomHandler {
|
||||
@SubscribeEvent
|
||||
fun onFOVEvent(event: EntityViewRenderEvent.FieldOfView) {
|
||||
if (Zoom.toggled) event.fov = Zoom.getNewZoom(event.fov)
|
||||
fun onFOVEvent(event: ComputeFovModifierEvent) {
|
||||
if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier.toDouble()).toFloat()
|
||||
}
|
||||
}
|
|
@ -7,16 +7,16 @@ org.gradle.parallel=true
|
|||
org.gradle.unsafe.configuration-cache=on
|
||||
org.gradle.vfs.watch=true
|
||||
|
||||
minecraft=22w16b
|
||||
forge_version=39.1
|
||||
kotlinforforge=3.1.0
|
||||
kotlinVer=1.6.0
|
||||
kotlin_coroutines_version=1.5.0
|
||||
serializationVer=1.2.1
|
||||
fabric_loader_version=0.11.7
|
||||
fabric_language_kotlin=1.7.0+kotlin.1.6.0
|
||||
fabric_resource_loader_version=0.4.24+ec94c6f6e0
|
||||
fabric_rendering_api_version=1.10.9+ec94c6f6e0
|
||||
minecraft=1.19.4
|
||||
forge_version=45.0
|
||||
kotlinforforge=4.1.0
|
||||
kotlinVer=1.8.20
|
||||
kotlin_coroutines_version=1.7.0-RC
|
||||
serializationVer=1.5.0
|
||||
fabric_loader_version=0.14.19
|
||||
fabric_language_kotlin=1.9.3+kotlin.1.8.20
|
||||
fabric_resource_loader_version=0.11.4+bd913b0d4e
|
||||
fabric_rendering_api_version=2.1.1+8f878217f4
|
||||
fabric_api_base_version=0.4.5+ec94c6f6e0
|
||||
clothconfig_version=7.0.60
|
||||
modmenu_version=3.0.1
|
||||
clothconfig_version=10.0.96
|
||||
modmenu_version=6.2.1
|
||||
|
|
|
@ -11,6 +11,7 @@ pluginManagement {
|
|||
|
||||
include("common")
|
||||
include("fabric")
|
||||
include("forge")
|
||||
|
||||
rootProject.name = "SnowyGUI"
|
||||
|
||||
|
|
Loading…
Reference in New Issue