Skip to content

Commit

Permalink
Port to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Dec 9, 2024
1 parent 57be47d commit 3c6c32e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
mc_modern = "1.21.3"
mc_modern = "1.21.4"
mc_legacy = "1.8.9"
mcp = "22-1.8.9"
forge_loader = "11.15.1.2318-1.8.9"
fabric_loader = "0.16.9"
fabric_api = "0.107.0+1.21.3"
yarn_build = "2"
fabric_api = "0.111.0+1.21.4"
yarn_build = "1"
lombok = "1.18.32"
jbAnnotations = "24.0.1"
kotlin = "2.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.github.notenoughupdates.moulconfig.common.RenderContext.TextureFilter
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gl.ShaderProgramKeys
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.gui.ScreenRect
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.RenderPhase
import net.minecraft.client.render.VertexFormat
Expand All @@ -18,12 +19,11 @@ import net.minecraft.client.texture.NativeImageBackedTexture
import net.minecraft.client.util.InputUtil
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import net.minecraft.util.TriState
import net.minecraft.util.Util
import org.joml.Matrix4f
import org.lwjgl.glfw.GLFW
import org.lwjgl.opengl.GL11
import java.awt.image.BufferedImage
import java.util.concurrent.ThreadLocalRandom

class ModernRenderContext(val drawContext: DrawContext) : RenderContext {
companion object {
Expand Down Expand Up @@ -79,19 +79,19 @@ class ModernRenderContext(val drawContext: DrawContext) : RenderContext {
val texture = NativeImageBackedTexture(img.width, img.height, true)
texture.setData(img)
texture.upload()
val res = MinecraftClient.getInstance().textureManager
.registerDynamicTexture("moulconfig", texture)
val id = Identifier.of("moulconfig", "dynamic/${ThreadLocalRandom.current().nextLong()}")
MinecraftClient.getInstance().textureManager.registerTexture(id, texture)
return object : DynamicTextureReference() {
override fun update(bufferedImage: BufferedImage) {
texture.setData(img)
texture.upload()
}

override val identifier: MyResourceLocation
get() = ModernMinecraft.fromIdentifier(res)
get() = ModernMinecraft.fromIdentifier(id)

override fun doDestroy() {
MinecraftClient.getInstance().textureManager.destroyTexture(res)
MinecraftClient.getInstance().textureManager.destroyTexture(id)
}
}
}
Expand Down Expand Up @@ -247,7 +247,10 @@ class ModernRenderContext(val drawContext: DrawContext) : RenderContext {
}

override fun pushScissor(left: Int, top: Int, right: Int, bottom: Int) {
drawContext.enableScissor(left, top, right, bottom)
// Do not use drawContext.enableScissor() since that transform coords
// In order to be compatible with 1.8.9, this method does not do that.
drawContext.scissorStack.push(ScreenRect(left, top, right - left, bottom - top))
refreshScissor()
}

override fun popScissor() {
Expand Down

0 comments on commit 3c6c32e

Please sign in to comment.