Compare commits

..

3 Commits
1.21.5 ... 1.21

Author SHA1 Message Date
46791002e4
Bump version to 0.3.6
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-04-16 21:08:13 +02:00
a09e2c389a
Fix my stupid configuration system
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-04-16 21:08:12 +02:00
ff7c473ecb
Fix the mod on neoforge 1.21.5 by notably using the mod loader configuration directories
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2025-04-16 21:07:47 +02:00
10 changed files with 54 additions and 104 deletions

View File

@ -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.10-SNAPSHOT" apply false
id("dev.architectury.loom") version "1.9-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"
@ -38,7 +38,6 @@ 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()
@ -57,7 +56,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:2024.06.23")
}
val refmap = "snowygui-${project.name}-refmap.json"
mixin {
@ -168,16 +167,14 @@ subprojects {
mergeinterfacesaggressively()
}
withType(net.fabricmc.loom.task.RemapJarTask::class) {
if (!devBuild) {
dependsOn(shrinkJar)
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
inputFile.set(shrinkedJar)
} else inputFile.set(shadowJar.archiveFile)
dependsOn(shrinkJar)
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
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)
@ -245,7 +242,7 @@ allprojects {
"forge_version" to rootProject.property("forge_version")
)
inputs.properties(modProperties)
filesNotMatching(listOf("*.png", "*.accessWidener")) {
filesNotMatching(listOf("*.png")) {
expand(modProperties)
}
}

View File

@ -49,9 +49,9 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
startBooleanToggle(translatable("$confPrefix.behavior.sortalphabetically"), sortAlphabetically)
.setDefaultValue(true).requireRestart()
.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
}.setMin(1.1F).build(),
}.setMin(1.1).build(),
startBooleanToggle(translatable("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer {
Zoom.smoothCameraOnZoom = it
Zoom.execAction()

View File

@ -1,5 +1,8 @@
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
@ -9,12 +12,11 @@ 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.renderBufferWithPipeline
import fr.username404.snowygui.utils.RenderingUtil.tessellator
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
@ -80,26 +82,25 @@ class ClickBox(
val y = y.toFloat()
val currentHeight = y + (height + clickboxHeightOffset)
prepareDraw()
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_TRIANGLE_FAN) {
with(tessellator.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR)) {
// 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()
addVertex(x, y + height, 0.0F).colorEnd()
}
BufferUploader.drawWithShader(buildOrThrow())
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_LINE_STRIP) {
colorShader()
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
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())
}
}
endDraw()
@ -119,9 +120,9 @@ class ClickBox(
}
guiGraphics?.run {
with(Minecraft.getInstance().font) {
drawInBatch(Component.nullToEmpty(name.string),
drawInBatch(name.string,
(x + 5), (y + 2), Colors.TRANSPARENT.hexValue, false,
pose().last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
pose().last().pose(), bufferSource(), Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
)
}
}

View File

@ -6,9 +6,9 @@ import net.minecraft.client.Minecraft
@ButtonInfo(Category.MISC, shouldSave = false)
object Zoom: ButtonImpl() {
var smoothCameraOnZoom: Boolean by Configuration
var zoomFactor: Float by Configuration
var zoomFactor: Double by Configuration
@JvmStatic
fun getNewZoom(fov: Float): Float = fov / zoomFactor
fun getNewZoom(fov: Double): Double = fov / zoomFactor
public override fun execAction() {
Minecraft.getInstance().options.smoothCamera = toggled && smoothCameraOnZoom
}

View File

@ -1,84 +1,43 @@
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.BufferBuilder
import com.mojang.blaze3d.vertex.BufferUploader
import com.mojang.blaze3d.vertex.DefaultVertexFormat
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.Minecraft
import net.minecraft.client.renderer.RenderPipelines
import java.util.OptionalInt
import java.util.OptionalDouble
import net.minecraft.client.renderer.GameRenderer
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(GameRenderer::getPositionColorShader)
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
}
fun prepareDraw() {
colorShader()
GlStateManager._enableBlend()
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
}
fun endDraw() {
GlStateManager._disableBlend()
RenderSystem.disableBlend()
}
fun drawRectangle(
x: Double, y: Double, height: Int, width: Int,
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
): Unit = renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_QUADS) {
): Unit = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR).run {
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()
}
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;
}
}
BufferUploader.drawWithShader(buildOrThrow())
}
}

View File

@ -1,9 +1,3 @@
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
mutable field net/minecraft/client/OptionInstance value Ljava/lang/Object;

View File

@ -4,17 +4,16 @@ import fr.username404.snowygui.ClickGui;
import fr.username404.snowygui.gui.feature.ButtonImpl;
import net.minecraft.client.gui.screens.TitleScreen;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class)
abstract class TitleScreenMixin {
@Unique private static boolean buttonsInitialized = false;
@Unique private static synchronized void setButtonsInitialized() { buttonsInitialized = true; }
private static boolean buttonsInitialized = false;
private static synchronized void setButtonsInitialized() { buttonsInitialized = true; }
@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) {
ClickGui.INSTANCE.tick();
ButtonImpl.initButtons();

View File

@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(GameRenderer.class)
abstract class ZoomMixin {
@Inject(at = @At(value = "RETURN"), method = "getFov(Lnet/minecraft/client/Camera;FZ)F", cancellable = true)
private void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Float> cir) {
@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<Double> cir) {
if (Zoom.INSTANCE.getToggled() && !OkZoomerCompatKt.isOkZoomerPresent) {
cir.setReturnValue(Zoom.getNewZoom(cir.getReturnValue()));
}

View File

@ -7,16 +7,16 @@ 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
minecraft=1.21
forge_version=21.0.143
kotlinforforge=5.4.0
kotlinVer=2.0.0
kotlin_coroutines_version=1.7.1
serializationVer=1.7.0
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
fabric_language_kotlin=1.11.0+kotlin.2.0.0
fabric_resource_loader_version=1.1.3+b559734490
fabric_rendering_api_version=5.0.3+d132107690
fabric_api_base_version=0.4.42+6573ed8c90
clothconfig_version=15.0.127
modmenu_version=11.0.0

View File

@ -7,6 +7,6 @@ import net.neoforged.neoforge.client.event.ComputeFovModifierEvent
object ZoomHandler {
@SubscribeEvent
fun onFOVEvent(event: ComputeFovModifierEvent) {
if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier)
if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier.toDouble()).toFloat()
}
}