Update to 1.21

This commit is contained in:
Jonas Herzig
2024-06-23 19:39:11 +02:00
parent 1433fccaf1
commit a4e0abec7f
32 changed files with 228 additions and 32 deletions

View File

@@ -46,9 +46,10 @@ import static com.replaymod.core.versions.MCVer.bindTexture;
import static com.replaymod.core.versions.MCVer.emitLine;
import static com.replaymod.core.versions.MCVer.popMatrix;
import static com.replaymod.core.versions.MCVer.pushMatrix;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
public class PathPreviewRenderer extends EventRegistrations {
private static final Identifier CAMERA_HEAD = new Identifier("replaymod", "camera_head.png");
private static final Identifier CAMERA_HEAD = identifier("replaymod", "camera_head.png");
private static final MinecraftClient mc = MCVer.getMinecraft();
private static final int SLOW_PATH_COLOR = 0xffcccc;
@@ -246,8 +247,12 @@ public class PathPreviewRenderer extends EventRegistrations {
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINES, VertexFormats.LINES);
//#else
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
//#endif
emitLine(buffer, Vector3f.sub(pos1, view, null), Vector3f.sub(pos2, view, null), color);
@@ -256,7 +261,13 @@ public class PathPreviewRenderer extends EventRegistrations {
//$$ RenderSystem.disableCull();
//#endif
GL11.glLineWidth(3);
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
//$$ }
//#else
tessellator.draw();
//#endif
//#if MC>=11700
//$$ RenderSystem.enableCull();
//#endif
@@ -284,8 +295,12 @@ public class PathPreviewRenderer extends EventRegistrations {
float maxY = 0.5f;
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
//#else
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE);
//#endif
buffer.vertex(minX, minY, 0).texture(posX + size, posY + size).next();
buffer.vertex(minX, maxY, 0).texture(posX + size, posY).next();
@@ -303,7 +318,13 @@ public class PathPreviewRenderer extends EventRegistrations {
//$$ RenderSystem.applyModelViewMatrix();
//$$ RenderSystem.setShader(GameRenderer::getPositionTexShader);
//#endif
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
//$$ }
//#else
tessellator.draw();
//#endif
popMatrix();
}
@@ -322,8 +343,12 @@ public class PathPreviewRenderer extends EventRegistrations {
//draw the position line
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINES, VertexFormats.LINES);
//#else
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
//#endif
emitLine(buffer, new Vector3f(0, 0, 0), new Vector3f(0, 0, 2), 0x00ff00aa);
@@ -334,7 +359,13 @@ public class PathPreviewRenderer extends EventRegistrations {
GL11.glDisable(GL11.GL_TEXTURE_2D);
//#endif
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
//$$ }
//#else
tessellator.draw();
//#endif
//#if MC<11700
GL11.glEnable(GL11.GL_TEXTURE_2D);
@@ -344,9 +375,17 @@ public class PathPreviewRenderer extends EventRegistrations {
float cubeSize = 0.5f;
//#if MC>=12100
//$$ float r = -cubeSize/2;
//#else
double r = -cubeSize/2;
//#endif
//#if MC>=12100
//$$ buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
//#else
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
//#endif
//back
buffer.vertex(r, r + cubeSize, r).texture(3 * 8 / 64f, 8 / 64f).color(255, 255, 255, 200).next();
@@ -388,7 +427,13 @@ public class PathPreviewRenderer extends EventRegistrations {
//$$ RenderSystem.applyModelViewMatrix();
//$$ RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
//#endif
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
//$$ }
//#else
tessellator.draw();
//#endif
popMatrix();
}