Skip to content

Commit a707b3a

Browse files
committedFeb 22, 2025·
Update to 25w08a.
- Update to 25w08a - Major internal changes to pano draw and texture registration
1 parent 91f87c8 commit a707b3a

File tree

6 files changed

+119
-73
lines changed

6 files changed

+119
-73
lines changed
 

‎gradle.properties

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
33
maven_group=com.terraformersmc
44
archive_name=vistas
55

6-
minecraft_version=1.21.4
7-
yarn_mappings=1.21.4+build.8
8-
loader_version=0.16.9
9-
fabric_version=0.115.1+1.21.4
6+
minecraft_version=25w08a
7+
yarn_mappings=25w08a+build.4
8+
loader_version=0.16.10
9+
fabric_version=0.118.0+1.21.5
1010
modmenu_version=13.0.1
1111
clothconfig_version=17.0.144
1212

@@ -21,14 +21,14 @@ default_release_type=beta
2121
# CurseForge Metadata
2222
curseforge_slug=vistas
2323
curseforge_id=423659
24-
curseforge_game_versions=1.21.4, Fabric, Quilt
24+
curseforge_game_versions=1.21.5-Snapshot, Fabric, Quilt
2525
curseforge_required_dependencies=fabric-api
2626
curseforge_optional_dependencies=
2727

2828
# Modrinth Metadata
2929
modrinth_slug=vistas
3030
modrinth_id=itzZXRxq
31-
modrinth_game_versions=1.21.4
31+
modrinth_game_versions=25w08a
3232
modrinth_mod_loaders=fabric, quilt
3333
modrinth_required_dependencies=fabric-api
3434

‎src/main/java/com/terraformersmc/vistas/mixin/SplashTextRendererMixin.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import net.minecraft.client.gui.screen.SplashTextRenderer;
1111
import net.minecraft.client.util.math.MatrixStack;
1212
import net.minecraft.util.math.RotationAxis;
13-
import org.joml.Quaternionf;
13+
import org.joml.Quaternionfc;
1414
import org.spongepowered.asm.mixin.Mixin;
1515
import org.spongepowered.asm.mixin.injection.At;
1616

@@ -21,11 +21,11 @@ public abstract class SplashTextRendererMixin {
2121
method = "render",
2222
at = @At(
2323
value = "INVOKE",
24-
target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V"
24+
target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionfc;)V"
2525
)
2626
)
2727
@SuppressWarnings("unused")
28-
private void vistas$render(MatrixStack instance, Quaternionf quaternion, Operation<Void> operation) {
28+
private void vistas$render(MatrixStack instance, Quaternionfc quaternion, Operation<Void> operation) {
2929
Panorama panorama = VistasTitle.CURRENT.getValue();
3030
LogoControl logo = panorama.getLogoControl();
3131

‎src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java

+7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import com.terraformersmc.vistas.config.VistasConfig;
55
import com.terraformersmc.vistas.resource.PanoramaResourceReloader;
66
import com.terraformersmc.vistas.title.LogoDrawerAccessor;
7+
import com.terraformersmc.vistas.title.VistasRotatingCubemapRenderer;
78
import com.terraformersmc.vistas.title.VistasTitle;
89
import net.fabricmc.api.EnvType;
910
import net.fabricmc.api.Environment;
1011
import net.minecraft.client.gui.LogoDrawer;
1112
import net.minecraft.client.gui.screen.Screen;
1213
import net.minecraft.client.gui.screen.SplashTextRenderer;
1314
import net.minecraft.client.gui.screen.TitleScreen;
15+
import net.minecraft.client.texture.TextureManager;
1416
import net.minecraft.text.Text;
1517
import org.jetbrains.annotations.Nullable;
1618
import org.spongepowered.asm.mixin.Final;
@@ -52,4 +54,9 @@ protected TitleScreenMixin(Text title) {
5254
this.splashText = null;
5355
}
5456
}
57+
58+
@Inject(method = "registerTextures", at = @At("TAIL"))
59+
private static void vistas$registerTextures(TextureManager textureManager, CallbackInfo ci) {
60+
VistasRotatingCubemapRenderer.registerTextures(textureManager);
61+
}
5562
}

‎src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java

+93-63
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
import net.fabricmc.api.EnvType;
77
import net.fabricmc.api.Environment;
88
import net.minecraft.client.MinecraftClient;
9-
import net.minecraft.client.gl.ShaderProgramKeys;
9+
import net.minecraft.client.gl.GlUsage;
10+
import net.minecraft.client.gl.VertexBuffer;
1011
import net.minecraft.client.render.*;
12+
import net.minecraft.client.texture.TextureManager;
13+
import net.minecraft.client.util.BufferAllocator;
1114
import net.minecraft.util.Identifier;
1215
import net.minecraft.util.math.RotationAxis;
1316
import org.joml.Matrix4f;
@@ -19,6 +22,7 @@ public class VistasCubemapRenderer {
1922

2023
private static final int FACES_COUNT = 6;
2124
private final Identifier[] faces = new Identifier[FACES_COUNT];
25+
private final VertexBuffer[] vertexBuffers = new VertexBuffer[FACES_COUNT];
2226

2327
private final Cubemap cubemap;
2428

@@ -32,90 +36,116 @@ public VistasCubemapRenderer(Cubemap cubemap) {
3236
}
3337

3438
public void draw(MinecraftClient client, float alpha) {
35-
Tessellator tessellator = Tessellator.getInstance();
36-
Matrix4f matrix4f = new Matrix4f().setPerspective((float) Math.toRadians(this.cubemap.getVisualControl().getFov()), (float) client.getWindow().getFramebufferWidth() / (float) client.getWindow().getFramebufferHeight(), 0.05F, 100.0F);
39+
if (this.vertexBuffers[0] == null) {
40+
this.computeVertexBuffers(alpha);
41+
}
42+
43+
Matrix4f matrix4f = new Matrix4f().setPerspective((float) Math.toRadians(this.cubemap.getVisualControl().getFov()), (float) client.getWindow().getFramebufferWidth() / (float) client.getWindow().getFramebufferHeight(), 0.05F, 10.0F);
3744
RenderSystem.backupProjectionMatrix();
3845
RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.PERSPECTIVE);
3946
Matrix4fStack matrixStack = RenderSystem.getModelViewStack();
4047
matrixStack.pushMatrix();
4148
matrixStack.rotationX((float) Math.PI);
42-
RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
43-
RenderSystem.enableBlend();
44-
RenderSystem.disableCull();
45-
RenderSystem.depthMask(false);
46-
47-
int r = Math.round((float) this.cubemap.getVisualControl().getColorR());
48-
int g = Math.round((float) this.cubemap.getVisualControl().getColorG());
49-
int b = Math.round((float) this.cubemap.getVisualControl().getColorB());
50-
int a = Math.round((float) this.cubemap.getVisualControl().getColorA() * alpha);
51-
52-
float w = (float) this.cubemap.getVisualControl().getWidth() / 2.0f;
53-
float h = (float) this.cubemap.getVisualControl().getHeight() / 2.0f;
54-
float d = (float) this.cubemap.getVisualControl().getDepth() / 2.0f;
5549

5650
matrixStack.pushMatrix();
5751
matrixStack.translate((float) this.cubemap.getVisualControl().getAddedX(), (float) this.cubemap.getVisualControl().getAddedY(), (float) this.cubemap.getVisualControl().getAddedZ());
5852
matrixStack.rotate(RotationAxis.POSITIVE_X.rotationDegrees((float) this.cubemap.getRotationControl().getPitch(cubemap.getRotationControl().isFrozen() ? 0.0D : time)));
5953
matrixStack.rotate(RotationAxis.POSITIVE_Y.rotationDegrees((float) this.cubemap.getRotationControl().getYaw(cubemap.getRotationControl().isFrozen() ? 0.0D : time)));
6054
matrixStack.rotate(RotationAxis.POSITIVE_Z.rotationDegrees((float) this.cubemap.getRotationControl().getRoll(cubemap.getRotationControl().isFrozen() ? 0.0D : time)));
6155

62-
for (int n = 0; n < 6; ++n) {
63-
RenderSystem.setShaderTexture(0, this.faces[n]);
64-
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
65-
66-
if (n == 0) {
67-
bufferBuilder.vertex(-w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a);
68-
bufferBuilder.vertex(-w, h, d).texture(0.0F, 1.0F).color(r, g, b, a);
69-
bufferBuilder.vertex(w, h, d).texture(1.0F, 1.0F).color(r, g, b, a);
70-
bufferBuilder.vertex(w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a);
71-
}
72-
73-
if (n == 1) {
74-
bufferBuilder.vertex(w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a);
75-
bufferBuilder.vertex(w, h, d).texture(0.0F, 1.0F).color(r, g, b, a);
76-
bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a);
77-
bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a);
78-
}
79-
80-
if (n == 2) {
81-
bufferBuilder.vertex(w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a);
82-
bufferBuilder.vertex(w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a);
83-
bufferBuilder.vertex(-w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a);
84-
bufferBuilder.vertex(-w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a);
85-
}
86-
87-
if (n == 3) {
88-
bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a);
89-
bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a);
90-
bufferBuilder.vertex(-w, h, d).texture(1.0F, 1.0F).color(r, g, b, a);
91-
bufferBuilder.vertex(-w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a);
92-
}
56+
for (int pass = 0; pass < 4; ++pass) {
57+
matrixStack.pushMatrix();
58+
float xOffset = ((float)(pass % 2) / 2.0F - 0.5F) / 256.0F;
59+
float yOffset = ((float)(pass / 2) / 2.0F - 0.5F) / 256.0F;
60+
matrixStack.translate(xOffset, yOffset, 0.0F);
61+
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha / (float)(pass + 1));
9362

94-
if (n == 4) {
95-
bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a);
96-
bufferBuilder.vertex(-w, -h, d).texture(0.0F, 1.0F).color(r, g, b, a);
97-
bufferBuilder.vertex(w, -h, d).texture(1.0F, 1.0F).color(r, g, b, a);
98-
bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a);
63+
for (int face = 0; face < FACES_COUNT; ++face) {
64+
this.vertexBuffers[face].bind();
65+
this.vertexBuffers[face].draw(RenderLayer.getPanorama(this.faces[face]));
9966
}
10067

101-
if (n == 5) {
102-
bufferBuilder.vertex(-w, h, d).texture(0.0F, 0.0F).color(r, g, b, a);
103-
bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a);
104-
bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a);
105-
bufferBuilder.vertex(w, h, d).texture(1.0F, 0.0F).color(r, g, b, a);
106-
}
107-
108-
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
68+
VertexBuffer.unbind();
69+
matrixStack.popMatrix();
70+
RenderSystem.colorMask(true, true, true, false);
10971
}
11072

11173
matrixStack.popMatrix();
11274

11375
RenderSystem.colorMask(true, true, true, true);
76+
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
11477
RenderSystem.restoreProjectionMatrix();
11578
matrixStack.popMatrix();
116-
RenderSystem.depthMask(true);
117-
RenderSystem.enableCull();
118-
RenderSystem.enableDepthTest();
79+
}
80+
81+
private void computeVertexBuffers(float alpha) {
82+
int r = Math.round((float) this.cubemap.getVisualControl().getColorR());
83+
int g = Math.round((float) this.cubemap.getVisualControl().getColorG());
84+
int b = Math.round((float) this.cubemap.getVisualControl().getColorB());
85+
int a = Math.round((float) this.cubemap.getVisualControl().getColorA() * alpha);
86+
87+
float w = (float) this.cubemap.getVisualControl().getWidth() / 2.0f;
88+
float h = (float) this.cubemap.getVisualControl().getHeight() / 2.0f;
89+
float d = (float) this.cubemap.getVisualControl().getDepth() / 2.0f;
90+
91+
try (BufferAllocator bufferAllocator = new BufferAllocator(VertexFormats.POSITION_TEXTURE_COLOR.getVertexSizeByte() * 4)) {
92+
for (int face = 0; face < FACES_COUNT; ++face) {
93+
BufferBuilder bufferBuilder = new BufferBuilder(bufferAllocator, VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
94+
95+
if (face == 0) {
96+
bufferBuilder.vertex(-w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a);
97+
bufferBuilder.vertex(-w, h, d).texture(0.0F, 1.0F).color(r, g, b, a);
98+
bufferBuilder.vertex(w, h, d).texture(1.0F, 1.0F).color(r, g, b, a);
99+
bufferBuilder.vertex(w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a);
100+
}
101+
102+
if (face == 1) {
103+
bufferBuilder.vertex(w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a);
104+
bufferBuilder.vertex(w, h, d).texture(0.0F, 1.0F).color(r, g, b, a);
105+
bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a);
106+
bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a);
107+
}
108+
109+
if (face == 2) {
110+
bufferBuilder.vertex(w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a);
111+
bufferBuilder.vertex(w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a);
112+
bufferBuilder.vertex(-w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a);
113+
bufferBuilder.vertex(-w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a);
114+
}
115+
116+
if (face == 3) {
117+
bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a);
118+
bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a);
119+
bufferBuilder.vertex(-w, h, d).texture(1.0F, 1.0F).color(r, g, b, a);
120+
bufferBuilder.vertex(-w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a);
121+
}
122+
123+
if (face == 4) {
124+
bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a);
125+
bufferBuilder.vertex(-w, -h, d).texture(0.0F, 1.0F).color(r, g, b, a);
126+
bufferBuilder.vertex(w, -h, d).texture(1.0F, 1.0F).color(r, g, b, a);
127+
bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a);
128+
}
129+
130+
if (face == 5) {
131+
bufferBuilder.vertex(-w, h, d).texture(0.0F, 0.0F).color(r, g, b, a);
132+
bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a);
133+
bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a);
134+
bufferBuilder.vertex(w, h, d).texture(1.0F, 0.0F).color(r, g, b, a);
135+
}
136+
137+
this.vertexBuffers[face] = new VertexBuffer(GlUsage.STATIC_WRITE);
138+
this.vertexBuffers[face].bind();
139+
this.vertexBuffers[face].upload(bufferBuilder.end());
140+
VertexBuffer.unbind();
141+
}
142+
}
143+
}
144+
145+
public void registerTextures(TextureManager textureManager) {
146+
for (Identifier identifier : this.faces) {
147+
textureManager.registerTexture(identifier);
148+
}
119149
}
120150

121151
public Cubemap getCubemap() {

‎src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.client.gui.DrawContext;
88
import net.minecraft.client.gui.RotatingCubeMapRenderer;
99
import net.minecraft.client.render.RenderLayer;
10+
import net.minecraft.client.texture.TextureManager;
1011
import net.minecraft.util.Identifier;
1112
import net.minecraft.util.math.ColorHelper;
1213

@@ -37,4 +38,12 @@ public void render(DrawContext context, int width, int height, float alpha, floa
3738
}
3839
});
3940
}
41+
42+
public static void registerTextures(TextureManager textureManager) {
43+
VistasTitle.PANORAMAS.values().forEach(panorama ->
44+
panorama.getCubemaps().forEach(cubemap ->
45+
new VistasCubemapRenderer(cubemap).registerTextures(textureManager)
46+
)
47+
);
48+
}
4049
}

‎src/main/resources/fabric.mod.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"depends": {
3232
"fabricloader": ">=0.15.3",
3333
"fabric-api": "*",
34-
"minecraft": ">=1.21.2 <1.22",
34+
"minecraft": ">1.21.4 <1.22",
3535
"cloth-config": "*"
3636
}
3737
}

0 commit comments

Comments
 (0)
Please sign in to comment.