Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
928e691cc9 | |||
8c526473e1 | |||
7b310399cf | |||
2aaeb7b039 | |||
6416a03001 | |||
e96c2adb68 | |||
5d98234d39 | |||
6eed08aa53 | |||
92c8e36c71 |
@ -18,7 +18,7 @@ plugins {
|
||||
kotlin("plugin.serialization") version "2.0.0"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
||||
id("architectury-plugin") version "[3.4.160, 3.5["
|
||||
id("dev.architectury.loom") version "1.9-SNAPSHOT" apply false
|
||||
id("dev.architectury.loom") version "1.10-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"
|
||||
@ -26,7 +26,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "fr.username404"
|
||||
version = "0.3.5"
|
||||
version = "0.3.6"
|
||||
val groupAndName = "${rootProject.group}.${rootProject.name.lowercase()}"
|
||||
|
||||
val javaVer: String = "21"
|
||||
@ -38,6 +38,7 @@ val minecraftVersion: String = (rootProject.property("minecraft") as String).als
|
||||
architectury { minecraft = it }
|
||||
}
|
||||
val kotlinX: String = "org.jetbrains.kotlinx"
|
||||
val devBuild = rootProject.hasProperty("devBuild") && rootProject.property("devBuild").toString().toBoolean()
|
||||
|
||||
subprojects {
|
||||
group = rootProject.group.toString()
|
||||
@ -56,7 +57,7 @@ subprojects {
|
||||
}
|
||||
mappingsDep = layered {
|
||||
silentMojangMappingsLicense()
|
||||
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21:2024.06.23")
|
||||
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21.5:2025.04.19")
|
||||
}
|
||||
val refmap = "snowygui-${project.name}-refmap.json"
|
||||
mixin {
|
||||
@ -167,14 +168,16 @@ subprojects {
|
||||
mergeinterfacesaggressively()
|
||||
}
|
||||
withType(net.fabricmc.loom.task.RemapJarTask::class) {
|
||||
dependsOn(shrinkJar)
|
||||
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
||||
if (!devBuild) {
|
||||
dependsOn(shrinkJar)
|
||||
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
||||
inputFile.set(shrinkedJar)
|
||||
} else inputFile.set(shadowJar.archiveFile)
|
||||
archiveBaseName.set(shadowJar.archiveBaseName)
|
||||
archiveVersion.set("[${rootProject.version}+$minecraftVersion]")
|
||||
archiveClassifier.set(this@subprojects.name)
|
||||
if (this@subprojects.name.contains("forge"))
|
||||
atAccessWideners.set(listOf("${rootProject.name.lowercase()}.accessWidener"))
|
||||
inputFile.set(shrinkedJar)
|
||||
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
|
||||
}
|
||||
getByName("modrinth").dependsOn(build)
|
||||
|
@ -1,4 +1,4 @@
|
||||
architectury { common("fabric", "neoforge"); injectInjectables = false }
|
||||
architectury { common("fabric", "neoforge"); injectInjectables = true }
|
||||
dependencies {
|
||||
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
|
||||
modImplementation("me.shedaniel.cloth:cloth-config:${rootProject.property("clothconfig_version")}") {
|
||||
|
@ -8,34 +8,30 @@ import com.typesafe.config.ConfigFactory.parseFile
|
||||
import com.typesafe.config.ConfigFactory.parseString
|
||||
import com.typesafe.config.ConfigRenderOptions
|
||||
import com.typesafe.config.ConfigValueFactory
|
||||
import dev.architectury.injectables.targets.ArchitecturyTarget
|
||||
import fr.username404.snowygui.ClickGui
|
||||
import fr.username404.snowygui.Snowy
|
||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||
import fr.username404.snowygui.gui.feature.shouldSave
|
||||
import fr.username404.snowygui.gui.feature.Category
|
||||
import fr.username404.snowygui.gui.feature.Macro
|
||||
import fr.username404.snowygui.gui.feature.shouldSave
|
||||
import io.github.config4k.extract
|
||||
import io.github.config4k.getValue
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
import java.io.File
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
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 java.io.File
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.absolutePathString
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.full.isSuperclassOf
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
object Configuration {
|
||||
@Deprecated("Use the getValue or setValue methods instead", level = DeprecationLevel.ERROR)
|
||||
@JvmStatic
|
||||
@ -54,7 +50,19 @@ object Configuration {
|
||||
}.toTypedArray()),
|
||||
)
|
||||
}
|
||||
private val configDirectory: String = (Minecraft.getInstance().gameDirectory.absolutePath + File.separator + "config").also { File(it).mkdir() }
|
||||
private val configDirectory: String =
|
||||
(if (ArchitecturyTarget.getCurrentTarget() == "fabric") {
|
||||
Class.forName("net.fabricmc.loader.api.FabricLoader").run {
|
||||
getMethod("getConfigDir").invoke(getMethod("getInstance").invoke(null))
|
||||
}
|
||||
} else {
|
||||
Class.forName("net.neoforged.fml.loading.FMLPaths")
|
||||
.getField("CONFIGDIR")
|
||||
.get(null)
|
||||
.let { enum ->
|
||||
enum.javaClass.getMethod("get").invoke(enum)
|
||||
}
|
||||
} as Path).absolutePathString()
|
||||
private val file: File = File(configDirectory + File.separator + "snowy.conf")
|
||||
private val obtained: Config = run {
|
||||
var result: Config = empty()
|
||||
@ -87,11 +95,7 @@ object Configuration {
|
||||
val enabledFeatures = mutableMapOf<String, Boolean>().apply {
|
||||
"enabledFeatures".let { obtained.run {
|
||||
if (hasPath(it)) {
|
||||
putAll(extract<Map<out String, Boolean>>(it).filterKeys { keyName -> ClickGui.clickBoxes.any {
|
||||
it.buttons.any { button ->
|
||||
button.info.shouldSave() && button.title == keyName
|
||||
}
|
||||
}})
|
||||
putAll(extract<Map<out String, Boolean>>(it))
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package fr.username404.snowygui.gui.elements
|
||||
|
||||
import com.mojang.blaze3d.vertex.BufferUploader
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||
import com.mojang.blaze3d.vertex.VertexFormat
|
||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||
import fr.username404.snowygui.config.Configuration
|
||||
import fr.username404.snowygui.gui.ColoredElement
|
||||
@ -12,11 +9,12 @@ import fr.username404.snowygui.gui.feature.Colors
|
||||
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.tessellator
|
||||
import fr.username404.snowygui.utils.RenderingUtil.renderBufferWithPipeline
|
||||
import io.github.config4k.extract
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.renderer.RenderPipelines
|
||||
import net.minecraft.network.chat.Component
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.TreeSet
|
||||
@ -82,25 +80,26 @@ class ClickBox(
|
||||
val y = y.toFloat()
|
||||
val currentHeight = y + (height + clickboxHeightOffset)
|
||||
prepareDraw()
|
||||
with(tessellator.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR)) {
|
||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
|
||||
// Render the header:
|
||||
addVertex(x, y + height, 0.0F).colorEnd()
|
||||
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
||||
addVertex(x + width, y, 0.0F).colorEnd()
|
||||
addVertex(x + inclination, y, 0.0F).colorEnd()
|
||||
}
|
||||
|
||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
|
||||
// Render the box:
|
||||
addVertex(x, currentHeight, 0.0F).colorEnd()
|
||||
addVertex(x + width + inclination, currentHeight, 0.0F).colorEnd()
|
||||
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
||||
BufferUploader.drawWithShader(buildOrThrow())
|
||||
addVertex(x, y + height, 0.0F).colorEnd()
|
||||
}
|
||||
|
||||
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_LINE_STRIP) {
|
||||
colorShader()
|
||||
with(tessellator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR)) {
|
||||
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
BufferUploader.drawWithShader(buildOrThrow())
|
||||
}
|
||||
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
}
|
||||
endDraw()
|
||||
|
||||
|
@ -17,25 +17,20 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||
private fun addButtons(vararg buttons: ButtonImpl) {
|
||||
buttons.groupBy { impl ->
|
||||
ClickGui.clickBoxes.find { box ->
|
||||
with(impl) {
|
||||
box.isCategory(impl.info.parent)
|
||||
}
|
||||
}.entries.forEach { entry -> entry.run {
|
||||
key?.buttons?.clear()
|
||||
value.forEach { if (!it.isDisabled) {
|
||||
key?.buttons?.add(it.apply {
|
||||
if (info.shouldSave() && !info.parent.shouldHide) {
|
||||
Configuration.enabledFeatures[title]?.let { bool ->
|
||||
toggled = bool
|
||||
}
|
||||
}
|
||||
box.isCategory(info.parent)
|
||||
}
|
||||
}
|
||||
}.entries.forEach { entry ->
|
||||
with(entry) {
|
||||
key?.buttons?.clear()
|
||||
value.forEach {
|
||||
if (!it.isDisabled) {
|
||||
key?.buttons?.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
} }
|
||||
} }
|
||||
}
|
||||
@JvmStatic
|
||||
fun initButtons() = addButtons(
|
||||
|
@ -9,12 +9,13 @@ import net.arikia.dev.drpc.DiscordRPC as discord_rpc
|
||||
@ButtonInfo(Category.MISC)
|
||||
object DiscordRPC: ButtonImpl() {
|
||||
private val RPCHandlers: DiscordEventHandlers = DiscordEventHandlers.Builder().build()
|
||||
private val RichPresence: DiscordRichPresence.Builder = DiscordRichPresence
|
||||
private val RichPresence: Lazy<DiscordRichPresence.Builder> = lazy { DiscordRichPresence
|
||||
.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())
|
||||
if (toggled) discord_rpc.discordUpdatePresence(RichPresence.value.build())
|
||||
else discord_rpc.discordClearPresence()
|
||||
}
|
||||
init {
|
||||
|
@ -1,43 +1,84 @@
|
||||
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.vertex.BufferUploader
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder
|
||||
import com.mojang.blaze3d.vertex.Tesselator
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer
|
||||
import com.mojang.blaze3d.vertex.VertexFormat
|
||||
import fr.username404.snowygui.gui.feature.Colors
|
||||
import fr.username404.snowygui.gui.hextoRGB
|
||||
import net.minecraft.client.renderer.CoreShaders
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.RenderPipelines
|
||||
import java.util.OptionalInt
|
||||
import java.util.OptionalDouble
|
||||
|
||||
object RenderingUtil {
|
||||
@JvmField val tessellator: Tesselator = Tesselator.getInstance()
|
||||
@JvmStatic
|
||||
fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer = hextoRGB(color).run {
|
||||
setColor(get(0), get(1), get(2), opacity)
|
||||
}
|
||||
fun colorShader() {
|
||||
RenderSystem.setShader(CoreShaders.POSITION_COLOR)
|
||||
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
|
||||
}
|
||||
fun prepareDraw() {
|
||||
colorShader()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
GlStateManager._enableBlend()
|
||||
}
|
||||
fun endDraw() {
|
||||
RenderSystem.disableBlend()
|
||||
GlStateManager._disableBlend()
|
||||
}
|
||||
fun drawRectangle(
|
||||
x: Double, y: Double, height: Int, width: Int,
|
||||
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
|
||||
): Unit = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR).run {
|
||||
): Unit = renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_QUADS) {
|
||||
fun VertexConsumer.colorIt() = colorIt(color, opacity)
|
||||
val x = x.toFloat() ; val y = y.toFloat()
|
||||
addVertex(x, y + height, 0.0F).colorIt()
|
||||
addVertex(x + width, y + height, 0.0F).colorIt()
|
||||
addVertex(x + width, y, 0.0F).colorIt()
|
||||
addVertex(x, y, 0.0F).colorIt()
|
||||
BufferUploader.drawWithShader(buildOrThrow())
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,4 +3,7 @@ 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 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
|
@ -7,16 +7,16 @@ org.gradle.parallel=true
|
||||
org.gradle.unsafe.configuration-cache=on
|
||||
org.gradle.vfs.watch=true
|
||||
|
||||
minecraft=1.21.2
|
||||
forge_version=21.2.1-beta
|
||||
minecraft=1.21.5
|
||||
forge_version=21.5.40-beta
|
||||
kotlinforforge=5.7.0
|
||||
kotlinVer=2.1.0
|
||||
kotlin_coroutines_version=1.9.0
|
||||
serializationVer=1.7.3
|
||||
fabric_loader_version=0.14.20
|
||||
fabric_language_kotlin=1.13.0+kotlin.2.1.0
|
||||
fabric_resource_loader_version=3.0.5+c47b9d4373
|
||||
fabric_rendering_api_version=8.0.5+c47b9d4373
|
||||
fabric_api_base_version=0.4.48+c47b9d4373
|
||||
clothconfig_version=16.0.143
|
||||
modmenu_version=12.0.0
|
||||
fabric_resource_loader_version=3.1.6+02ca679607
|
||||
fabric_rendering_api_version=11.1.11+081cc04307
|
||||
fabric_api_base_version=0.4.62+73a52b4b07
|
||||
clothconfig_version=18.0.145
|
||||
modmenu_version=14.0.0-rc.2
|
||||
|
Loading…
Reference in New Issue
Block a user