Skip to content

Commit 748bd38

Browse files
authored
fix: rendering methods for RC1 (#840)
* fix: rendering methods for RC1 * Update check_build.yml fix check_build.yml * Update check_build.yml v4 sertup-java * Update capture build artifacts version * Add 1.21.5 to CF versions * RC2 --------- Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> - Updated to 1.21.5
1 parent 627239a commit 748bd38

File tree

11 files changed

+101
-68
lines changed

11 files changed

+101
-68
lines changed

.github/workflows/check_build.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ jobs:
1111
strategy:
1212
matrix:
1313
# Use these Java versions
14-
java: [
15-
21, # Minimum
16-
]
17-
os: [ubuntu-22.04]
14+
java: [ 21 ]
15+
distro: [ temurin ]
16+
# and run on both Linux and Windows
17+
os: [ ubuntu-latest ]
1818
runs-on: ${{ matrix.os }}
1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
2424
- name: Validate Gradle wrapper
2525
uses: gradle/wrapper-validation-action@v1
2626
- name: Setup JDK ${{ matrix.java }}
27-
uses: actions/setup-java@v3
27+
uses: actions/setup-java@v4
2828
with:
29-
distribution: zulu
29+
distribution: ${{ matrix.distro }}
3030
java-version: ${{ matrix.java }}
3131
- name: Make Gradle wrapper executable
3232
if: ${{ runner.os != 'Windows' }}
3333
run: chmod +x ./gradlew
3434
- name: Build
3535
run: ./gradlew build --stacktrace --parallel
3636
- name: Capture build artifacts
37-
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from LTS java on one OS
37+
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from LTS java on one OS
3838
uses: actions/upload-artifact@v4
3939
with:
4040
name: Artifacts

gradle.properties

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx2G
33
maven_group=com.terraformersmc
44
archive_name=modmenu
55

6-
minecraft_version=25w10a
7-
yarn_mappings=25w10a+build.3
6+
minecraft_version=1.21.5-rc1
7+
yarn_mappings=1.21.5-rc1+build.2
88
loader_version=0.16.10
9-
fabric_version=0.118.4+1.21.5
10-
text_placeholder_api_version=2.5.2+1.21.3
11-
quilt_loader_version=0.28.0-beta.8
9+
fabric_version=0.119.2+1.21.5
10+
text_placeholder_api_version=2.6.0+1.21.5
11+
quilt_loader_version=0.28.1-beta.1
1212

1313
# Project Metadata
1414
project_name=Mod Menu
@@ -21,14 +21,14 @@ default_release_type=stable
2121
# Modrinth Metadata
2222
modrinth_slug=modmenu
2323
modrinth_id=mOgUt4GM
24-
modrinth_game_versions=25w09a, 25w09b, 25w10a
24+
modrinth_game_versions=1.21.5-rc1, 1.21.5-rc2, 1.21.5
2525
modrinth_mod_loaders=fabric, quilt
2626
modrinth_required_dependencies=fabric-api, placeholder-api
2727

2828
# CurseForge Metadata
2929
curseforge_slug=modmenu
3030
curseforge_id=308702
31-
curseforge_game_versions=1.21.5-Snapshot, Fabric, Quilt
31+
curseforge_game_versions=1.21.5-Snapshot, 1.21.5, Fabric, Quilt
3232
curseforge_required_dependencies=fabric-api, text-placeholder-api
3333
curseforge_optional_dependencies=
3434

gradle/wrapper/gradle-wrapper.jar

252 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -203,7 +205,7 @@ fi
203205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204206

205207
# Collect all arguments for the java command:
206-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207209
# and any embedded shellness will be escaped.
208210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209211
# treated as '${Hostname}' itself on the command line.

gradlew.bat

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.terraformersmc.modmenu.gui;
22

33
import com.google.common.base.Joiner;
4-
import com.mojang.blaze3d.platform.GlStateManager;
4+
import com.mojang.blaze3d.opengl.GlStateManager;
55
import com.mojang.blaze3d.systems.RenderSystem;
66
import com.terraformersmc.modmenu.ModMenu;
77
import com.terraformersmc.modmenu.config.ModMenuConfig;

src/main/java/com/terraformersmc/modmenu/gui/widget/DescriptionListWidget.java

+39-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.terraformersmc.modmenu.gui.widget;
22

3+
import com.mojang.blaze3d.buffers.BufferType;
4+
import com.mojang.blaze3d.buffers.BufferUsage;
5+
import com.mojang.blaze3d.buffers.GpuBuffer;
6+
import com.mojang.blaze3d.pipeline.RenderPipeline;
7+
import com.mojang.blaze3d.systems.RenderPass;
38
import com.mojang.blaze3d.systems.RenderSystem;
9+
import com.mojang.blaze3d.vertex.VertexFormat;
410
import com.terraformersmc.modmenu.api.UpdateInfo;
511
import com.terraformersmc.modmenu.config.ModMenuConfig;
612
import com.terraformersmc.modmenu.gui.ModsScreen;
@@ -18,6 +24,7 @@
1824
import net.minecraft.client.gui.widget.ElementListWidget;
1925
import net.minecraft.client.gui.widget.EntryListWidget;
2026
import net.minecraft.client.render.*;
27+
import net.minecraft.client.util.BufferAllocator;
2128
import net.minecraft.text.OrderedText;
2229
import net.minecraft.text.Text;
2330
import net.minecraft.util.Formatting;
@@ -275,30 +282,38 @@ public void renderList(DrawContext drawContext, int mouseX, int mouseY, float de
275282
super.renderList(drawContext, mouseX, mouseY, delta);
276283
drawContext.disableScissor();
277284

278-
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
279-
final int black = ColorHelper.fullAlpha(0);
280-
bufferBuilder.vertex(this.getX(), (this.getY() + 4), 0.0F).color(0);
281-
bufferBuilder.vertex(this.getRight(), (this.getY() + 4), 0.0F).color(0);
282-
bufferBuilder.vertex(this.getRight(), this.getY(), 0.0F).color(black);
283-
bufferBuilder.vertex(this.getX(), this.getY(), 0.0F).color(black);
284-
bufferBuilder.vertex(this.getX(), this.getBottom(), 0.0F).color(black);
285-
bufferBuilder.vertex(this.getRight(), this.getBottom(), 0.0F).color(black);
286-
bufferBuilder.vertex(this.getRight(), (this.getBottom() - 4), 0.0F).color(0);
287-
bufferBuilder.vertex(this.getX(), (this.getBottom() - 4), 0.0F).color(0);
288-
this.renderScrollBar(bufferBuilder);
289-
try (BuiltBuffer builtBuffer = bufferBuilder.end()) {
290-
VertexFormat.DrawMode drawMode = builtBuffer.getDrawParameters().mode();
291-
Framebuffer framebuffer = MinecraftClient.getInstance().getFramebuffer();
292-
try (RenderPass renderPass = RenderSystem.getDevice().getResourceManager().newRenderPass(framebuffer.getColorAttachment(), OptionalInt.empty(), framebuffer.getDepthAttachment(), OptionalDouble.empty());
293-
GpuBuffer gpuBuffer = RenderSystem.getDevice().createBuffer(() -> "Description List", GlBufferTarget.VERTICES, GlUsage.DYNAMIC_WRITE, 786432)) {
294-
RenderSystem.ShapeIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(drawMode);
295-
renderPass.bindShader(ShaderPipelines.GUI);
296-
renderPass.setVertexBuffer(0, gpuBuffer);
297-
renderPass.setIndexBuffer(autoStorageIndexBuffer.getIndexBuffer(builtBuffer.getDrawParameters().indexCount()), autoStorageIndexBuffer.getIndexType());
298-
RenderSystem.getDevice().getResourceManager().copyDataInto(gpuBuffer, builtBuffer.getBuffer(), 0);
299-
renderPass.drawObjects(0, builtBuffer.getDrawParameters().indexCount());
300-
}
301-
}
285+
RenderPipeline pipeline = RenderPipelines.GUI;
286+
try (BufferAllocator alloc = new BufferAllocator(pipeline.getVertexFormat().getVertexSize() * 4)) {
287+
BufferBuilder bufferBuilder = new BufferBuilder(alloc, pipeline.getVertexFormatMode(), pipeline.getVertexFormat());
288+
final int black = ColorHelper.fullAlpha(0);
289+
bufferBuilder.vertex(this.getX(), (this.getY() + 4), 0.0F).color(0);
290+
bufferBuilder.vertex(this.getRight(), (this.getY() + 4), 0.0F).color(0);
291+
bufferBuilder.vertex(this.getRight(), this.getY(), 0.0F).color(black);
292+
bufferBuilder.vertex(this.getX(), this.getY(), 0.0F).color(black);
293+
bufferBuilder.vertex(this.getX(), this.getBottom(), 0.0F).color(black);
294+
bufferBuilder.vertex(this.getRight(), this.getBottom(), 0.0F).color(black);
295+
bufferBuilder.vertex(this.getRight(), (this.getBottom() - 4), 0.0F).color(0);
296+
bufferBuilder.vertex(this.getX(), (this.getBottom() - 4), 0.0F).color(0);
297+
this.renderScrollBar(bufferBuilder);
298+
try (BuiltBuffer builtBuffer = bufferBuilder.endNullable()) {
299+
if (builtBuffer == null) {
300+
alloc.close();
301+
return;
302+
}
303+
Framebuffer framebuffer = MinecraftClient.getInstance().getFramebuffer();
304+
RenderSystem.ShapeIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(pipeline.getVertexFormatMode());
305+
VertexFormat.IndexType indexType = autoStorageIndexBuffer.getIndexType();
306+
GpuBuffer vertexBuffer = RenderSystem.getDevice().createBuffer(() -> "Description List", BufferType.VERTICES, BufferUsage.DYNAMIC_WRITE, builtBuffer.getBuffer().remaining());
307+
GpuBuffer indexBuffer = autoStorageIndexBuffer.getIndexBuffer(builtBuffer.getDrawParameters().indexCount());
308+
RenderSystem.getDevice().createCommandEncoder().writeToBuffer(vertexBuffer, builtBuffer.getBuffer(), 0);
309+
try (RenderPass renderPass = RenderSystem.getDevice().createCommandEncoder().createRenderPass(framebuffer.getColorAttachment(), OptionalInt.empty(), framebuffer.getDepthAttachment(), OptionalDouble.empty())) {
310+
renderPass.setPipeline(pipeline);
311+
renderPass.setVertexBuffer(0, vertexBuffer);
312+
renderPass.setIndexBuffer(indexBuffer, indexType);
313+
renderPass.drawIndexed(0, builtBuffer.getDrawParameters().indexCount());
314+
}
315+
}
316+
}
302317
}
303318

304319
public void renderScrollBar(BufferBuilder bufferBuilder) {

src/main/java/com/terraformersmc/modmenu/gui/widget/ModListWidget.java

+37-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.terraformersmc.modmenu.gui.widget;
22

3+
import com.mojang.blaze3d.buffers.BufferType;
4+
import com.mojang.blaze3d.buffers.BufferUsage;
5+
import com.mojang.blaze3d.buffers.GpuBuffer;
6+
import com.mojang.blaze3d.pipeline.RenderPipeline;
7+
import com.mojang.blaze3d.systems.RenderPass;
38
import com.mojang.blaze3d.systems.RenderSystem;
9+
import com.mojang.blaze3d.vertex.VertexFormat;
410
import com.terraformersmc.modmenu.ModMenu;
511
import com.terraformersmc.modmenu.config.ModMenuConfig;
612
import com.terraformersmc.modmenu.gui.ModsScreen;
@@ -16,6 +22,7 @@
1622
import net.minecraft.client.gui.DrawContext;
1723
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
1824
import net.minecraft.client.render.*;
25+
import net.minecraft.client.util.BufferAllocator;
1926
import net.minecraft.text.Text;
2027
import net.minecraft.util.math.ColorHelper;
2128
import net.minecraft.util.math.MathHelper;
@@ -214,7 +221,6 @@ private void filter(String searchTerm, boolean refresh, boolean search) {
214221
@Override
215222
protected void renderList(DrawContext drawContext, int mouseX, int mouseY, float delta) {
216223
int entryCount = this.getEntryCount();
217-
Tessellator tessellator = Tessellator.getInstance();
218224
for (int index = 0; index < entryCount; ++index) {
219225
int entryTop = this.getRowTop(index) + 2;
220226
int entryBottom = this.getRowTop(index) + this.itemHeight;
@@ -230,28 +236,36 @@ protected void renderList(DrawContext drawContext, int mouseX, int mouseY, float
230236
float float_2 = this.isFocused() ? 1.0F : 0.5F;
231237
final int topColor = ColorHelper.fromFloats(1.0F, float_2, float_2, float_2);
232238
final int bottomColor = ColorHelper.fromFloats(1.0F, 0.0F, 0.0F, 0.0F);
233-
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
234-
bufferBuilder.vertex(matrix, entryLeft, entryTop + entryHeight + 2, 0.0F).color(topColor);
235-
bufferBuilder.vertex(matrix, selectionRight, entryTop + entryHeight + 2, 0.0F).color(topColor);
236-
bufferBuilder.vertex(matrix, selectionRight, entryTop - 2, 0.0F).color(topColor);
237-
bufferBuilder.vertex(matrix, entryLeft, entryTop - 2, 0.0F).color(topColor);
238-
bufferBuilder.vertex(matrix, entryLeft + 1, entryTop + entryHeight + 1, 0.0F).color(bottomColor);
239-
bufferBuilder.vertex(matrix, selectionRight - 1, entryTop + entryHeight + 1, 0.0F).color(bottomColor);
240-
bufferBuilder.vertex(matrix, selectionRight - 1, entryTop - 1, 0.0F).color(bottomColor);
241-
bufferBuilder.vertex(matrix, entryLeft + 1, entryTop - 1, 0.0F).color(bottomColor);
242-
try (BuiltBuffer builtBuffer = bufferBuilder.end()) {
243-
VertexFormat.DrawMode drawMode = builtBuffer.getDrawParameters().mode();
244-
Framebuffer framebuffer = MinecraftClient.getInstance().getFramebuffer();
245-
try (RenderPass renderPass = RenderSystem.getDevice().getResourceManager().newRenderPass(framebuffer.getColorAttachment(), OptionalInt.empty(), framebuffer.getDepthAttachment(), OptionalDouble.empty());
246-
GpuBuffer gpuBuffer = RenderSystem.getDevice().createBuffer(() -> "Mod List", GlBufferTarget.VERTICES, GlUsage.DYNAMIC_WRITE, 786432)) { // createBuffer
247-
RenderSystem.ShapeIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(drawMode);
248-
renderPass.bindShader(ShaderPipelines.GUI);
249-
renderPass.setVertexBuffer(0, gpuBuffer);
250-
renderPass.setIndexBuffer(autoStorageIndexBuffer.getIndexBuffer(builtBuffer.getDrawParameters().indexCount()), autoStorageIndexBuffer.getIndexType());
251-
RenderSystem.getDevice().getResourceManager().copyDataInto(gpuBuffer, builtBuffer.getBuffer(), 0);
252-
renderPass.drawObjects(0, builtBuffer.getDrawParameters().indexCount());
253-
}
254-
}
239+
RenderPipeline pipeline = RenderPipelines.GUI;
240+
try (BufferAllocator alloc = new BufferAllocator(pipeline.getVertexFormat().getVertexSize() * 4)) {
241+
BufferBuilder bufferBuilder = new BufferBuilder(alloc, pipeline.getVertexFormatMode(), pipeline.getVertexFormat());
242+
bufferBuilder.vertex(matrix, entryLeft, entryTop + entryHeight + 2, 0.0F).color(topColor);
243+
bufferBuilder.vertex(matrix, selectionRight, entryTop + entryHeight + 2, 0.0F).color(topColor);
244+
bufferBuilder.vertex(matrix, selectionRight, entryTop - 2, 0.0F).color(topColor);
245+
bufferBuilder.vertex(matrix, entryLeft, entryTop - 2, 0.0F).color(topColor);
246+
bufferBuilder.vertex(matrix, entryLeft + 1, entryTop + entryHeight + 1, 0.0F).color(bottomColor);
247+
bufferBuilder.vertex(matrix, selectionRight - 1, entryTop + entryHeight + 1, 0.0F).color(bottomColor);
248+
bufferBuilder.vertex(matrix, selectionRight - 1, entryTop - 1, 0.0F).color(bottomColor);
249+
bufferBuilder.vertex(matrix, entryLeft + 1, entryTop - 1, 0.0F).color(bottomColor);
250+
try (BuiltBuffer builtBuffer = bufferBuilder.endNullable()) {
251+
if (builtBuffer == null) {
252+
alloc.close();
253+
return;
254+
}
255+
Framebuffer framebuffer = MinecraftClient.getInstance().getFramebuffer();
256+
RenderSystem.ShapeIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(pipeline.getVertexFormatMode());
257+
VertexFormat.IndexType indexType = autoStorageIndexBuffer.getIndexType();
258+
GpuBuffer indexBuffer = autoStorageIndexBuffer.getIndexBuffer(builtBuffer.getDrawParameters().indexCount());
259+
GpuBuffer vertexBuffer = RenderSystem.getDevice().createBuffer(() -> "Mod List", BufferType.VERTICES, BufferUsage.DYNAMIC_WRITE, builtBuffer.getBuffer().remaining());
260+
RenderSystem.getDevice().createCommandEncoder().writeToBuffer(vertexBuffer, builtBuffer.getBuffer(), 0);
261+
try (RenderPass renderPass = RenderSystem.getDevice().createCommandEncoder().createRenderPass(framebuffer.getColorAttachment(), OptionalInt.empty(), framebuffer.getDepthAttachment(), OptionalDouble.empty())) {
262+
renderPass.setPipeline(pipeline);
263+
renderPass.setVertexBuffer(0, vertexBuffer);
264+
renderPass.setIndexBuffer(indexBuffer, indexType);
265+
renderPass.drawIndexed(0, builtBuffer.getDrawParameters().indexCount());
266+
}
267+
}
268+
}
255269
}
256270

257271
entryLeft = this.getRowLeft();

src/main/java/com/terraformersmc/modmenu/gui/widget/entries/ModListEntry.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.terraformersmc.modmenu.gui.widget.entries;
22

3-
import com.mojang.blaze3d.platform.GlStateManager;
3+
import com.mojang.blaze3d.opengl.GlStateManager;
44
import com.mojang.blaze3d.systems.RenderSystem;
55
import com.terraformersmc.modmenu.ModMenu;
66
import com.terraformersmc.modmenu.config.ModMenuConfig;

src/main/resources/fabric.mod.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"fabric-key-binding-api-v1": "*",
2626
"fabric-lifecycle-events-v1": "*",
2727
"fabricloader": ">=0.16.10",
28-
"minecraft": ">=1.21.5-alpha.25.6.a"
28+
"minecraft": ">=1.21.5-rc.1"
2929
},
3030
"authors": [
3131
"Prospector",

0 commit comments

Comments
 (0)