Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0afa43168d | |||
| c0f008c187 | |||
| fcba61b050 | |||
| c8ac0629c3 | |||
| bc14627b97 | |||
| bb90bad1d1 |
@ -1,24 +1,23 @@
|
|||||||
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.dependencies.DependencyType
|
|
||||||
import masecla.modrinth4j.model.version.ProjectVersion.VersionType
|
import masecla.modrinth4j.model.version.ProjectVersion.VersionType
|
||||||
|
import com.modrinth.minotaur.dependencies.DependencyType
|
||||||
import net.fabricmc.loom.LoomGradleExtension
|
import net.fabricmc.loom.LoomGradleExtension
|
||||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("com.guardsquare:proguard-gradle:[7.5, 7.7[") {
|
classpath("com.guardsquare:proguard-gradle:[7.4, 7.5[") {
|
||||||
exclude("com.android.tools.build")
|
exclude("com.android.tools.build")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.0.0"
|
kotlin("jvm") version "1.9.24"
|
||||||
kotlin("plugin.serialization") version "2.0.0"
|
kotlin("plugin.serialization") version "1.9.24"
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
||||||
id("architectury-plugin") version "[3.4.160, 3.5["
|
id("architectury-plugin") version "[3.4.124, 3.5["
|
||||||
id("dev.architectury.loom") version "1.10-SNAPSHOT" apply false
|
id("dev.architectury.loom") version "1.5-SNAPSHOT" apply false
|
||||||
id("com.github.ben-manes.versions") version "0.51.0"
|
id("com.github.ben-manes.versions") version "0.51.0"
|
||||||
id("net.kyori.indra.git") version "3.1.3"
|
id("net.kyori.indra.git") version "3.1.3"
|
||||||
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.2.5"
|
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.2.5"
|
||||||
@ -26,10 +25,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "fr.username404"
|
group = "fr.username404"
|
||||||
version = "0.3.6"
|
version = "0.3.7"
|
||||||
val groupAndName = "${rootProject.group}.${rootProject.name.lowercase()}"
|
val groupAndName = "${rootProject.group}.${rootProject.name.toLowerCase()}"
|
||||||
|
|
||||||
val javaVer: String = "21"
|
val javaVer: String = "17"
|
||||||
val sourceJavaVer: String = javaVer
|
val sourceJavaVer: String = javaVer
|
||||||
val kotlinVer: String by rootProject
|
val kotlinVer: String by rootProject
|
||||||
val kotlinSplitVersion = kotlinVer.split('.')
|
val kotlinSplitVersion = kotlinVer.split('.')
|
||||||
@ -38,7 +37,6 @@ val minecraftVersion: String = (rootProject.property("minecraft") as String).als
|
|||||||
architectury { minecraft = it }
|
architectury { minecraft = it }
|
||||||
}
|
}
|
||||||
val kotlinX: String = "org.jetbrains.kotlinx"
|
val kotlinX: String = "org.jetbrains.kotlinx"
|
||||||
val devBuild = rootProject.hasProperty("devBuild") && rootProject.property("devBuild").toString().toBoolean()
|
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
group = rootProject.group.toString()
|
group = rootProject.group.toString()
|
||||||
@ -52,17 +50,18 @@ subprojects {
|
|||||||
apply(plugin = "dev.architectury.loom")
|
apply(plugin = "dev.architectury.loom")
|
||||||
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
|
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
|
||||||
extensions.configure<LoomGradleExtension>("loom") {
|
extensions.configure<LoomGradleExtension>("loom") {
|
||||||
if (this@subprojects.project.name != "common") {
|
|
||||||
accessWidenerPath.set(project(":common").extensions.getByType<LoomGradleExtensionAPI>().accessWidenerPath)
|
|
||||||
}
|
|
||||||
mappingsDep = layered {
|
mappingsDep = layered {
|
||||||
silentMojangMappingsLicense()
|
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.20.1:2023.06.26")
|
||||||
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21.5:2025.04.19")
|
|
||||||
}
|
}
|
||||||
|
silentMojangMappingsLicense()
|
||||||
val refmap = "snowygui-${project.name}-refmap.json"
|
val refmap = "snowygui-${project.name}-refmap.json"
|
||||||
mixin {
|
mixin {
|
||||||
useLegacyMixinAp = true
|
defaultRefmapName.set(refmap)
|
||||||
defaultRefmapName = refmap
|
if (isForge) {
|
||||||
|
forge {
|
||||||
|
mixinConfigs("snowygui-common.mixins.json", "snowygui-forge.mixins.json")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "com.github.johnrengelman.shadow")
|
||||||
@ -168,16 +167,12 @@ subprojects {
|
|||||||
mergeinterfacesaggressively()
|
mergeinterfacesaggressively()
|
||||||
}
|
}
|
||||||
withType(net.fabricmc.loom.task.RemapJarTask::class) {
|
withType(net.fabricmc.loom.task.RemapJarTask::class) {
|
||||||
if (!devBuild) {
|
dependsOn(shrinkJar)
|
||||||
dependsOn(shrinkJar)
|
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
||||||
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
|
||||||
inputFile.set(shrinkedJar)
|
|
||||||
} else inputFile.set(shadowJar.archiveFile)
|
|
||||||
archiveBaseName.set(shadowJar.archiveBaseName)
|
archiveBaseName.set(shadowJar.archiveBaseName)
|
||||||
archiveVersion.set("[${rootProject.version}+$minecraftVersion]")
|
archiveVersion.set("[${rootProject.version}+$minecraftVersion]")
|
||||||
archiveClassifier.set(this@subprojects.name)
|
archiveClassifier.set(this@subprojects.name)
|
||||||
if (this@subprojects.name.contains("forge"))
|
inputFile.set(shrinkedJar)
|
||||||
atAccessWideners.set(listOf("${rootProject.name.lowercase()}.accessWidener"))
|
|
||||||
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)
|
||||||
@ -213,9 +208,8 @@ allprojects {
|
|||||||
"-opt-in=kotlin.RequiresOptIn", "-Xextended-compiler-checks", "-Xassertions=jvm", "-progressive"
|
"-opt-in=kotlin.RequiresOptIn", "-Xextended-compiler-checks", "-Xassertions=jvm", "-progressive"
|
||||||
)
|
)
|
||||||
jvmTarget = javaVer
|
jvmTarget = javaVer
|
||||||
// Uncomment when updating to architectury-loom 1.9
|
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]}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
withType(JavaCompile::class) {
|
withType(JavaCompile::class) {
|
||||||
@ -242,10 +236,10 @@ allprojects {
|
|||||||
"kotlinforforge" to rootProject.property("kotlinforforge"),
|
"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"),
|
"fabric_loader" to rootProject.property("fabric_loader_version"),
|
||||||
"forge_version" to rootProject.property("forge_version")
|
"forge_version" to rootProject.property("forge_version").toString().dropLast(2)
|
||||||
)
|
)
|
||||||
inputs.properties(modProperties)
|
inputs.properties(modProperties)
|
||||||
filesNotMatching(listOf("*.png", "*.accessWidener")) {
|
filesNotMatching(listOf("*.png")) {
|
||||||
expand(modProperties)
|
expand(modProperties)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
architectury { common("fabric", "neoforge"); injectInjectables = true }
|
architectury { common("fabric", "forge"); injectInjectables = true }
|
||||||
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")}") {
|
||||||
@ -6,8 +6,4 @@ dependencies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
|
||||||
accessWidenerPath = file("src/main/resources/${rootProject.name.lowercase()}.accessWidener")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.getByName("shrinkJar").enabled = false
|
tasks.getByName("shrinkJar").enabled = false
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
@ -4,17 +4,16 @@ import fr.username404.snowygui.ClickGui;
|
|||||||
import fr.username404.snowygui.gui.feature.ButtonImpl;
|
import fr.username404.snowygui.gui.feature.ButtonImpl;
|
||||||
import net.minecraft.client.gui.screens.TitleScreen;
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(TitleScreen.class)
|
@Mixin(TitleScreen.class)
|
||||||
abstract class TitleScreenMixin {
|
abstract class TitleScreenMixin {
|
||||||
@Unique private static boolean buttonsInitialized = false;
|
private static boolean buttonsInitialized = false;
|
||||||
@Unique private static synchronized void setButtonsInitialized() { buttonsInitialized = true; }
|
private static synchronized void setButtonsInitialized() { buttonsInitialized = true; }
|
||||||
@Inject(method = "createNormalMenuOptions", at = @At(value = "RETURN"))
|
@Inject(method = "createNormalMenuOptions", at = @At(value = "RETURN"))
|
||||||
public void createNormalMenuOptions(int i, int j, CallbackInfoReturnable<Integer> cir) {
|
public void createNormalMenuOptions(int i, int j, CallbackInfo ci) {
|
||||||
if (!buttonsInitialized) {
|
if (!buttonsInitialized) {
|
||||||
ClickGui.INSTANCE.tick();
|
ClickGui.INSTANCE.tick();
|
||||||
ButtonImpl.initButtons();
|
ButtonImpl.initButtons();
|
||||||
@ -30,7 +30,7 @@ object ClickGui: SnowyScreen() {
|
|||||||
buttonsContext { this.mouseClicked(d, e, i) }; return super.mouseClicked(d, e, i);
|
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 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, scrollY: Double): Boolean { boxContext { scroll(d, e, scrollY) }; 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 {
|
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
||||||
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package fr.username404.snowygui
|
|||||||
|
|
||||||
import fr.username404.snowygui.config.Configuration
|
import fr.username404.snowygui.config.Configuration
|
||||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
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.gui.feature.ButtonInfo
|
||||||
import fr.username404.snowygui.misc.AddKeyMaps
|
import fr.username404.snowygui.misc.AddKeyMaps
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
|
|||||||
@ -4,7 +4,11 @@ import fr.username404.snowygui.ClickGui
|
|||||||
import fr.username404.snowygui.gui.elements.ClickBox
|
import fr.username404.snowygui.gui.elements.ClickBox
|
||||||
import fr.username404.snowygui.gui.elements.ClickBox.Companion.buttonsMax
|
import fr.username404.snowygui.gui.elements.ClickBox.Companion.buttonsMax
|
||||||
import fr.username404.snowygui.gui.elements.ClickBox.Companion.sortAlphabetically
|
import fr.username404.snowygui.gui.elements.ClickBox.Companion.sortAlphabetically
|
||||||
import fr.username404.snowygui.gui.feature.*
|
import fr.username404.snowygui.gui.feature.Category
|
||||||
|
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 fr.username404.snowygui.utils.FontUtil
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
@ -23,8 +27,8 @@ private fun supplyComponent(string: String?): Optional<Component> = string?.run
|
|||||||
|
|
||||||
val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
||||||
override fun isPauseScreen(): Boolean = false
|
override fun isPauseScreen(): Boolean = false
|
||||||
override fun render(guiGraphics: GuiGraphics, mouseX: Int, mouseY: Int, pTick: Float) {
|
override fun render(guiGraphics: GuiGraphics, i: Int, j: Int, f: Float) {
|
||||||
super.renderBackground(guiGraphics, mouseX, mouseY, pTick)
|
super.renderBackground(guiGraphics)
|
||||||
FontUtil.drawScaled(guiGraphics,
|
FontUtil.drawScaled(guiGraphics,
|
||||||
text = "An appropriate version of the Cloth Config mod is required for the configuration of snowygui.", 16.0, 16.0,
|
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
|
color = Colors.WHITE, scaleFactor = 0.85F
|
||||||
@ -49,9 +53,9 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
|||||||
startBooleanToggle(translatable("$confPrefix.behavior.sortalphabetically"), sortAlphabetically)
|
startBooleanToggle(translatable("$confPrefix.behavior.sortalphabetically"), sortAlphabetically)
|
||||||
.setDefaultValue(true).requireRestart()
|
.setDefaultValue(true).requireRestart()
|
||||||
.setSaveConsumer { sortAlphabetically = it }.build(),
|
.setSaveConsumer { sortAlphabetically = it }.build(),
|
||||||
startFloatField(translatable("$confPrefix.behavior.zoom.factor"), Zoom.zoomFactor).setSaveConsumer {
|
startDoubleField(translatable("$confPrefix.behavior.zoom.factor"), Zoom.zoomFactor).setSaveConsumer {
|
||||||
Zoom.zoomFactor = it
|
Zoom.zoomFactor = it
|
||||||
}.setMin(1.1F).build(),
|
}.setMin(1.1).build(),
|
||||||
startBooleanToggle(translatable("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer {
|
startBooleanToggle(translatable("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer {
|
||||||
Zoom.smoothCameraOnZoom = it
|
Zoom.smoothCameraOnZoom = it
|
||||||
Zoom.execAction()
|
Zoom.execAction()
|
||||||
|
|||||||
@ -56,7 +56,7 @@ object Configuration {
|
|||||||
getMethod("getConfigDir").invoke(getMethod("getInstance").invoke(null))
|
getMethod("getConfigDir").invoke(getMethod("getInstance").invoke(null))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Class.forName("net.neoforged.fml.loading.FMLPaths")
|
Class.forName("net.minecraftforge.fml.loading.FMLPaths")
|
||||||
.getField("CONFIGDIR")
|
.getField("CONFIGDIR")
|
||||||
.get(null)
|
.get(null)
|
||||||
.let { enum ->
|
.let { enum ->
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.*
|
|||||||
import fr.username404.snowygui.Snowy
|
import fr.username404.snowygui.Snowy
|
||||||
import fr.username404.snowygui.gui.feature.Colors
|
import fr.username404.snowygui.gui.feature.Colors
|
||||||
import fr.username404.snowygui.utils.RenderingUtil
|
import fr.username404.snowygui.utils.RenderingUtil
|
||||||
|
import fr.username404.snowygui.utils.RenderingUtil.colorEnd
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||||
|
|
||||||
@ -54,11 +55,11 @@ abstract class ColoredElement(
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer {
|
@JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer {
|
||||||
with(hextoRGB(color)) {
|
with(hextoRGB(color)) {
|
||||||
return this@colorIt.setColor(get(0), get(1), get(2), opacity)
|
return this@colorIt.color(get(0), get(1), get(2), opacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color) = colorIt(color, opacity)
|
internal fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color) = colorEnd(color, opacity)
|
||||||
protected fun defaultRectFunc() = RenderingUtil.drawRectangle(x, y, height, width, color, opacity)
|
protected fun defaultRectFunc() = RenderingUtil.drawRectangle(x, y, height, width, color, opacity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,22 @@
|
|||||||
package fr.username404.snowygui.gui.elements
|
package fr.username404.snowygui.gui.elements
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||||
import fr.username404.snowygui.config.Configuration
|
import fr.username404.snowygui.config.Configuration
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat
|
||||||
import fr.username404.snowygui.gui.ColoredElement
|
import fr.username404.snowygui.gui.ColoredElement
|
||||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||||
import fr.username404.snowygui.gui.feature.Category
|
import fr.username404.snowygui.gui.feature.Category
|
||||||
import fr.username404.snowygui.gui.feature.Colors
|
import fr.username404.snowygui.gui.feature.Colors
|
||||||
|
import fr.username404.snowygui.utils.RenderingUtil.buffer
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.colorShader
|
import fr.username404.snowygui.utils.RenderingUtil.colorShader
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.renderBufferWithPipeline
|
import fr.username404.snowygui.utils.RenderingUtil.tessellator
|
||||||
import io.github.config4k.extract
|
import io.github.config4k.extract
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.client.gui.Font
|
import net.minecraft.client.gui.Font
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
import net.minecraft.client.renderer.RenderPipelines
|
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import org.jetbrains.annotations.ApiStatus
|
import org.jetbrains.annotations.ApiStatus
|
||||||
import java.util.TreeSet
|
import java.util.TreeSet
|
||||||
@ -73,55 +75,52 @@ class ClickBox(
|
|||||||
var sortAlphabetically: Boolean by Configuration
|
var sortAlphabetically: Boolean by Configuration
|
||||||
const val buttonsMax: Short = 16 // TODO Remove the buttons limit
|
const val buttonsMax: Short = 16 // TODO Remove the buttons limit
|
||||||
const val clickboxHeightOffset: Int = 80
|
const val clickboxHeightOffset: Int = 80
|
||||||
private const val inclination: Float = 2.5F
|
private const val inclination: Double = 2.5
|
||||||
}
|
}
|
||||||
override fun render(guiGraphics: GuiGraphics?) {
|
override fun render(guiGraphics: GuiGraphics?) {
|
||||||
val x = x.toFloat()
|
|
||||||
val y = y.toFloat()
|
|
||||||
val currentHeight = y + (height + clickboxHeightOffset)
|
val currentHeight = y + (height + clickboxHeightOffset)
|
||||||
prepareDraw()
|
prepareDraw()
|
||||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
|
with(buffer) {
|
||||||
|
begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR)
|
||||||
// Render the header:
|
// Render the header:
|
||||||
addVertex(x, y + height, 0.0F).colorEnd()
|
vertex(x, y + height, 0.0).colorEnd()
|
||||||
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||||
addVertex(x + width, y, 0.0F).colorEnd()
|
vertex(x + width, y, 0.0).colorEnd()
|
||||||
addVertex(x + inclination, y, 0.0F).colorEnd()
|
vertex(x + inclination, y, 0.0).colorEnd()
|
||||||
}
|
|
||||||
|
|
||||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
|
|
||||||
// Render the box:
|
// Render the box:
|
||||||
addVertex(x, currentHeight, 0.0F).colorEnd()
|
vertex(x, currentHeight, 0.0).colorEnd()
|
||||||
addVertex(x + width + inclination, currentHeight, 0.0F).colorEnd()
|
vertex(x + width + inclination, currentHeight, 0.0).colorEnd()
|
||||||
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||||
addVertex(x, y + height, 0.0F).colorEnd()
|
tessellator.end()
|
||||||
}
|
|
||||||
|
|
||||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_LINE_STRIP) {
|
|
||||||
colorShader()
|
colorShader()
|
||||||
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR)
|
||||||
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
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()
|
endDraw()
|
||||||
|
|
||||||
if (buttons.isNotEmpty()) {
|
if (buttons.isNotEmpty()) {
|
||||||
buttonsProgressBar.apply {
|
buttonsProgressBar.apply {
|
||||||
this.x = this@ClickBox.x + this@ClickBox.width - 3
|
x = this@ClickBox.x + this@ClickBox.width - 3
|
||||||
this.y = this@ClickBox.y + this@ClickBox.height + 3
|
y = this@ClickBox.y + this@ClickBox.height + 3
|
||||||
}.display(guiGraphics)
|
}.display(guiGraphics)
|
||||||
buttons.forEachIndexed { num, button ->
|
buttons.forEachIndexed { num, button ->
|
||||||
val fullHeight = (y + height.toDouble())..(this.y + height + clickboxHeightOffset)
|
val fullHeight = (y + height.toDouble())..(y + height + clickboxHeightOffset)
|
||||||
button.also {
|
button.also {
|
||||||
it.x = this.x + 3
|
it.x = x + 3
|
||||||
it.y = this.y + 3 + height + (((num + 1) - barStage) * 9)
|
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)
|
it.hidden = if ((num + 1) <= 8) ((it.y) !in fullHeight) else ((it.y + it.height) !in fullHeight)
|
||||||
}.display(guiGraphics)
|
}.display(guiGraphics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
guiGraphics?.run {
|
guiGraphics?.run {
|
||||||
with(Minecraft.getInstance().font) {
|
with(Minecraft.getInstance().font) {
|
||||||
drawInBatch(Component.nullToEmpty(name.string),
|
drawInBatch(name.string,
|
||||||
(x + 5), (y + 2), Colors.TRANSPARENT.hexValue, false,
|
(x + 5).toFloat(), (y + 2).toFloat(), Colors.TRANSPARENT.hexValue, false,
|
||||||
pose().last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
|
pose().last().pose(), bufferSource(), Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import net.minecraft.client.gui.GuiGraphics
|
|||||||
import kotlin.reflect.full.findAnnotation
|
import kotlin.reflect.full.findAnnotation
|
||||||
|
|
||||||
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||||
companion object {
|
internal companion object {
|
||||||
private fun addButtons(vararg buttons: ButtonImpl) {
|
private fun addButtons(vararg buttons: ButtonImpl) {
|
||||||
buttons.groupBy { impl ->
|
buttons.groupBy { impl ->
|
||||||
ClickGui.clickBoxes.find { box ->
|
ClickGui.clickBoxes.find { box ->
|
||||||
|
|||||||
@ -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)
|
||||||
@ -9,11 +10,11 @@ object GammaBoost: ButtonImpl() {
|
|||||||
override fun execAction() {
|
override fun execAction() {
|
||||||
with(Minecraft.getInstance().options) {
|
with(Minecraft.getInstance().options) {
|
||||||
val gamma = gamma().get()
|
val gamma = gamma().get()
|
||||||
gamma().value =
|
@Suppress("KotlinConstantConditions")
|
||||||
if (toggled) {
|
(gamma() as OptionValueAccessor).setValue(if (toggled) {
|
||||||
if (gamma < boost) oldGamma = gamma
|
if (gamma < boost) oldGamma = gamma
|
||||||
boost
|
boost
|
||||||
} else oldGamma
|
} else oldGamma)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6,9 +6,9 @@ import net.minecraft.client.Minecraft
|
|||||||
@ButtonInfo(Category.MISC, shouldSave = false)
|
@ButtonInfo(Category.MISC, shouldSave = false)
|
||||||
object Zoom: ButtonImpl() {
|
object Zoom: ButtonImpl() {
|
||||||
var smoothCameraOnZoom: Boolean by Configuration
|
var smoothCameraOnZoom: Boolean by Configuration
|
||||||
var zoomFactor: Float by Configuration
|
var zoomFactor: Double by Configuration
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getNewZoom(fov: Float): Float = fov / zoomFactor
|
fun getNewZoom(fov: Double): Double = fov / zoomFactor
|
||||||
public override fun execAction() {
|
public override fun execAction() {
|
||||||
Minecraft.getInstance().options.smoothCamera = toggled && smoothCameraOnZoom
|
Minecraft.getInstance().options.smoothCamera = toggled && smoothCameraOnZoom
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,84 +1,45 @@
|
|||||||
package fr.username404.snowygui.utils
|
package fr.username404.snowygui.utils
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.BufferType
|
|
||||||
import com.mojang.blaze3d.buffers.BufferUsage
|
|
||||||
import com.mojang.blaze3d.opengl.GlCommandEncoder
|
|
||||||
import com.mojang.blaze3d.opengl.GlStateManager
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget
|
|
||||||
import com.mojang.blaze3d.systems.RenderPass
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem
|
import com.mojang.blaze3d.systems.RenderSystem
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder
|
import com.mojang.blaze3d.vertex.BufferBuilder
|
||||||
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||||
import com.mojang.blaze3d.vertex.Tesselator
|
import com.mojang.blaze3d.vertex.Tesselator
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer
|
import com.mojang.blaze3d.vertex.VertexConsumer
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat
|
||||||
import fr.username404.snowygui.gui.feature.Colors
|
import fr.username404.snowygui.gui.feature.Colors
|
||||||
import fr.username404.snowygui.gui.hextoRGB
|
import fr.username404.snowygui.gui.hextoRGB
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.renderer.GameRenderer
|
||||||
import net.minecraft.client.renderer.RenderPipelines
|
|
||||||
import java.util.OptionalInt
|
|
||||||
import java.util.OptionalDouble
|
|
||||||
|
|
||||||
object RenderingUtil {
|
object RenderingUtil {
|
||||||
|
@JvmField val tessellator: Tesselator = Tesselator.getInstance()
|
||||||
|
@JvmField val buffer: BufferBuilder = tessellator.builder
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer = hextoRGB(color).run {
|
fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer = hextoRGB(color).run {
|
||||||
setColor(get(0), get(1), get(2), opacity)
|
color(get(0), get(1), get(2), opacity)
|
||||||
}
|
}
|
||||||
|
fun VertexConsumer.colorEnd(color: Int, opacity: Float = 1F) = colorIt(color, opacity).endVertex()
|
||||||
fun colorShader() {
|
fun colorShader() {
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionColorShader)
|
||||||
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
|
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
|
||||||
}
|
}
|
||||||
fun prepareDraw() {
|
fun prepareDraw() {
|
||||||
colorShader()
|
colorShader()
|
||||||
GlStateManager._enableBlend()
|
RenderSystem.enableBlend()
|
||||||
|
RenderSystem.defaultBlendFunc()
|
||||||
}
|
}
|
||||||
fun endDraw() {
|
fun endDraw() {
|
||||||
GlStateManager._disableBlend()
|
RenderSystem.disableBlend()
|
||||||
}
|
}
|
||||||
fun drawRectangle(
|
fun drawRectangle(
|
||||||
x: Double, y: Double, height: Int, width: Int,
|
x: Double, y: Double, height: Int, width: Int,
|
||||||
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
|
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
|
||||||
): Unit = renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_QUADS) {
|
): Unit = buffer.run {
|
||||||
fun VertexConsumer.colorIt() = colorIt(color, opacity)
|
fun VertexConsumer.colorEnd() = colorEnd(color, opacity)
|
||||||
val x = x.toFloat() ; val y = y.toFloat()
|
begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
|
||||||
addVertex(x, y + height, 0.0F).colorIt()
|
vertex(x, y + height, 0.0).colorEnd()
|
||||||
addVertex(x + width, y + height, 0.0F).colorIt()
|
vertex(x + width, y + height, 0.0).colorEnd()
|
||||||
addVertex(x + width, y, 0.0F).colorIt()
|
vertex(x + width, y, 0.0).colorEnd()
|
||||||
addVertex(x, y, 0.0F).colorIt()
|
vertex(x, y, 0.0).colorEnd()
|
||||||
}
|
tessellator.end()
|
||||||
|
|
||||||
fun renderBufferWithPipeline(
|
|
||||||
name: String? = "Dynamic vertex buffer",
|
|
||||||
renderPipeline: RenderPipeline,
|
|
||||||
renderTarget: RenderTarget = Minecraft.getInstance().mainRenderTarget,
|
|
||||||
uniformAndSamplerConsumer: ((RenderPass) -> Unit)? = null,
|
|
||||||
bufferBuilderConsumer: BufferBuilder.() -> Unit,
|
|
||||||
) {
|
|
||||||
val mode = renderPipeline.vertexFormatMode
|
|
||||||
val builder = Tesselator.getInstance().begin(mode, renderPipeline.vertexFormat)
|
|
||||||
bufferBuilderConsumer(builder)
|
|
||||||
builder.buildOrThrow().use { meshData ->
|
|
||||||
val encoder = RenderSystem.getDevice().createCommandEncoder() as GlCommandEncoder
|
|
||||||
encoder.createRenderPass(
|
|
||||||
renderTarget.colorTexture!!,
|
|
||||||
OptionalInt.empty(),
|
|
||||||
renderTarget.depthTexture,
|
|
||||||
OptionalDouble.empty()
|
|
||||||
).use { renderPass ->
|
|
||||||
encoder.inRenderPass = false;
|
|
||||||
RenderSystem.getDevice().createBuffer(
|
|
||||||
{ name }, BufferType.VERTICES, BufferUsage.DYNAMIC_WRITE, meshData.vertexBuffer()
|
|
||||||
).use { buffer ->
|
|
||||||
val autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(mode)
|
|
||||||
renderPass.setPipeline(renderPipeline)
|
|
||||||
renderPass.setVertexBuffer(0, buffer)
|
|
||||||
renderPass.setIndexBuffer(
|
|
||||||
autoStorageIndexBuffer.getBuffer(meshData.drawState().indexCount()),
|
|
||||||
autoStorageIndexBuffer.type()
|
|
||||||
)
|
|
||||||
uniformAndSamplerConsumer?.invoke(renderPass)
|
|
||||||
renderPass.drawIndexed(0, meshData.drawState().indexCount())
|
|
||||||
}
|
|
||||||
encoder.inRenderPass = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,14 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "fr.username404.snowygui.mixins",
|
"package": "fr.username404.snowygui.mixins",
|
||||||
"compatibilityLevel": "JAVA_18",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"client": [],
|
"client": [
|
||||||
|
"KeysAccessor",
|
||||||
|
"KeyMappings",
|
||||||
|
"EndTickMixin",
|
||||||
|
"TitleScreenMixin",
|
||||||
|
"OptionValueAccessor"
|
||||||
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
accessWidener v2 named
|
|
||||||
|
|
||||||
accessible field net/minecraft/client/OptionInstance value Ljava/lang/Object;
|
|
||||||
mutable field net/minecraft/client/OptionInstance value Ljava/lang/Object;
|
|
||||||
|
|
||||||
accessible field net/minecraft/client/gui/GuiGraphics bufferSource Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;
|
|
||||||
|
|
||||||
accessible field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z
|
|
||||||
mutable field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"accessWidener": "snowygui.accessWidener"
|
|
||||||
}
|
|
||||||
@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
|
|
||||||
@Mixin(GameRenderer.class)
|
@Mixin(GameRenderer.class)
|
||||||
abstract class ZoomMixin {
|
abstract class ZoomMixin {
|
||||||
@Inject(at = @At(value = "RETURN"), method = "getFov(Lnet/minecraft/client/Camera;FZ)F", cancellable = true)
|
@Inject(at = @At(value = "RETURN"), method = "getFov(Lnet/minecraft/client/Camera;FZ)D", cancellable = true)
|
||||||
private void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Float> cir) {
|
private void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Double> cir) {
|
||||||
if (Zoom.INSTANCE.getToggled() && !OkZoomerCompatKt.isOkZoomerPresent) {
|
if (Zoom.INSTANCE.getToggled() && !OkZoomerCompatKt.isOkZoomerPresent) {
|
||||||
cir.setReturnValue(Zoom.getNewZoom(cir.getReturnValue()));
|
cir.setReturnValue(Zoom.getNewZoom(cir.getReturnValue()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package fr.username404.snowygui.fabric
|
package fr.username404.snowygui.fabric
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import fr.username404.snowygui.EventSnowy
|
import fr.username404.snowygui.EventSnowy
|
||||||
import fr.username404.snowygui.Snowy
|
import fr.username404.snowygui.Snowy
|
||||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||||
@ -7,7 +8,6 @@ import net.fabricmc.api.ClientModInitializer
|
|||||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
|
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.EVENT
|
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.EVENT
|
||||||
import net.fabricmc.loader.api.FabricLoader
|
import net.fabricmc.loader.api.FabricLoader
|
||||||
import net.minecraft.client.DeltaTracker
|
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
import kotlin.io.path.exists
|
import kotlin.io.path.exists
|
||||||
import kotlin.io.path.isDirectory
|
import kotlin.io.path.isDirectory
|
||||||
@ -21,7 +21,7 @@ class FabricInit: Snowy(), ClientModInitializer {
|
|||||||
EVENT.register(
|
EVENT.register(
|
||||||
object: HudRenderCallback, EventSnowy {
|
object: HudRenderCallback, EventSnowy {
|
||||||
override val type: String = "HudRender"
|
override val type: String = "HudRender"
|
||||||
override fun onHudRender(guiGraphics: GuiGraphics?, tickCounter: DeltaTracker?) = fire(guiGraphics)
|
override fun onHudRender(guiGraphics: GuiGraphics?, tickDelta: Float) = fire(guiGraphics)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,6 @@
|
|||||||
"snowygui-common.mixins.json",
|
"snowygui-common.mixins.json",
|
||||||
"snowygui-fabric.mixins.json"
|
"snowygui-fabric.mixins.json"
|
||||||
],
|
],
|
||||||
"accessWidener": "snowygui.accessWidener",
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=${fabric_loader}",
|
"fabricloader": ">=${fabric_loader}",
|
||||||
"fabric-language-kotlin": ">=${fabric_kotlin}",
|
"fabric-language-kotlin": ">=${fabric_kotlin}",
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "fr.username404.snowygui.mixins",
|
"package": "fr.username404.snowygui.mixins",
|
||||||
"compatibilityLevel": "JAVA_18",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"client": [
|
"client": [
|
||||||
"EndTickMixin",
|
|
||||||
"TitleScreenMixin",
|
|
||||||
"KeysAccessor",
|
|
||||||
"KeyMappings",
|
|
||||||
"ZoomMixin",
|
"ZoomMixin",
|
||||||
"OkZoomerAlternativeMixin"
|
"OkZoomerAlternativeMixin"
|
||||||
],
|
],
|
||||||
|
|||||||
25
forge/build.gradle.kts
Normal file
25
forge/build.gradle.kts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
architectury { platformSetupLoomIde(); forge() }
|
||||||
|
repositories {
|
||||||
|
maven(url = "https://thedarkcolour.github.io/KotlinForForge/")
|
||||||
|
}
|
||||||
|
|
||||||
|
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", configuration = "namedElements")) { isTransitive = false }
|
||||||
|
add("developmentForge", project(path = ":common")) { isTransitive = false }
|
||||||
|
shadowC(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
|
||||||
|
}; loom {
|
||||||
|
if (JavaVersion.current().isJava9Compatible) {
|
||||||
|
runs {
|
||||||
|
val args: MutableList<String> = mutableListOf("-Dfml.earlyprogresswindow=false")
|
||||||
|
args += if (JavaVersion.current() < JavaVersion.VERSION_17) {
|
||||||
|
listOf("--add-exports java.base/sun.security.util=ALL-UNNAMED", "--add-opens java.base/java.util.jar=ALL-UNNAMED")
|
||||||
|
} else listOf("--illegal-access=permit")
|
||||||
|
this.forEach {
|
||||||
|
it.vmArgs(args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
forge/gradle.properties
Normal file
1
forge/gradle.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
loom.platform=forge
|
||||||
@ -4,19 +4,25 @@ import fr.username404.snowygui.Snowy
|
|||||||
import fr.username404.snowygui.config.SnowyConfigScreen
|
import fr.username404.snowygui.config.SnowyConfigScreen
|
||||||
import fr.username404.snowygui.config.configScreenParent
|
import fr.username404.snowygui.config.configScreenParent
|
||||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||||
import net.neoforged.fml.ModContainer
|
import net.minecraftforge.fml.ModList
|
||||||
import net.neoforged.fml.ModList
|
import net.minecraftforge.fml.common.Mod
|
||||||
import net.neoforged.fml.common.Mod
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
|
||||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent
|
import net.minecraftforge.client.ConfigScreenHandler
|
||||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory
|
import net.minecraftforge.forgespi.language.ModFileScanData
|
||||||
import net.neoforged.neoforge.common.NeoForge
|
|
||||||
import net.neoforged.neoforgespi.language.ModFileScanData
|
|
||||||
import org.objectweb.asm.Type
|
import org.objectweb.asm.Type
|
||||||
|
import thedarkcolour.kotlinforforge.forge.FORGE_BUS
|
||||||
|
import thedarkcolour.kotlinforforge.forge.LOADING_CONTEXT
|
||||||
|
import thedarkcolour.kotlinforforge.forge.MOD_BUS
|
||||||
|
|
||||||
@Mod("snowygui")
|
@Mod("snowygui")
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
class ForgeInit(container: ModContainer): Snowy() {
|
class ForgeInit: Snowy() {
|
||||||
private fun initSetup(event: FMLClientSetupEvent) = atInit()
|
private fun initSetup(event: FMLClientSetupEvent) = atInit()
|
||||||
|
private fun configSetup(event: FMLClientSetupEvent) {
|
||||||
|
LOADING_CONTEXT.registerExtensionPoint(
|
||||||
|
ConfigScreenHandler.ConfigScreenFactory::class.java
|
||||||
|
) { ConfigScreenHandler.ConfigScreenFactory { _, parent -> configScreenParent = parent; SnowyConfigScreen } }
|
||||||
|
}
|
||||||
override val annotatedButtons = ModList.get() // Forge-specific reflection
|
override val annotatedButtons = ModList.get() // Forge-specific reflection
|
||||||
.allScanData
|
.allScanData
|
||||||
.flatMap { obj: ModFileScanData -> obj.classes }
|
.flatMap { obj: ModFileScanData -> obj.classes }
|
||||||
@ -28,18 +34,13 @@ class ForgeInit(container: ModContainer): Snowy() {
|
|||||||
.map { Class.forName((it!!.javaClass.getDeclaredField("clazz").apply { isAccessible = true }.get(it) as Type).className).asSubclass(ButtonImpl::class.java)}
|
.map { Class.forName((it!!.javaClass.getDeclaredField("clazz").apply { isAccessible = true }.get(it) as Type).className).asSubclass(ButtonImpl::class.java)}
|
||||||
.toSet()
|
.toSet()
|
||||||
init {
|
init {
|
||||||
container.eventBus!!.run {
|
with(MOD_BUS) {
|
||||||
addListener(this@ForgeInit::initSetup)
|
addListener(this@ForgeInit::initSetup)
|
||||||
register(MiscModBusHandlers)
|
addListener(this@ForgeInit::configSetup)
|
||||||
}
|
}
|
||||||
NeoForge.EVENT_BUS.run {
|
with(FORGE_BUS) {
|
||||||
register(EndTickHandler)
|
|
||||||
register(HudHandler)
|
register(HudHandler)
|
||||||
register(ZoomHandler)
|
register(ZoomHandler)
|
||||||
}
|
}
|
||||||
container.registerExtensionPoint(
|
|
||||||
IConfigScreenFactory::class.java,
|
|
||||||
IConfigScreenFactory { _, parent -> configScreenParent = parent; SnowyConfigScreen }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
package fr.username404.snowygui.forge
|
package fr.username404.snowygui.forge
|
||||||
|
|
||||||
import fr.username404.snowygui.EventSnowy
|
import fr.username404.snowygui.EventSnowy
|
||||||
import net.neoforged.bus.api.SubscribeEvent
|
import net.minecraftforge.client.event.RenderGuiEvent
|
||||||
import net.neoforged.neoforge.client.event.RenderGuiEvent
|
import net.minecraftforge.eventbus.api.SubscribeEvent
|
||||||
|
|
||||||
object HudHandler: EventSnowy {
|
object HudHandler: EventSnowy {
|
||||||
override val type: String = "HudRender"
|
override val type: String = "HudRender"
|
||||||
@ -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.neoforged.bus.api.SubscribeEvent
|
import net.minecraftforge.client.event.ComputeFovModifierEvent
|
||||||
import net.neoforged.neoforge.client.event.ComputeFovModifierEvent
|
import net.minecraftforge.eventbus.api.SubscribeEvent
|
||||||
|
|
||||||
object ZoomHandler {
|
object ZoomHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
fun onFOVEvent(event: ComputeFovModifierEvent) {
|
fun onFOVEvent(event: ComputeFovModifierEvent) {
|
||||||
if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier)
|
if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier.toDouble()).toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,14 +14,14 @@ A cross-platform mod offering a useful interface.
|
|||||||
logoFile = "icon.png"
|
logoFile = "icon.png"
|
||||||
|
|
||||||
[[dependencies.snowygui]]
|
[[dependencies.snowygui]]
|
||||||
modId = "cloth_config"
|
modId = "cloth-config"
|
||||||
mandatory = false
|
mandatory = false
|
||||||
versionRange = "[${clothconfig},)"
|
versionRange = "[${clothconfig},)"
|
||||||
ordering = "BEFORE"
|
ordering = "BEFORE"
|
||||||
side = "CLIENT"
|
side = "CLIENT"
|
||||||
|
|
||||||
[[dependencies.snowygui]]
|
[[dependencies.snowygui]]
|
||||||
modId = "neoforge"
|
modId = "forge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[${forge_version},)"
|
versionRange = "[${forge_version},)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
@ -33,9 +33,3 @@ mandatory = true
|
|||||||
versionRange = "[${minecraft_version},)"
|
versionRange = "[${minecraft_version},)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[mixins]]
|
|
||||||
config = "snowygui-common.mixins.json"
|
|
||||||
|
|
||||||
[[mixins]]
|
|
||||||
config = "snowygui-neoforge.mixins.json"
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"required": false,
|
"required": false,
|
||||||
"package": "fr.username404.snowygui.mixins",
|
"package": "fr.username404.snowygui.mixins",
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"client": [],
|
"client": [],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
@ -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=1.21.5
|
minecraft=1.20
|
||||||
forge_version=21.5.40-beta
|
forge_version=46.0
|
||||||
kotlinforforge=5.7.0
|
kotlinforforge=4.3.0
|
||||||
kotlinVer=2.1.0
|
kotlinVer=1.8.22
|
||||||
kotlin_coroutines_version=1.9.0
|
kotlin_coroutines_version=1.7.1
|
||||||
serializationVer=1.7.3
|
serializationVer=1.5.1
|
||||||
fabric_loader_version=0.14.20
|
fabric_loader_version=0.14.19
|
||||||
fabric_language_kotlin=1.13.0+kotlin.2.1.0
|
fabric_language_kotlin=1.9.5+kotlin.1.8.22
|
||||||
fabric_resource_loader_version=3.1.6+02ca679607
|
fabric_resource_loader_version=0.11.7+f7923f6d27
|
||||||
fabric_rendering_api_version=11.1.11+081cc04307
|
fabric_rendering_api_version=3.0.6+b3afc78b27
|
||||||
fabric_api_base_version=0.4.62+73a52b4b07
|
fabric_api_base_version=0.4.29+b04edc7a27
|
||||||
clothconfig_version=18.0.145
|
clothconfig_version=11.0.99
|
||||||
modmenu_version=14.0.0-rc.2
|
modmenu_version=7.0.0
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-rc-1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
architectury { platformSetupLoomIde(); neoForge() }
|
|
||||||
repositories {
|
|
||||||
maven(url = "https://maven.neoforged.net/releases/")
|
|
||||||
maven(url = "https://thedarkcolour.github.io/KotlinForForge/")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
neoForge("net.neoforged:neoforge:${rootProject.property("forge_version").toString().let {
|
|
||||||
return@let if (it.length > 4) it else "$it.+"
|
|
||||||
}}")
|
|
||||||
implementation("thedarkcolour:kotlinforforge:${rootProject.property("kotlinforforge")}")
|
|
||||||
modApi("me.shedaniel.cloth:cloth-config-neoforge:${rootProject.property("clothconfig_version")}")
|
|
||||||
implementation(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
|
|
||||||
|
|
||||||
add("developmentNeoForge", project(path = ":common")) { isTransitive = false }
|
|
||||||
shadowC(project(path = ":common", configuration = "transformProductionNeoForge")) { isTransitive = false }
|
|
||||||
}; loom {
|
|
||||||
runs {
|
|
||||||
val args: MutableList<String> = mutableListOf("-Dfml.earlyprogresswindow=false")
|
|
||||||
args += listOf("--illegal-access=permit")
|
|
||||||
this.forEach {
|
|
||||||
it.vmArgs(args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
loom.platform=neoforge
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
package fr.username404.snowygui.forge
|
|
||||||
|
|
||||||
import fr.username404.snowygui.EventSnowy
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent
|
|
||||||
import net.neoforged.neoforge.client.event.ClientTickEvent
|
|
||||||
|
|
||||||
object EndTickHandler: EventSnowy {
|
|
||||||
override val type: String = "EndTick"
|
|
||||||
@SubscribeEvent
|
|
||||||
fun handleEndTick(event: ClientTickEvent.Post) = fire<Any>()
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package fr.username404.snowygui.forge
|
|
||||||
|
|
||||||
import fr.username404.snowygui.ClickGui
|
|
||||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
|
||||||
import fr.username404.snowygui.misc.AddKeyMaps
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent
|
|
||||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent
|
|
||||||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent
|
|
||||||
|
|
||||||
object MiscModBusHandlers {
|
|
||||||
@SubscribeEvent
|
|
||||||
fun handleClickGuiInit(event: RegisterMenuScreensEvent) {
|
|
||||||
ClickGui.tick()
|
|
||||||
ButtonImpl.initButtons()
|
|
||||||
}
|
|
||||||
@SubscribeEvent
|
|
||||||
fun handleKeys(event: RegisterKeyMappingsEvent) {
|
|
||||||
AddKeyMaps.list.forEach {
|
|
||||||
event.register(it.key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,7 +2,7 @@ pluginManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
maven(url = "https://maven.fabricmc.net/")
|
maven(url = "https://maven.fabricmc.net/")
|
||||||
maven(url = "https://maven.architectury.dev/")
|
maven(url = "https://maven.architectury.dev/")
|
||||||
maven(url = "https://maven.neoforged.net/releases/")
|
maven(url = "https://maven.minecraftforge.net/")
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
@ -11,7 +11,7 @@ pluginManagement {
|
|||||||
|
|
||||||
include("common")
|
include("common")
|
||||||
include("fabric")
|
include("fabric")
|
||||||
include("neoforge")
|
include("forge")
|
||||||
|
|
||||||
rootProject.name = "SnowyGUI"
|
rootProject.name = "SnowyGUI"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user