Skip to content

Commit 1064d02

Browse files
Version 1.3.5.10
1 parent f71efa3 commit 1064d02

File tree

138 files changed

+2639
-1207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2639
-1207
lines changed

api/api/api.api

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,13 @@ public abstract interface class gg/essential/api/utils/GuiUtil {
423423
public abstract fun openScreen (Lnet/minecraft/client/gui/screens/Screen;)V
424424
@1.17.1-forge,1.18.2-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
425425
public abstract fun openedScreen ()Lnet/minecraft/client/gui/screens/Screen;
426-
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric
426+
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric
427427
public static fun getOpenedScreen ()Lnet/minecraft/client/gui/screen/Screen;
428-
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric
428+
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric
429429
public static fun open (Lnet/minecraft/client/gui/screen/Screen;)V
430-
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric
430+
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric
431431
public abstract fun openScreen (Lnet/minecraft/client/gui/screen/Screen;)V
432-
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric
432+
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric
433433
public abstract fun openedScreen ()Lnet/minecraft/client/gui/screen/Screen;
434434
@1.12.2-forge,1.8.9-forge
435435
public static fun getOpenedScreen ()Lnet/minecraft/client/gui/GuiScreen;
@@ -446,9 +446,9 @@ public final class gg/essential/api/utils/GuiUtil$Companion {
446446
public final fun getOpenedScreen ()Lnet/minecraft/client/gui/screens/Screen;
447447
@1.17.1-forge,1.18.2-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
448448
public final fun open (Lnet/minecraft/client/gui/screens/Screen;)V
449-
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric
449+
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric
450450
public final fun getOpenedScreen ()Lnet/minecraft/client/gui/screen/Screen;
451-
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric
451+
@1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric
452452
public final fun open (Lnet/minecraft/client/gui/screen/Screen;)V
453453
@1.12.2-forge,1.8.9-forge
454454
public final fun getOpenedScreen ()Lnet/minecraft/client/gui/GuiScreen;
@@ -512,14 +512,15 @@ public final class gg/essential/api/utils/KotlinAdapter : net/minecraftforge/fml
512512
public abstract interface class gg/essential/api/utils/MinecraftUtils {
513513
@1.17.1-forge,1.18.2-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
514514
public abstract fun getResourceImage (Lnet/minecraft/resources/ResourceLocation;)Ljava/awt/image/BufferedImage;
515-
@1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric
515+
@1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.18.2-fabric,1.19-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric
516516
public abstract fun getResourceImage (Lnet/minecraft/util/Identifier;)Ljava/awt/image/BufferedImage;
517517
@1.12.2-forge,1.16.2-forge,1.8.9-forge
518518
public abstract fun getResourceImage (Lnet/minecraft/util/ResourceLocation;)Ljava/awt/image/BufferedImage;
519519
public abstract fun isDevelopment ()Z
520520
public abstract fun isHypixel ()Z
521521
public abstract fun sendChatMessageAndFormat (Ljava/lang/String;)V
522522
public abstract fun sendChatMessageAndFormat (Ljava/lang/String;[Ljava/lang/Object;)V
523+
@1.12.2-forge,1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.17.1-forge,1.18.1-fabric,1.18.2-fabric,1.18.2-forge,1.19-fabric,1.19.2-fabric,1.19.2-forge,1.19.3-fabric,1.19.3-forge,1.19.4-fabric,1.19.4-forge,1.20-fabric,1.20.1-fabric,1.20.1-forge,1.20.2-fabric,1.20.2-forge,1.20.4-fabric,1.20.4-forge,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.8.9-forge
523524
public abstract fun sendMessage (Lgg/essential/universal/wrappers/message/UTextComponent;)V
524525
public abstract fun sendMessage (Ljava/lang/String;)V
525526
public abstract fun sendMessage (Ljava/lang/String;Ljava/lang/String;)V

api/src/main/kotlin/gg/essential/api/utils/MinecraftUtils.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212
package gg.essential.api.utils
1313

14-
import gg.essential.universal.wrappers.message.UTextComponent
1514
import net.minecraft.util.ResourceLocation
1615
import java.awt.image.BufferedImage
1716

@@ -23,7 +22,10 @@ interface MinecraftUtils {
2322
/**
2423
* Queues a message component to be displayed to the player in chat, client-side only.
2524
*/
26-
fun sendMessage(message: UTextComponent)
25+
//#if MC<12105
26+
@Deprecated("Use `UChat.chat` instead.")
27+
fun sendMessage(message: gg.essential.universal.wrappers.message.UTextComponent)
28+
//#endif
2729

2830
/**
2931
* Queues a message to be displayed to the player in chat, client-side only. The input message is also

build-logic/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies {
3737
implementation ("com.google.guava:guava:30.1.1-jre")
3838

3939
implementation("gg.essential:essential-gradle-toolkit:0.6.6")
40+
implementation("gg.essential.loom:gg.essential.loom.gradle.plugin:1.7.25") // TODO remove once EGT has updated
4041
}
4142

4243
gradlePlugin {

build-logic/src/main/kotlin/essential/preprocessor.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fun Project.configurePreprocessTree(versions: File) {
2020
configure<RootPreprocessExtension> {
2121
strictExtraMappings.set(true)
2222

23+
val fabric12105 = createNode("1.21.5-fabric", 12105, "yarn")
2324
val fabric12104 = createNode("1.21.4-fabric", 12104, "yarn")
2425
val fabric12103 = createNode("1.21.3-fabric", 12103, "yarn")
2526
val fabric12100 = createNode("1.21-fabric", 12100, "yarn")
@@ -48,6 +49,7 @@ fun Project.configurePreprocessTree(versions: File) {
4849
val forge11202 = createNode("1.12.2-forge", 11202, "srg")
4950
val forge10809 = createNode("1.8.9-forge", 10809, "srg")
5051

52+
fabric12105.link(fabric12104)
5153
fabric12104.link(fabric12103, versions.resolve("1.21.4-1.21.3.txt"))
5254
fabric12103.link(fabric12100)
5355
fabric12100.link(fabric12006)

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ dependencies {
120120
12100 -> "0.99.2+1.21"
121121
12103 -> "0.106.0+1.21.2"
122122
12104 -> "0.110.0+1.21.4"
123+
12105 -> "0.119.0+1.21.5"
123124
else -> error("No fabric API version configured!")
124125
}
125126
include(modImplementation(fabricApi.module("fabric-api-base", fapiVersion))!!)

changelog/release-1.3.5.10.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Title: Bug Patch
2+
Summary: Minor bug fixes
3+
4+
## New Versions
5+
- Added support for 1.21.5 Fabric
6+
7+
## Bug Fixes
8+
- Fixed crash when servers send invalid player skin textures on Minecraft versions older than 1.20.2
9+
- Fixed first person visuals of some cosmetics and emotes
10+
- Fixed some emote animations unintentionally affecting first person hands in 1.21.2 and above
11+
- Fixed some cosmetics with left/right side options showing particles for both sides at the same time
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* Copyright (c) 2024 ModCore Inc. All rights reserved.
3+
*
4+
* This code is part of ModCore Inc.'s Essential Mod repository and is protected
5+
* under copyright registration # TX0009138511. For the full license, see:
6+
* https://github.com/EssentialGG/Essential/blob/main/LICENSE
7+
*
8+
* You may not use, copy, reproduce, modify, sell, license, distribute,
9+
* commercialize, or otherwise exploit, or create derivative works based
10+
* upon, this file or any other in this repository, all of which is reserved by Essential.
11+
*/
12+
package gg.essential.gui.common.constraints
13+
14+
import gg.essential.elementa.UIComponent
15+
import gg.essential.elementa.constraints.ConstraintType
16+
import gg.essential.elementa.constraints.PaddingConstraint
17+
import gg.essential.elementa.constraints.PositionConstraint
18+
import gg.essential.elementa.constraints.resolution.ConstraintVisitor
19+
import gg.essential.elementa.utils.ObservableAddEvent
20+
import gg.essential.elementa.utils.ObservableClearEvent
21+
import gg.essential.elementa.utils.ObservableListEvent
22+
import gg.essential.elementa.utils.ObservableRemoveEvent
23+
import gg.essential.elementa.utils.roundToRealPixels
24+
import gg.essential.gui.layoutdsl.Alignment
25+
import gg.essential.gui.layoutdsl.Arrangement
26+
import kotlin.math.max
27+
28+
class FlowLayoutController(
29+
private val component: UIComponent,
30+
/** Minimum spacing allocated between items in each row. Actual spacing is determined by [itemArrangement]. */
31+
private val xSpacingMin: Float,
32+
/** Spacing between rows. */
33+
private val ySpacing: Float,
34+
/** Arranges items in a row */
35+
private val itemArrangement: Arrangement,
36+
/** Aligns items vertically within a row */
37+
private val itemAlignment: Alignment,
38+
) {
39+
internal var recalculate = true
40+
41+
class Layout(var x: Float, var y: Float, var yPadding: Float)
42+
private val cachedLayout = mutableMapOf<UIComponent, Layout>()
43+
44+
fun getLayout(component: UIComponent): Layout {
45+
if (recalculate) {
46+
layout()
47+
recalculate = false
48+
}
49+
return cachedLayout[component]
50+
?: error("Component $component's position was not laid out by $this")
51+
}
52+
53+
private fun layout() {
54+
val containerWidth = component.getWidth()
55+
56+
class Row(val startIndex: Int, override val size: Int, val maxHeight: Float) : AbstractList<Float>() {
57+
override fun get(index: Int): Float = component.children[startIndex + index].getWidth()
58+
}
59+
val rows = sequence {
60+
val spacing = xSpacingMin.roundToRealPixels()
61+
var startIndex = 0
62+
var size = 0
63+
var currentWidth = -spacing
64+
var maxHeight = 0f
65+
for ((index, child) in component.children.withIndex()) {
66+
val childWidth = child.getWidth()
67+
if (currentWidth + spacing + childWidth > containerWidth + EPSILON && size > 0) {
68+
yield(Row(startIndex, size, maxHeight))
69+
startIndex = index
70+
size = 0
71+
currentWidth = -spacing
72+
maxHeight = 0f
73+
}
74+
size++
75+
currentWidth += spacing + childWidth
76+
maxHeight = max(maxHeight, child.getHeight())
77+
}
78+
if (size > 0) {
79+
yield(Row(startIndex, size, maxHeight))
80+
}
81+
}
82+
83+
var y = 0f
84+
for ((rowIndex, row) in rows.withIndex()) {
85+
itemArrangement.arrange(containerWidth, row) { i, x ->
86+
val child = component.children[row.startIndex + i]
87+
val height = child.getHeight()
88+
cachedLayout[child] = Layout(
89+
x = x,
90+
y = y + itemAlignment.align(row.maxHeight, height),
91+
// This allows ChildBasedSizeConstraint to function for the parent height by emitting negative
92+
// padding for all but the first item in a row
93+
yPadding = (if (i == 0) row.maxHeight + (if (rowIndex == 0) 0f else ySpacing) else 0f) - height,
94+
)
95+
}
96+
y += row.maxHeight + ySpacing
97+
}
98+
}
99+
100+
init {
101+
component.children.forEach(::applyConstraints)
102+
component.children.addObserver { _, maybeEvent ->
103+
@Suppress("UNCHECKED_CAST")
104+
val event = maybeEvent as? ObservableListEvent<UIComponent> ?: return@addObserver
105+
recalculate = true
106+
when (event) {
107+
is ObservableAddEvent -> applyConstraints(event.element.value)
108+
is ObservableRemoveEvent -> cachedLayout.remove(event.element.value)
109+
is ObservableClearEvent -> cachedLayout.clear()
110+
}
111+
}
112+
}
113+
114+
private fun applyConstraints(child: UIComponent) {
115+
child.setX(FlowLayoutControlledPositionConstraint())
116+
child.setY(FlowLayoutControlledPositionConstraint())
117+
}
118+
119+
private inner class FlowLayoutControlledPositionConstraint : PositionConstraint, PaddingConstraint {
120+
override var cachedValue = 0f
121+
override var recalculate = true
122+
set(value) {
123+
field = value
124+
if (value) {
125+
this@FlowLayoutController.recalculate = true
126+
}
127+
}
128+
129+
override fun getXPositionImpl(component: UIComponent) = component.parent.getLeft() + getLayout(component).x
130+
override fun getYPositionImpl(component: UIComponent) = component.parent.getTop() + getLayout(component).y
131+
override fun getHorizontalPadding(component: UIComponent): Float = 0f
132+
override fun getVerticalPadding(component: UIComponent): Float = getLayout(component).yPadding
133+
134+
override var constrainTo: UIComponent?
135+
get() = null
136+
set(_) = throw UnsupportedOperationException()
137+
138+
override fun visitImpl(visitor: ConstraintVisitor, type: ConstraintType) {}
139+
}
140+
141+
companion object {
142+
private const val EPSILON = 0.01f
143+
}
144+
}

elementa/layoutdsl/src/main/kotlin/gg/essential/gui/common/constraints/SpacedCramSiblingConstraint.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import gg.essential.elementa.constraints.resolution.ConstraintVisitor
2020
/**
2121
* Note: All items are assumed to be same width
2222
*/
23+
@Deprecated("Apply FlowLayoutController on container instead.")
2324
class SpacedCramSiblingConstraint(
2425
private val minSeparation: WidthConstraint,
2526
private val margin: WidthConstraint,

elementa/layoutdsl/src/main/kotlin/gg/essential/gui/effects/AlphaEffect.kt

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import gg.essential.elementa.state.State
1616
import gg.essential.universal.UGraphics
1717
import gg.essential.universal.UMatrixStack
1818
import gg.essential.universal.UResolution
19+
import gg.essential.universal.render.URenderPipeline
1920
import gg.essential.universal.shader.BlendState
20-
import gg.essential.universal.shader.SamplerUniform
21-
import gg.essential.universal.shader.UShader
21+
import gg.essential.universal.vertex.UBufferBuilder
2222
import org.lwjgl.opengl.GL11
2323
import java.io.Closeable
2424
import java.lang.ref.PhantomReference
@@ -37,7 +37,6 @@ class AlphaEffect(private val alphaState: State<Float>) : Effect() {
3737
private var textureHeight = -1
3838

3939
override fun setup() {
40-
initShader()
4140
Resources.drainCleanupQueue()
4241
resources.textureId = GL11.glGenTextures()
4342
}
@@ -58,7 +57,7 @@ class AlphaEffect(private val alphaState: State<Float>) : Effect() {
5857
val width = right - left
5958
val height = bottom - top
6059

61-
if (width == 0 || height == 0 || !shader.usable) {
60+
if (width == 0 || height == 0) {
6261
return
6362
}
6463

@@ -87,7 +86,7 @@ class AlphaEffect(private val alphaState: State<Float>) : Effect() {
8786
val width = right - left
8887
val height = bottom - top
8988

90-
if (width == 0.0 || height == 0.0 || !shader.usable) {
89+
if (width == 0.0 || height == 0.0) {
9190
return
9291
}
9392

@@ -96,29 +95,13 @@ class AlphaEffect(private val alphaState: State<Float>) : Effect() {
9695
val blue = 1f
9796
val alpha = 1f - alphaState.get()
9897

99-
var prevAlphaTestFunc = 0
100-
var prevAlphaTestRef = 0f
101-
if (!UGraphics.isCoreProfile()) {
102-
prevAlphaTestFunc = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC)
103-
prevAlphaTestRef = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF)
104-
UGraphics.alphaFunc(GL11.GL_ALWAYS, 0f)
105-
}
106-
107-
shader.bind()
108-
textureUniform.setValue(resources.textureId)
109-
110-
val worldRenderer = UGraphics.getFromTessellator()
111-
worldRenderer.beginWithActiveShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_TEXTURE_COLOR)
98+
val worldRenderer = UBufferBuilder.create(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_TEXTURE_COLOR)
11299
worldRenderer.pos(matrixStack, x, y + height, 0.0).tex(0.0, 0.0).color(red, green, blue, alpha).endVertex()
113100
worldRenderer.pos(matrixStack, x + width, y + height, 0.0).tex(1.0, 0.0).color(red, green, blue, alpha).endVertex()
114101
worldRenderer.pos(matrixStack, x + width, y, 0.0).tex(1.0, 1.0).color(red, green, blue, alpha).endVertex()
115102
worldRenderer.pos(matrixStack, x, y, 0.0).tex(0.0, 1.0).color(red, green, blue, alpha).endVertex()
116-
worldRenderer.drawDirect()
117-
118-
shader.unbind()
119-
120-
if (!UGraphics.isCoreProfile()) {
121-
UGraphics.alphaFunc(prevAlphaTestFunc, prevAlphaTestRef)
103+
worldRenderer.build()?.drawAndClose(PIPELINE) {
104+
texture("u_Texture", resources.textureId)
122105
}
123106
}
124107

@@ -155,13 +138,9 @@ class AlphaEffect(private val alphaState: State<Float>) : Effect() {
155138
}
156139

157140
companion object {
158-
private lateinit var shader: UShader
159-
private lateinit var textureUniform: SamplerUniform
160-
161-
private fun initShader() {
162-
if (::shader.isInitialized) return
163-
164-
shader = UShader.fromLegacyShader("""
141+
private val PIPELINE: URenderPipeline
142+
init {
143+
val vertexShaderSource = """
165144
#version 110
166145
167146
varying vec2 f_Position;
@@ -174,7 +153,8 @@ class AlphaEffect(private val alphaState: State<Float>) : Effect() {
174153
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
175154
gl_FrontColor = gl_Color;
176155
}
177-
""".trimIndent(), """
156+
""".trimIndent()
157+
val fragmentShaderSource = """
178158
#version 110
179159
180160
uniform sampler2D u_Texture;
@@ -185,14 +165,16 @@ class AlphaEffect(private val alphaState: State<Float>) : Effect() {
185165
void main() {
186166
gl_FragColor = gl_Color * vec4(texture2D(u_Texture, f_TexCoord).rgb, 1.0);
187167
}
188-
""".trimIndent(), BlendState.NORMAL, UGraphics.CommonVertexFormats.POSITION_TEXTURE_COLOR)
189-
190-
if (!shader.usable) {
191-
println("Failed to load AlphaEffect shader")
192-
return
193-
}
194-
195-
textureUniform = shader.getSamplerUniform("u_Texture")
168+
""".trimIndent()
169+
PIPELINE = URenderPipeline.builderWithLegacyShader(
170+
"elementa:alpha_effect",
171+
UGraphics.DrawMode.QUADS,
172+
UGraphics.CommonVertexFormats.POSITION_TEXTURE_COLOR,
173+
vertexShaderSource,
174+
fragmentShaderSource,
175+
).apply {
176+
blendState = BlendState.NORMAL
177+
}.build()
196178
}
197179
}
198180
}

0 commit comments

Comments
 (0)