Compare commits
29 Commits
Author | SHA1 | Date |
---|---|---|
Username404-59 | 0db5d80cf1 | |
Username404-59 | d44f871335 | |
Username404-59 | d60d506c6c | |
Username404-59 | c58eee6631 | |
Username404-59 | c204db0d47 | |
Username404-59 | aebff3e15e | |
Username404-59 | 01c420b4cc | |
Username404-59 | bc10ffa2cf | |
Username404 | 5563e59603 | |
Username404 | 2772d52217 | |
Username404 | f4834255ec | |
Username404 | 771820f72f | |
Username404 | 45c3fe54e8 | |
Username404 | 40d9ee1605 | |
Username404-59 | 119b75811f | |
Username404 | 0f28ac6b33 | |
Username404 | 36cf819f02 | |
Username404 | 9e0214acd9 | |
Username404 | 4df3066134 | |
Username404 | 76b28db14b | |
Username404 | 312b875267 | |
Username404 | f8ae9f1ad1 | |
Username404 | 840e041817 | |
Username404 | 65d8aa75ee | |
Username404 | 24c99cd79e | |
Username404 | ed9ccc399f | |
Username404 | 7574605480 | |
Username404 | 3d5b6133e5 | |
Username404 | 0a2175c2e1 |
|
@ -1,5 +1,8 @@
|
|||
pipeline {
|
||||
agent any
|
||||
environment {
|
||||
JAVA_HOME='/usr/lib/jvm/temurin-17-jdk-amd64/'
|
||||
}
|
||||
|
||||
options {
|
||||
buildDiscarder(logRotator(numToKeepStr: '48', artifactNumToKeepStr: '96'))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -13,11 +13,11 @@ buildscript {
|
|||
}
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.22"
|
||||
kotlin("plugin.serialization") version "1.9.22"
|
||||
kotlin("jvm") version "1.9.24"
|
||||
kotlin("plugin.serialization") version "1.9.24"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
||||
id("architectury-plugin") version "[3.4.124, 3.5["
|
||||
id("dev.architectury.loom") version "1.4-SNAPSHOT" apply false
|
||||
id("dev.architectury.loom") version "1.5-SNAPSHOT" apply false
|
||||
id("com.github.ben-manes.versions") version "0.51.0"
|
||||
id("net.kyori.indra.git") version "3.1.3"
|
||||
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.2.5"
|
||||
|
@ -25,7 +25,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "fr.username404"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
val groupAndName = "${rootProject.group}.${rootProject.name.toLowerCase()}"
|
||||
|
||||
val javaVer: String = "17"
|
||||
|
@ -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-${rootProject.architectury.minecraft}:2022.02.13")
|
||||
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.20.1:2023.06.26")
|
||||
}
|
||||
silentMojangMappingsLicense()
|
||||
val refmap = "snowygui-${project.name}-refmap.json"
|
||||
|
@ -75,8 +75,8 @@ subprojects {
|
|||
implementation("$kotlinX:kotlinx-serialization-core:$serializationVer")
|
||||
implementation("$kotlinX:kotlinx-serialization-json:$serializationVer")
|
||||
listOf(
|
||||
"com.typesafe:config:1.4.2",
|
||||
"io.github.config4k:config4k:0.4.2",
|
||||
"com.typesafe:config:1.4.3",
|
||||
"io.github.config4k:config4k:0.6.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,8 +86,8 @@ subprojects {
|
|||
extensions.configure<ModrinthExtension>("modrinth") {
|
||||
projectId.set("OuGyGg6A")
|
||||
syncBodyFrom.set("$rootDir/README.md")
|
||||
gameVersions.add(mcBase)
|
||||
if (project.name == "forge") dependencies.add(com.modrinth.minotaur.dependencies.VersionDependency("Bxm9xbNJ", DependencyType.REQUIRED)) // Kotlinforforge dependency
|
||||
gameVersions.add(minecraftVersion)
|
||||
if (project.name == "forge") dependencies.add(com.modrinth.minotaur.dependencies.ModDependency("ordsPcFz", DependencyType.REQUIRED)) // Kotlinforforge dependency
|
||||
versionNumber.set(rootProject.version.toString() + "-${project.name}")
|
||||
versionType.set(VersionType.ALPHA.name)
|
||||
detectLoaders.set(false)
|
||||
|
@ -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,12 +229,14 @@ 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"),
|
||||
"kotlinforforge" to rootProject.property("kotlinforforge"),
|
||||
"clothconfig" to rootProject.property("clothconfig_version")
|
||||
"clothconfig" to rootProject.property("clothconfig_version"),
|
||||
"fabric_loader" to rootProject.property("fabric_loader_version"),
|
||||
"forge_version" to rootProject.property("forge_version").toString().dropLast(2)
|
||||
)
|
||||
inputs.properties(modProperties)
|
||||
filesNotMatching(listOf("*.png")) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
architectury { common(); 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);
|
||||
}
|
|
@ -14,17 +14,29 @@ object ClickGui: SnowyScreen() {
|
|||
private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach {
|
||||
if (it.y > y + height) it.args()
|
||||
} }
|
||||
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseClicked(d, e, i) }; return false }
|
||||
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseReleased(d, e, i) }; return false }
|
||||
|
||||
private var draggingBox: String? = null
|
||||
private inline fun currentBoxContext(args: ClickBox.() -> Unit): Unit? = draggingBox?.run { boxContext { if (name.string == draggingBox) args() } }
|
||||
private var offsetX: Double = 0.0;
|
||||
private var offsetY: Double = 0.0;
|
||||
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean {
|
||||
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||
clickBoxes.find { it.isWithinBounds(d, e) }?.let { draggingBox = it.name.string }
|
||||
currentBoxContext {
|
||||
offsetX = d - (x + width)
|
||||
offsetY = e - (y + height)
|
||||
}
|
||||
}
|
||||
buttonsContext { this.mouseClicked(d, e, i) }; return super.mouseClicked(d, e, i);
|
||||
}
|
||||
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { draggingBox = null; buttonsContext { this.mouseReleased(d, e, i) }; return false }
|
||||
override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false }
|
||||
|
||||
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
||||
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||
components.forEach {
|
||||
if (it.isWithinBounds(d.minus(f), e.minus(g)) && !isDragging) {
|
||||
isDragging = true
|
||||
it.x = d.minus(f) + (d - (it.x + it.width))
|
||||
it.y = e.minus(g) + (e - (it.y + it.height))
|
||||
} else isDragging = false
|
||||
currentBoxContext {
|
||||
x = (d + offsetX).coerceIn(0.0..this@ClickGui.width - width.toDouble())
|
||||
y = (e + offsetY).coerceIn(0.0..this@ClickGui.height - height.toDouble())
|
||||
}
|
||||
}
|
||||
return super.mouseDragged(d, e, i, f, g)
|
||||
|
|
|
@ -2,9 +2,11 @@ package fr.username404.snowygui
|
|||
|
||||
import fr.username404.snowygui.config.Configuration
|
||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||
import fr.username404.snowygui.gui.feature.ButtonImpl.Companion.initButtons
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo
|
||||
import fr.username404.snowygui.misc.AddKeyMaps
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.Component.translatable
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
import java.lang.reflect.Modifier
|
||||
|
@ -15,8 +17,7 @@ abstract class Snowy {
|
|||
private val displayInitMessage: Boolean by Configuration
|
||||
abstract val annotatedButtons: Set<Class<out ButtonImpl>>
|
||||
companion object {
|
||||
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||
object MissingComponent: TranslatableComponent(null) { override fun getString(): String = "MISSING_COMPONENT" }
|
||||
val MissingComponent: Component = translatable("MISSING_COMPONENT")
|
||||
@Suppress("JVM_STATIC_ON_CONST_OR_JVM_FIELD") // See KT-39868
|
||||
@JvmStatic
|
||||
protected const val FeaturePackage: String = "fr.username404.snowygui.gui.feature"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package fr.username404.snowygui.config
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.ClickGui
|
||||
import fr.username404.snowygui.utils.FontUtil
|
||||
import fr.username404.snowygui.gui.elements.ClickBox
|
||||
import fr.username404.snowygui.gui.elements.ClickBox.Companion.buttonsMax
|
||||
import fr.username404.snowygui.gui.elements.ClickBox.Companion.sortAlphabetically
|
||||
|
@ -11,25 +9,27 @@ import fr.username404.snowygui.gui.feature.Colors
|
|||
import fr.username404.snowygui.gui.feature.Macro
|
||||
import fr.username404.snowygui.gui.feature.Keystrokes
|
||||
import fr.username404.snowygui.gui.feature.Zoom
|
||||
import fr.username404.snowygui.utils.FontUtil
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.network.chat.Component.translatable
|
||||
import java.util.Optional
|
||||
|
||||
private const val confPrefix: String = "screen.snowy.config"
|
||||
private val translationComponent = TranslatableComponent(confPrefix)
|
||||
private val translationComponent = translatable(confPrefix)
|
||||
|
||||
var configScreenParent: Screen? = null
|
||||
|
||||
private fun supplyComponent(string: String?): Optional<Component> = string?.run {
|
||||
Optional.of(TranslatableComponent(string))
|
||||
Optional.of(translatable(string))
|
||||
} ?: Optional.empty()
|
||||
|
||||
val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
||||
override fun isPauseScreen(): Boolean = false
|
||||
override fun render(poseStack: PoseStack, i: Int, j: Int, f: Float) {
|
||||
super.renderBackground(poseStack)
|
||||
FontUtil.drawScaled(poseStack,
|
||||
override fun render(guiGraphics: GuiGraphics, i: Int, j: Int, f: Float) {
|
||||
super.renderBackground(guiGraphics)
|
||||
FontUtil.drawScaled(guiGraphics,
|
||||
text = "An appropriate version of the Cloth Config mod is required for the configuration of snowygui.", 16.0, 16.0,
|
||||
color = Colors.WHITE, scaleFactor = 0.85F
|
||||
)
|
||||
|
@ -47,20 +47,20 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
|||
.setShouldListSmoothScroll(true)
|
||||
.setTitle(translationComponent).apply {
|
||||
with(entryBuilder()) {
|
||||
getOrCreateCategory(TranslatableComponent("$confPrefix.general")).addEntry(startSubCategory(TranslatableComponent("$confPrefix.behavior")).apply {
|
||||
getOrCreateCategory(translatable("$confPrefix.general")).addEntry(startSubCategory(translatable("$confPrefix.behavior")).apply {
|
||||
addAll(
|
||||
setOf(
|
||||
startBooleanToggle(TranslatableComponent("$confPrefix.behavior.sortalphabetically"), sortAlphabetically)
|
||||
startBooleanToggle(translatable("$confPrefix.behavior.sortalphabetically"), sortAlphabetically)
|
||||
.setDefaultValue(true).requireRestart()
|
||||
.setSaveConsumer { sortAlphabetically = it }.build(),
|
||||
startDoubleField(TranslatableComponent("$confPrefix.behavior.zoom.factor"), Zoom.zoomFactor).setSaveConsumer {
|
||||
startDoubleField(translatable("$confPrefix.behavior.zoom.factor"), Zoom.zoomFactor).setSaveConsumer {
|
||||
Zoom.zoomFactor = it
|
||||
}.setMin(1.1).build(),
|
||||
startBooleanToggle(TranslatableComponent("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer {
|
||||
startBooleanToggle(translatable("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer {
|
||||
Zoom.smoothCameraOnZoom = it
|
||||
Zoom.execAction()
|
||||
}.build(),
|
||||
startEnumSelector(TranslatableComponent("$confPrefix.behavior.keystrokes.position"), Keystrokes.Position::class.java, Keystrokes.Position.values().find {
|
||||
startEnumSelector(translatable("$confPrefix.behavior.keystrokes.position"), Keystrokes.Position::class.java, Keystrokes.Position.values().find {
|
||||
it.value == Keystrokes.currentPosition
|
||||
}).setSaveConsumer {
|
||||
Keystrokes.currentPosition = it.value
|
||||
|
@ -68,7 +68,7 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
|||
)
|
||||
)
|
||||
}.build())
|
||||
.addEntry(startSubCategory(TranslatableComponent("$confPrefix.colors")).also { builder ->
|
||||
.addEntry(startSubCategory(translatable("$confPrefix.colors")).also { builder ->
|
||||
builder.addAll(
|
||||
ClickGui.clickBoxes.map { box ->
|
||||
startColorField(box.name, box.color).setSaveConsumer {
|
||||
|
@ -77,7 +77,7 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
|||
}
|
||||
)
|
||||
}.build()).addEntry(startStrList(
|
||||
TranslatableComponent(Category.MACROS.translationKey),
|
||||
Category.MACROS.box.name,
|
||||
macrosButtons.getTitleCommand()
|
||||
).setInsertInFront(false).setDefaultValue(Configuration.foundMacros.getTitleCommand()).setErrorSupplier { list ->
|
||||
supplyComponent(if (list.size > buttonsMax) "$confPrefix.general.macros.toomuchbuttons" else null)
|
||||
|
@ -93,7 +93,7 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
|||
}
|
||||
)
|
||||
}
|
||||
}.setTooltip(TranslatableComponent("$confPrefix.general.macros.tooltip")).setSaveConsumer { it.forEach { string ->
|
||||
}.setTooltip(translatable("$confPrefix.general.macros.tooltip")).setSaveConsumer { it.forEach { string ->
|
||||
with(string.split(":")) {
|
||||
if (size == 2) Macro(title = component1().trimStart(), command = component2().trim()).let { newMacro ->
|
||||
macrosButtons.removeIf { existingMacro ->
|
||||
|
|
|
@ -29,6 +29,8 @@ import kotlinx.serialization.ExperimentalSerializationApi
|
|||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.network.chat.contents.TranslatableContents
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.isSuperclassOf
|
||||
|
@ -46,9 +48,9 @@ object Configuration {
|
|||
}
|
||||
},
|
||||
"box_colors" to mapOf<String, Int>(*ClickGui.clickBoxes.filter { box ->
|
||||
(box.name.key != MissingComponent.key) && Category.fromBox(box)?.categoryColor != box.color
|
||||
((box.name.contents as TranslatableContents).key != (MissingComponent.contents as TranslatableContents).key) && Category.fromBox(box)?.categoryColor != box.color
|
||||
}.map {
|
||||
it.name.key to it.color
|
||||
(it.name as TranslatableContents).key to it.color
|
||||
}.toTypedArray()),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -5,10 +5,11 @@ import fr.username404.snowygui.Snowy
|
|||
import fr.username404.snowygui.gui.feature.Colors
|
||||
import fr.username404.snowygui.utils.RenderingUtil
|
||||
import fr.username404.snowygui.utils.RenderingUtil.colorEnd
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
|
||||
fun interface Renderable {
|
||||
fun render(poseStack: PoseStack?)
|
||||
fun render(guiGraphics: GuiGraphics?)
|
||||
}
|
||||
|
||||
abstract class Element(
|
||||
|
@ -19,17 +20,22 @@ 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 {
|
||||
return object: Element(x, y, width, height) {
|
||||
override fun render(poseStack: PoseStack?) = r.render(poseStack)
|
||||
override fun render(guiGraphics: GuiGraphics?) = r.render(guiGraphics)
|
||||
}
|
||||
}
|
||||
}
|
||||
open fun display(stack: PoseStack? = null) {
|
||||
open fun display(guiGraphics: GuiGraphics? = null) {
|
||||
if (!hidden && !caughtError) try {
|
||||
render(stack)
|
||||
render(guiGraphics)
|
||||
} catch (t: Throwable) {
|
||||
with(Snowy.logs) {
|
||||
error("An element from snowy threw an error: \n\t$t")
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package fr.username404.snowygui.gui
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.network.chat.Component.translatable
|
||||
|
||||
abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", private val willPauseScreen: Boolean = false): Screen(TranslatableComponent(translatableString)) {
|
||||
abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", private val willPauseScreen: Boolean = false): Screen(translatable(translatableString)) {
|
||||
abstract val components: MutableCollection<Element>
|
||||
override fun render(poseStack: PoseStack?, i: Int, j: Int, f: Float) {
|
||||
if (poseStack != null) {
|
||||
components.forEach {
|
||||
it.display(poseStack)
|
||||
}
|
||||
override fun render(guiGraphics: GuiGraphics, i: Int, j: Int, f: Float) {
|
||||
components.forEach {
|
||||
it.display(guiGraphics)
|
||||
}
|
||||
}
|
||||
override fun isPauseScreen(): Boolean = willPauseScreen
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package fr.username404.snowygui.gui.elements
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||
import fr.username404.snowygui.config.Configuration
|
||||
import com.mojang.blaze3d.vertex.VertexFormat
|
||||
|
@ -15,11 +14,10 @@ import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
|||
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.tessellator
|
||||
import io.github.config4k.extract
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.network.chat.Component
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.TreeSet
|
||||
import kotlin.collections.LinkedHashSet
|
||||
|
@ -27,17 +25,17 @@ import kotlin.collections.LinkedHashSet
|
|||
@ApiStatus.Internal
|
||||
class ClickBox(
|
||||
x: Double, y: Double,
|
||||
override var color: Int = Colors.BLUE.hexValue,
|
||||
val name: TranslatableComponent = MissingComponent
|
||||
val name: Component = MissingComponent,
|
||||
override var color: Int = savedColors?.get(name.string) ?: Colors.BLUE.hexValue,
|
||||
): ColoredElement(x, y, 80, 10, color, 0.5F) {
|
||||
fun isCategory(c: Category): Boolean = (name.key == c.translationKey)
|
||||
fun isCategory(c: Category): Boolean = (name.string == c.box.name.string)
|
||||
val buttons: MutableSet<ButtonImpl> =
|
||||
if (sortAlphabetically)
|
||||
TreeSet(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title })
|
||||
else LinkedHashSet()
|
||||
override fun display(stack: PoseStack?) {
|
||||
override fun display(guiGraphics: GuiGraphics?) {
|
||||
hidden = buttons.isEmpty() || hidden
|
||||
super.display(stack)
|
||||
super.display(guiGraphics)
|
||||
}
|
||||
|
||||
@JvmField
|
||||
|
@ -47,7 +45,7 @@ class ClickBox(
|
|||
opacity = 0.75F
|
||||
) {
|
||||
override val color: Int get() = this@ClickBox.color
|
||||
override fun render(poseStack: PoseStack?) {
|
||||
override fun render(guiGraphics: GuiGraphics?) {
|
||||
prepareDraw()
|
||||
colorShader(); defaultRectFunc()
|
||||
endDraw()
|
||||
|
@ -79,55 +77,52 @@ class ClickBox(
|
|||
const val clickboxHeightOffset: Int = 80
|
||||
private const val inclination: Double = 2.5
|
||||
}
|
||||
override fun render(poseStack: PoseStack?) {
|
||||
runBlocking {
|
||||
prepareDraw()
|
||||
with(buffer) {
|
||||
begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR)
|
||||
// Render the header:
|
||||
vertex(x, y + height, 0.0).colorEnd()
|
||||
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||
vertex(x + width, y, 0.0).colorEnd()
|
||||
vertex(x + inclination, y, 0.0).colorEnd()
|
||||
override fun render(guiGraphics: GuiGraphics?) {
|
||||
val currentHeight = y + (height + clickboxHeightOffset)
|
||||
prepareDraw()
|
||||
with(buffer) {
|
||||
begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR)
|
||||
// Render the header:
|
||||
vertex(x, y + height, 0.0).colorEnd()
|
||||
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||
vertex(x + width, y, 0.0).colorEnd()
|
||||
vertex(x + inclination, y, 0.0).colorEnd()
|
||||
|
||||
// Render the box:
|
||||
val currentHeight = y + (height + clickboxHeightOffset)
|
||||
vertex(x, currentHeight, 0.0).colorEnd()
|
||||
vertex(x + width + inclination, currentHeight, 0.0).colorEnd()
|
||||
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||
tessellator.end()
|
||||
// Render the box:
|
||||
vertex(x, currentHeight, 0.0).colorEnd()
|
||||
vertex(x + width + inclination, currentHeight, 0.0).colorEnd()
|
||||
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||
tessellator.end()
|
||||
|
||||
colorShader()
|
||||
begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR)
|
||||
vertex(x + inclination, y + height, 0.0).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
vertex(x + width, y + height, 0.0).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
tessellator.end()
|
||||
}
|
||||
endDraw()
|
||||
colorShader()
|
||||
begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR)
|
||||
vertex(x + inclination, y + height, 0.0).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
vertex(x + width, y + height, 0.0).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
tessellator.end()
|
||||
}
|
||||
endDraw()
|
||||
|
||||
val renderButtons = if (buttons.isNotEmpty()) launch(start = CoroutineStart.UNDISPATCHED) {
|
||||
buttonsProgressBar.apply {
|
||||
x = this@ClickBox.x + this@ClickBox.width - 3
|
||||
y = this@ClickBox.y + this@ClickBox.height + 3
|
||||
}.display(poseStack)
|
||||
buttons.forEachIndexed { num, button ->
|
||||
val fullHeight = (y + height.toDouble())..(y + height + clickboxHeightOffset)
|
||||
button.also {
|
||||
it.x = x + 3
|
||||
it.y = y + 3 + height + (((num + 1) - barStage) * 9)
|
||||
it.hidden = if ((num + 1) <= 8) ((it.y) !in fullHeight) else ((it.y + it.height) !in fullHeight)
|
||||
}.display(poseStack)
|
||||
}
|
||||
} else null
|
||||
if (poseStack != null) {
|
||||
Minecraft.getInstance().font.draw(poseStack, name.string, x.toFloat() + 5, y.toFloat() + 1.5F, Colors.TRANSPARENT.hexValue)
|
||||
renderButtons?.join()
|
||||
if (buttons.isNotEmpty()) {
|
||||
buttonsProgressBar.apply {
|
||||
x = this@ClickBox.x + this@ClickBox.width - 3
|
||||
y = this@ClickBox.y + this@ClickBox.height + 3
|
||||
}.display(guiGraphics)
|
||||
buttons.forEachIndexed { num, button ->
|
||||
val fullHeight = (y + height.toDouble())..(y + height + clickboxHeightOffset)
|
||||
button.also {
|
||||
it.x = x + 3
|
||||
it.y = y + 3 + height + (((num + 1) - barStage) * 9)
|
||||
it.hidden = if ((num + 1) <= 8) ((it.y) !in fullHeight) else ((it.y + it.height) !in fullHeight)
|
||||
}.display(guiGraphics)
|
||||
}
|
||||
}
|
||||
}
|
||||
init {
|
||||
savedColors?.get(name.key)?.let {
|
||||
this.color = it
|
||||
guiGraphics?.run {
|
||||
with(Minecraft.getInstance().font) {
|
||||
drawInBatch(name.string,
|
||||
(x + 5).toFloat(), (y + 2).toFloat(), Colors.TRANSPARENT.hexValue, false,
|
||||
pose().last().pose(), bufferSource(), Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package fr.username404.snowygui.gui.feature
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.ClickGui
|
||||
import fr.username404.snowygui.Snowy
|
||||
import fr.username404.snowygui.config.Configuration
|
||||
import fr.username404.snowygui.gui.ColoredElement
|
||||
import fr.username404.snowygui.utils.FontUtil
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
||||
import fr.username404.snowygui.utils.FontUtil
|
||||
import fr.username404.snowygui.utils.RenderingUtil.colorShader
|
||||
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.colorShader
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
|
||||
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||
|
@ -90,12 +90,12 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||
lightDown()
|
||||
}; return false
|
||||
}
|
||||
final override fun render(poseStack: PoseStack?) {
|
||||
final override fun render(guiGraphics: GuiGraphics?) {
|
||||
prepareDraw()
|
||||
colorShader(); defaultRectFunc()
|
||||
endDraw()
|
||||
if (poseStack != null) {
|
||||
FontUtil.drawScaled(poseStack, title, x + 1, y + 1, 0.75F)
|
||||
if (guiGraphics != null) {
|
||||
FontUtil.drawScaled(guiGraphics, title, x + 1, y + 1, 0.75F)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package fr.username404.snowygui.gui.feature
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.EventSnowy
|
||||
import fr.username404.snowygui.argsLambda
|
||||
import fr.username404.snowygui.gui.Renderable
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
sealed class ButtonImplWithHud: ButtonImpl() {
|
||||
protected abstract val hudRenderLambda: Renderable
|
||||
private val generatedLambda: argsLambda = { hudRenderLambda.render(it.first() as PoseStack?) }
|
||||
private val generatedLambda: argsLambda = { hudRenderLambda.render(it.first() as GuiGraphics?) }
|
||||
final override fun execAction() {
|
||||
EventSnowy["HudRender"].run {
|
||||
if (toggled) add(generatedLambda)
|
||||
|
|
|
@ -2,7 +2,8 @@ package fr.username404.snowygui.gui.feature
|
|||
|
||||
import fr.username404.snowygui.ClickGui
|
||||
import fr.username404.snowygui.gui.elements.ClickBox
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.network.chat.Component.translatable
|
||||
import net.minecraft.network.chat.contents.TranslatableContents
|
||||
|
||||
/**
|
||||
* Should be used on classes/objects extending [ButtonImpl]
|
||||
|
@ -22,7 +23,7 @@ annotation class ButtonInfo(
|
|||
TOGGLE,
|
||||
CLICK
|
||||
}
|
||||
enum class Category(val translationKey: String, val categoryColor: Int, val shouldHide: Boolean = false) {
|
||||
enum class Category(translationKey: String, val categoryColor: Int, val shouldHide: Boolean = false) {
|
||||
MISC("snowy.clickbox.misc", Colors.BLUE),
|
||||
HUD("snowy.clickbox.hud", Colors.DARK_PURPLE),
|
||||
MACROS("snowy.clickbox.macros", Colors.GREEN);
|
||||
|
@ -35,14 +36,14 @@ annotation class ButtonInfo(
|
|||
x = 4.0 + (ordinal - ClickGui.clickBoxes.count { category ->
|
||||
category.hidden
|
||||
}) * 86, y = 4.0,
|
||||
name = TranslatableComponent(translationKey),
|
||||
name = translatable(translationKey),
|
||||
color = categoryColor
|
||||
); private set
|
||||
private fun addBox() = ClickGui.components.add(box.apply { if (shouldHide) hidden = true })
|
||||
constructor(
|
||||
translationKey: String, categoryColor: Colors, condition: Boolean = false
|
||||
): this(translationKey, categoryColor.hexValue, condition)
|
||||
constructor(categoryBox: ClickBox): this(translationKey = categoryBox.name.key, categoryColor = categoryBox.color) {
|
||||
constructor(categoryBox: ClickBox): this(translationKey = (categoryBox.name.contents as TranslatableContents).key, categoryColor = categoryBox.color) {
|
||||
with(ClickGui.components) {
|
||||
remove(this@Category.box)
|
||||
this@Category.box = categoryBox
|
||||
|
|
|
@ -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,10 +9,12 @@ object GammaBoost: ButtonImpl() {
|
|||
private var oldGamma = 0.0
|
||||
override fun execAction() {
|
||||
with(Minecraft.getInstance().options) {
|
||||
gamma = if (toggled) {
|
||||
val gamma = gamma().get()
|
||||
@Suppress("KotlinConstantConditions")
|
||||
(gamma() as OptionValueAccessor).setValue(if (toggled) {
|
||||
if (gamma < boost) oldGamma = gamma
|
||||
boost
|
||||
} else oldGamma
|
||||
} else oldGamma)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package fr.username404.snowygui.gui.feature
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.config.Configuration
|
||||
import fr.username404.snowygui.gui.ColoredElement
|
||||
import fr.username404.snowygui.gui.Renderable
|
||||
import fr.username404.snowygui.utils.FontUtil
|
||||
import fr.username404.snowygui.utils.RenderingUtil
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
@ButtonInfo(Category.HUD)
|
||||
object Keystrokes: ButtonImplWithHud() {
|
||||
|
@ -41,14 +41,14 @@ object Keystrokes: ButtonImplWithHud() {
|
|||
return dynamicOpacity[i]
|
||||
}
|
||||
|
||||
private fun drawKey(x: Double, y: Double, key: Int, poseStack: PoseStack? = null) {
|
||||
private fun drawKey(x: Double, y: Double, key: Int, guiGraphics: GuiGraphics?) {
|
||||
RenderingUtil.prepareDraw()
|
||||
RenderingUtil.drawRectangle(
|
||||
x, y, height / 2, height / 2,
|
||||
color = color, opacity = getDynamicOpacity(key).toFloat()
|
||||
)
|
||||
RenderingUtil.endDraw()
|
||||
poseStack?.let {
|
||||
guiGraphics?.let {
|
||||
FontUtil.drawScaled(
|
||||
it, keysArray.first[key].translatedKeyMessage.string.uppercase(),
|
||||
x + height.toDouble() / 5.5, y + height.toDouble() / 6.5,
|
||||
|
@ -57,11 +57,11 @@ object Keystrokes: ButtonImplWithHud() {
|
|||
}
|
||||
}
|
||||
private fun getNewPos(i: Int) = x + (i * (2 + (height / 2)))
|
||||
override fun render(poseStack: PoseStack?) = with(RenderingUtil) {
|
||||
override fun render(guiGraphics: GuiGraphics?) = with(RenderingUtil) {
|
||||
for (i in 0 until 3) {
|
||||
drawKey(getNewPos(i), y, i, poseStack)
|
||||
drawKey(getNewPos(i), y, i, guiGraphics)
|
||||
}
|
||||
drawKey(getNewPos(1), y - (height / 2) - 2, 3, poseStack)
|
||||
drawKey(getNewPos(1), y - (height / 2) - 2, 3, guiGraphics)
|
||||
}
|
||||
}
|
||||
override val hudRenderLambda = Renderable {
|
||||
|
|
|
@ -15,12 +15,12 @@ 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)
|
||||
} else it
|
||||
connection.run {
|
||||
command.let {
|
||||
if (it.startsWith("say") && !hasPermissions(2)) {
|
||||
sendChat(it.drop(4))
|
||||
} else sendCommand(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
package fr.username404.snowygui.utils
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.Minecraft
|
||||
import fr.username404.snowygui.gui.feature.Colors
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
object FontUtil {
|
||||
fun drawScaled(stack: PoseStack, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
|
||||
fun drawScaled(guiGraphics: GuiGraphics, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
|
||||
val stack = guiGraphics.pose()
|
||||
stack.scale(scaleFactor, scaleFactor, scaleFactor)
|
||||
Minecraft.getInstance().font.draw(stack, text, (x / scaleFactor).toFloat(), (y / scaleFactor).toFloat(), color.hexValue)
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, text, (x / scaleFactor).toInt(), (y / scaleFactor).toInt(), color.hexValue, false)
|
||||
val factorToOriginal = 1F / scaleFactor
|
||||
stack.scale(factorToOriginal, factorToOriginal, factorToOriginal)
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -8,10 +8,12 @@ import net.fabricmc.api.ClientModInitializer
|
|||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.EVENT
|
||||
import net.fabricmc.loader.api.FabricLoader
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
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() {
|
||||
|
@ -19,12 +21,12 @@ class FabricInit: Snowy(), ClientModInitializer {
|
|||
EVENT.register(
|
||||
object: HudRenderCallback, EventSnowy {
|
||||
override val type: String = "HudRender"
|
||||
override fun onHudRender(matrixStack: PoseStack?, tickDelta: Float) = fire(matrixStack)
|
||||
override fun onHudRender(guiGraphics: GuiGraphics?, tickDelta: Float) = fire(guiGraphics)
|
||||
}
|
||||
)
|
||||
}
|
||||
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) {
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
"snowygui-fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.11.0",
|
||||
"fabricloader": ">=${fabric_loader}",
|
||||
"fabric-language-kotlin": ">=${fabric_kotlin}",
|
||||
"fabric-resource-loader-v0": "*",
|
||||
"fabric-rendering-v1": "*",
|
||||
"minecraft": ">=${minecraft_version}"
|
||||
"minecraft": ">=1.19-alpha.22.16.b"
|
||||
},
|
||||
"recommends": {
|
||||
"cloth-config2": ">=${clothconfig}"
|
||||
|
|
|
@ -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.guiGraphics)
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ side = "CLIENT"
|
|||
[[dependencies.snowygui]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[37,)"
|
||||
versionRange = "[${forge_version},)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
|
|
|
@ -7,16 +7,16 @@ org.gradle.parallel=true
|
|||
org.gradle.unsafe.configuration-cache=on
|
||||
org.gradle.vfs.watch=true
|
||||
|
||||
minecraft=1.18.1
|
||||
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.14+713c266865
|
||||
fabric_rendering_api_version=1.10.6+713c266865
|
||||
fabric_api_base_version=0.3.0+a02b4463d5
|
||||
clothconfig_version=6.2.57
|
||||
modmenu_version=3.0.1
|
||||
minecraft=1.20
|
||||
forge_version=46.0
|
||||
kotlinforforge=4.3.0
|
||||
kotlinVer=1.8.22
|
||||
kotlin_coroutines_version=1.7.1
|
||||
serializationVer=1.5.1
|
||||
fabric_loader_version=0.14.19
|
||||
fabric_language_kotlin=1.9.5+kotlin.1.8.22
|
||||
fabric_resource_loader_version=0.11.7+f7923f6d27
|
||||
fabric_rendering_api_version=3.0.6+b3afc78b27
|
||||
fabric_api_base_version=0.4.29+b04edc7a27
|
||||
clothconfig_version=11.0.99
|
||||
modmenu_version=7.0.0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-rc-1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
Loading…
Reference in New Issue