Compare commits

...

8 Commits

Author SHA1 Message Date
202c06bead
Update kotlinforforge to 5.9.0
To fully support NeoForged 1.21.6

Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-29 09:43:44 +02:00
80204fcb01
Improve writeTransform call
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-27 02:43:06 +02:00
d0f46afc28
Actually use a value of 40 for BufferType.VERTICES, and continue porting effort
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-27 02:38:39 +02:00
04873a7a64
Fix renderPass draw call
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-27 01:11:42 +02:00
50db20d855
Fix arguments to createRenderPass
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-27 01:01:25 +02:00
8e96814e12
Use a value of 40 for BufferType.VERTICES
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-27 00:28:47 +02:00
38df17d90f
Start trying to port to 1.21.6
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-26 21:23:53 +02:00
9e0f5e696c
Update gradle
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-06-26 21:23:26 +02:00
8 changed files with 55 additions and 39 deletions

View File

@ -14,8 +14,8 @@ buildscript {
}
plugins {
kotlin("jvm") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
kotlin("jvm") version "2.1.20"
kotlin("plugin.serialization") version "2.1.20"
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.5:2025.04.19")
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21.6:2025.06.26-nightly-20250626.125431-1")
}
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,9 +119,11 @@ class ClickBox(
}
guiGraphics?.run {
with(Minecraft.getInstance().font) {
drawInBatch(Component.nullToEmpty(name.string),
(x + 5), (y + 2), Colors.TRANSPARENT.hexValue, false,
pose().last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
drawString(
this,
Component.nullToEmpty(name.string),
(x + 5).toInt(), (y + 2).toInt(),
ARGB.opaque(Colors.TRANSPARENT.hexValue), false
)
}
}

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,13 +3,19 @@ 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, scaleFactor)
guiGraphics.drawString(Minecraft.getInstance().font, text, (x / scaleFactor).toInt(), (y / scaleFactor).toInt(), color.hexValue, false)
stack.scale(scaleFactor, scaleFactor, Matrix3x2f())
guiGraphics.drawString(
Minecraft.getInstance().font, text,
(x / scaleFactor).toInt(), (y / scaleFactor).toInt(),
ARGB.opaque(color.hexValue), false
)
val factorToOriginal = 1F / scaleFactor
stack.scale(factorToOriginal, factorToOriginal, factorToOriginal)
stack.scale(factorToOriginal, factorToOriginal, Matrix3x2f())
}
}

View File

@ -1,7 +1,5 @@
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
@ -15,17 +13,16 @@ 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 java.util.OptionalInt
import org.joml.Vector4f
import java.util.OptionalDouble
import java.util.OptionalInt
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() {
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
}
fun colorShader() {}
fun prepareDraw() {
colorShader()
GlStateManager._enableBlend()
@ -45,6 +42,13 @@ 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,
@ -58,14 +62,15 @@ object RenderingUtil {
builder.buildOrThrow().use { meshData ->
val encoder = RenderSystem.getDevice().createCommandEncoder() as GlCommandEncoder
encoder.createRenderPass(
renderTarget.colorTexture!!,
{ name },
renderTarget.colorTextureView!!,
OptionalInt.empty(),
renderTarget.depthTexture,
renderTarget.depthTextureView!!,
OptionalDouble.empty()
).use { renderPass ->
encoder.inRenderPass = false;
RenderSystem.getDevice().createBuffer(
{ name }, BufferType.VERTICES, BufferUsage.DYNAMIC_WRITE, meshData.vertexBuffer()
{ name }, 40, meshData.vertexBuffer()
).use { buffer ->
val autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(mode)
renderPass.setPipeline(renderPipeline)
@ -74,8 +79,13 @@ object RenderingUtil {
autoStorageIndexBuffer.getBuffer(meshData.drawState().indexCount()),
autoStorageIndexBuffer.type()
)
// RenderSystem.bindDefaultUniforms(renderPass)
renderPass.setUniform(
"DynamicTransforms",
gpuSlice
)
uniformAndSamplerConsumer?.invoke(renderPass)
renderPass.drawIndexed(0, meshData.drawState().indexCount())
renderPass.drawIndexed(0, 0, meshData.drawState().indexCount(), 1)
}
encoder.inRenderPass = false;
}

View File

@ -3,7 +3,5 @@ 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:+UseShenandoahGC -XX:+AlwaysPreTouch
org.gradle.jvmargs=-Xmx2G -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -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.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
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

View File

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