Update to minecraft 1.17
This commit is contained in:
parent
cc97418155
commit
961e67644b
|
@ -1,7 +1,6 @@
|
|||
package fr.username404.snowygui.gui
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer
|
||||
import com.mojang.blaze3d.vertex.*
|
||||
import fr.username404.snowygui.Snowy
|
||||
import fr.username404.snowygui.gui.feature.Colors
|
||||
import fr.username404.snowygui.utils.RenderingUtil
|
||||
|
@ -14,7 +13,7 @@ fun interface Renderable {
|
|||
|
||||
abstract class Element(
|
||||
@JvmField val xOrigin: Double, @JvmField val yOrigin: Double,
|
||||
@JvmField val originalWidth: Int, @JvmField val originalHeight: Int
|
||||
val originalWidth: Int, val originalHeight: Int
|
||||
): Renderable, GuiEventListener {
|
||||
open var width = originalWidth; open var height = originalHeight
|
||||
open var x = xOrigin; open var y = yOrigin
|
||||
|
@ -22,6 +21,11 @@ abstract class Element(
|
|||
(coordinateX in x..(x + width + offsetWidth)) && (coordinateY in y..(y + height + offsetHeight))
|
||||
companion object {
|
||||
private var caughtError: Boolean = false
|
||||
fun fromRenderable(r: Renderable, x: Double, y: Double, width: Int, height: Int): Element {
|
||||
return object: Element(x, y, width, height) {
|
||||
override fun render(poseStack: PoseStack?) = r.render(poseStack)
|
||||
}
|
||||
}
|
||||
}
|
||||
open fun display(stack: PoseStack? = null) {
|
||||
if (!hidden && !caughtError) try {
|
||||
|
@ -42,7 +46,14 @@ abstract class ColoredElement(
|
|||
x: Double, y: Double, width: Int, height: Int,
|
||||
open val color: Int = Colors.TRANSPARENT.hexValue, protected var opacity: Float,
|
||||
) : Element(x, y, width, height) {
|
||||
protected fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color) = colorEnd(color, opacity)
|
||||
companion object {
|
||||
@JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer {
|
||||
with(hextoRGB(color)) {
|
||||
return this@colorIt.color(get(0), get(1), get(2), opacity)
|
||||
}
|
||||
}
|
||||
}
|
||||
internal fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color) = colorEnd(color, opacity)
|
||||
protected fun defaultRectFunc() = RenderingUtil.drawRectangle(x, y, height, width, color, opacity)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,13 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
|||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||
import fr.username404.snowygui.config.Configuration
|
||||
import com.mojang.blaze3d.vertex.VertexFormat
|
||||
import fr.username404.snowygui.gui.ColoredElement
|
||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||
import fr.username404.snowygui.gui.feature.Category
|
||||
import fr.username404.snowygui.gui.feature.Colors
|
||||
import fr.username404.snowygui.utils.RenderingUtil.buffer
|
||||
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
|
||||
|
@ -19,7 +21,6 @@ import kotlinx.coroutines.runBlocking
|
|||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.lwjgl.opengl.GL20
|
||||
import java.util.TreeSet
|
||||
import kotlin.collections.LinkedHashSet
|
||||
|
||||
|
@ -48,7 +49,7 @@ class ClickBox(
|
|||
override val color: Int get() = this@ClickBox.color
|
||||
override fun render(poseStack: PoseStack?) {
|
||||
prepareDraw()
|
||||
defaultRectFunc()
|
||||
colorShader(); defaultRectFunc()
|
||||
endDraw()
|
||||
}
|
||||
init { height = 8 }
|
||||
|
@ -82,7 +83,7 @@ class ClickBox(
|
|||
runBlocking {
|
||||
prepareDraw()
|
||||
with(buffer) {
|
||||
begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR)
|
||||
begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR)
|
||||
// Render the header:
|
||||
vertex(x, y + height, 0.0).colorEnd()
|
||||
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||
|
@ -96,7 +97,8 @@ class ClickBox(
|
|||
vertex(x + width + inclination, y + height, 0.0).colorEnd()
|
||||
tessellator.end()
|
||||
|
||||
begin(GL20.GL_LINES, DefaultVertexFormat.POSITION_COLOR)
|
||||
colorShader()
|
||||
begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR)
|
||||
vertex(x + inclination, y + height, 0.0).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
vertex(x + width, y + height, 0.0).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
tessellator.end()
|
||||
|
|
|
@ -9,6 +9,7 @@ import fr.username404.snowygui.utils.FontUtil
|
|||
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
||||
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.colorShader
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
|
||||
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||
|
@ -91,7 +92,7 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||
}
|
||||
final override fun render(poseStack: PoseStack?) {
|
||||
prepareDraw()
|
||||
defaultRectFunc()
|
||||
colorShader(); defaultRectFunc()
|
||||
endDraw()
|
||||
if (poseStack != null) {
|
||||
FontUtil.drawScaled(poseStack, title, x + 1, y + 1, 0.75F)
|
||||
|
|
|
@ -5,9 +5,10 @@ import com.mojang.blaze3d.vertex.BufferBuilder
|
|||
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 org.lwjgl.opengl.GL20
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
|
||||
object RenderingUtil {
|
||||
@JvmField val tessellator: Tesselator = Tesselator.getInstance()
|
||||
|
@ -17,7 +18,12 @@ object RenderingUtil {
|
|||
color(get(0), get(1), get(2), opacity)
|
||||
}
|
||||
fun VertexConsumer.colorEnd(color: Int, opacity: Float = 1F) = colorIt(color, opacity).endVertex()
|
||||
fun colorShader() {
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader)
|
||||
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
|
||||
}
|
||||
fun prepareDraw() {
|
||||
colorShader()
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
|
@ -31,7 +37,7 @@ object RenderingUtil {
|
|||
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
|
||||
): Unit = buffer.run {
|
||||
fun VertexConsumer.colorEnd() = colorEnd(color, opacity)
|
||||
begin(GL20.GL_QUADS, DefaultVertexFormat.POSITION_COLOR)
|
||||
begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
|
||||
vertex(x, y + height, 0.0).colorEnd()
|
||||
vertex(x + width, y + height, 0.0).colorEnd()
|
||||
vertex(x + width, y, 0.0).colorEnd()
|
||||
|
|
|
@ -23,7 +23,7 @@ side = "CLIENT"
|
|||
[[dependencies.snowygui]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[32,)"
|
||||
versionRange = "[37,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
|
|
|
@ -7,16 +7,16 @@ org.gradle.parallel=true
|
|||
org.gradle.unsafe.configuration-cache=on
|
||||
org.gradle.vfs.watch=true
|
||||
|
||||
minecraft=1.16.5
|
||||
forge_version=36.2
|
||||
minecraft=1.17
|
||||
forge_version=37.1
|
||||
kotlinforforge=1.17.0
|
||||
kotlinVer=1.6.0
|
||||
kotlin_coroutines_version=1.5.0
|
||||
serializationVer=1.3.1
|
||||
serializationVer=1.2.1
|
||||
fabric_loader_version=0.11.7
|
||||
fabric_language_kotlin=1.7.0+kotlin.1.6.0
|
||||
fabric_resource_loader_version=0.2.5+059ea8667c
|
||||
fabric_rendering_api_version=1.1.2+346247d77c
|
||||
fabric_api_base_version=0.1.3+12a8474c7c
|
||||
fabric_resource_loader_version=0.4.7+b7ab6121d5
|
||||
fabric_rendering_api_version=1.6.0+a02b4463d5
|
||||
fabric_api_base_version=0.3.0+a02b4463d5
|
||||
clothconfig_version=4.11.19
|
||||
modmenu_version=1.16.9
|
||||
modmenu_version=2.0.0-beta.7
|
||||
|
|
Loading…
Reference in New Issue