Compare commits

..

No commits in common. "1.21.6" and "1.21.5" have entirely different histories.

8 changed files with 39 additions and 55 deletions

View File

@ -14,8 +14,8 @@ buildscript {
}
plugins {
kotlin("jvm") version "2.1.20"
kotlin("plugin.serialization") version "2.1.20"
kotlin("jvm") version "2.0.0"
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.10-SNAPSHOT" apply false
@ -57,7 +57,7 @@ subprojects {
}
mappingsDep = layered {
silentMojangMappingsLicense()
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21.6:2025.06.26-nightly-20250626.125431-1")
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21.5:2025.04.19")
}
val refmap = "snowygui-${project.name}-refmap.json"
mixin {

View File

@ -12,10 +12,10 @@ import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
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 net.minecraft.util.ARGB
import org.jetbrains.annotations.ApiStatus
import java.util.TreeSet
import kotlin.collections.LinkedHashSet
@ -45,7 +45,7 @@ class ClickBox(
override val color: Int get() = this@ClickBox.color
override fun render(guiGraphics: GuiGraphics?) {
prepareDraw()
colorShader(); defaultRectFunc();
colorShader(); defaultRectFunc()
endDraw()
}
init { height = 8 }
@ -119,11 +119,9 @@ class ClickBox(
}
guiGraphics?.run {
with(Minecraft.getInstance().font) {
drawString(
this,
Component.nullToEmpty(name.string),
(x + 5).toInt(), (y + 2).toInt(),
ARGB.opaque(Colors.TRANSPARENT.hexValue), false
drawInBatch(Component.nullToEmpty(name.string),
(x + 5), (y + 2), Colors.TRANSPARENT.hexValue, false,
pose().last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
)
}
}

View File

@ -87,7 +87,7 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
}
final override fun render(guiGraphics: GuiGraphics?) {
prepareDraw()
colorShader(); defaultRectFunc();
colorShader(); defaultRectFunc()
endDraw()
if (guiGraphics != null) {
FontUtil.drawScaled(guiGraphics, title, x + 1, y + 1, 0.75F)

View File

@ -3,19 +3,13 @@ package fr.username404.snowygui.utils
import net.minecraft.client.Minecraft
import fr.username404.snowygui.gui.feature.Colors
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.util.ARGB
import org.joml.Matrix3x2f
object FontUtil {
fun drawScaled(guiGraphics: GuiGraphics, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
val stack = guiGraphics.pose()
stack.scale(scaleFactor, scaleFactor, Matrix3x2f())
guiGraphics.drawString(
Minecraft.getInstance().font, text,
(x / scaleFactor).toInt(), (y / scaleFactor).toInt(),
ARGB.opaque(color.hexValue), false
)
stack.scale(scaleFactor, scaleFactor, scaleFactor)
guiGraphics.drawString(Minecraft.getInstance().font, text, (x / scaleFactor).toInt(), (y / scaleFactor).toInt(), color.hexValue, false)
val factorToOriginal = 1F / scaleFactor
stack.scale(factorToOriginal, factorToOriginal, Matrix3x2f())
stack.scale(factorToOriginal, factorToOriginal, factorToOriginal)
}
}

View File

@ -1,5 +1,7 @@
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
@ -13,16 +15,17 @@ import fr.username404.snowygui.gui.feature.Colors
import fr.username404.snowygui.gui.hextoRGB
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.RenderPipelines
import org.joml.Vector4f
import java.util.OptionalDouble
import java.util.OptionalInt
import java.util.OptionalDouble
object RenderingUtil {
@JvmStatic
fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer = hextoRGB(color).run {
setColor(get(0), get(1), get(2), opacity)
}
fun colorShader() {}
fun colorShader() {
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
}
fun prepareDraw() {
colorShader()
GlStateManager._enableBlend()
@ -42,13 +45,6 @@ object RenderingUtil {
addVertex(x, y, 0.0F).colorIt()
}
val gpuSlice = RenderSystem.getDynamicUniforms().writeTransform(
RenderSystem.getModelViewMatrix(),
Vector4f(1F, 1F, 1F, 1F), // Alternative to old setShaderColor
RenderSystem.getModelOffset(),
RenderSystem.getTextureMatrix(),
RenderSystem.getShaderLineWidth()
)
fun renderBufferWithPipeline(
name: String? = "Dynamic vertex buffer",
renderPipeline: RenderPipeline,
@ -62,15 +58,14 @@ object RenderingUtil {
builder.buildOrThrow().use { meshData ->
val encoder = RenderSystem.getDevice().createCommandEncoder() as GlCommandEncoder
encoder.createRenderPass(
{ name },
renderTarget.colorTextureView!!,
renderTarget.colorTexture!!,
OptionalInt.empty(),
renderTarget.depthTextureView!!,
renderTarget.depthTexture,
OptionalDouble.empty()
).use { renderPass ->
encoder.inRenderPass = false;
RenderSystem.getDevice().createBuffer(
{ name }, 40, meshData.vertexBuffer()
{ name }, BufferType.VERTICES, BufferUsage.DYNAMIC_WRITE, meshData.vertexBuffer()
).use { buffer ->
val autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(mode)
renderPass.setPipeline(renderPipeline)
@ -79,13 +74,8 @@ object RenderingUtil {
autoStorageIndexBuffer.getBuffer(meshData.drawState().indexCount()),
autoStorageIndexBuffer.type()
)
// RenderSystem.bindDefaultUniforms(renderPass)
renderPass.setUniform(
"DynamicTransforms",
gpuSlice
)
uniformAndSamplerConsumer?.invoke(renderPass)
renderPass.drawIndexed(0, 0, meshData.drawState().indexCount(), 1)
renderPass.drawIndexed(0, meshData.drawState().indexCount())
}
encoder.inRenderPass = false;
}

View File

@ -3,5 +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 com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z
mutable field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z

View File

@ -1,22 +1,22 @@
org.gradle.daemon=false
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2G -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+AlwaysPreTouch
org.gradle.jvmargs=-Xmx2G -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:+AlwaysPreTouch
kotlin.incremental=true
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.unsafe.configuration-cache=on
org.gradle.vfs.watch=true
minecraft=1.21.6
forge_version=21.6.0-beta
kotlinforforge=5.9.0
kotlinVer=2.1.20
kotlin_coroutines_version=1.10.2
serializationVer=1.8.1
fabric_loader_version=0.16.0
fabric_language_kotlin=1.13.3+kotlin.2.1.21
fabric_resource_loader_version=3.1.10+fa6cb72b9c
fabric_rendering_api_version=12.3.0+ac3e15d19c
fabric_api_base_version=0.4.63+9ec45cd89c
clothconfig_version=19.0.146
modmenu_version=15.0.0-beta.1
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.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

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-rc-1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists