Update to 1.21.5

This commit is contained in:
Jonas Herzig
2025-04-27 13:04:28 +02:00
parent 7aad4dcfd9
commit a8c1d19240
26 changed files with 372 additions and 37 deletions

View File

@@ -89,6 +89,7 @@ dependencies {
12100 -> "0.100.3+1.21"
12102 -> "0.106.1+1.21.2"
12104 -> "0.111.0+1.21.4"
12105 -> "0.119.9+1.21.5"
else -> throw UnsupportedOperationException()
}
val fabricApiModules = mutableListOf(
@@ -167,6 +168,7 @@ dependencies {
if (platform.isFabric) {
val modMenuVersion = when {
mcVersion >= 12105 -> "14.0.0-rc.2"
mcVersion >= 12104 -> "13.0.0-beta.1"
mcVersion >= 12102 -> "12.0.0-beta.1"
mcVersion >= 12100 -> "11.0.0-rc.4"

View File

@@ -1,8 +1,10 @@
essential.defaults.loom=0
essential.defaults.loom.fabric-loader=net.fabricmc:fabric-loader:0.16.9
essential.defaults.loom.fabric-loader=net.fabricmc:fabric-loader:0.16.12
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx8G
org.gradle.parallel=true
org.gradle.configureondemand=true
loom.ignoreDependencyLoomVersionValidation=true

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
jGui

Submodule jGui updated: bbce84072e...be4bf44276

View File

@@ -3,6 +3,7 @@ import java.io.ByteArrayOutputStream
plugins {
id("gg.essential.multi-version.root")
id("gg.essential.loom") version "1.7.28" apply false
id("com.github.hierynomus.license") version "0.15.0"
}
@@ -203,6 +204,7 @@ defaultTasks("bundleJar")
preprocess {
strictExtraMappings.set(true)
val mc12105 = createNode("1.21.5", 12105, "yarn")
val mc12104 = createNode("1.21.4", 12104, "yarn")
val mc12102 = createNode("1.21.2", 12102, "yarn")
val mc12100 = createNode("1.21", 12100, "yarn")
@@ -234,6 +236,7 @@ preprocess {
val mc10800 = createNode("1.8", 10800, "srg")
val mc10710 = createNode("1.7.10", 10710, "srg")
mc12105.link(mc12104, file("versions/mapping-fabric-1.21.5-1.21.4.txt"))
mc12104.link(mc12102)
mc12102.link(mc12100)
mc12100.link(mc12006)

View File

@@ -11,7 +11,7 @@ pluginManagement {
maven("https://repo.essential.gg/repository/maven-public")
}
plugins {
id("gg.essential.multi-version.root") version "0.6.5"
id("gg.essential.multi-version.root") version "0.6.7"
id("io.github.goooler.shadow") version "8.1.7"
}
}
@@ -42,6 +42,7 @@ val jGuiVersions = listOf(
"1.21",
"1.21.2",
"1.21.4",
"1.21.5",
)
val replayModVersions = listOf(
// "1.7.10",
@@ -74,6 +75,7 @@ val replayModVersions = listOf(
"1.21",
"1.21.2",
"1.21.4",
"1.21.5",
)
rootProject.buildFileName = "root.gradle.kts"

View File

@@ -16,6 +16,10 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.Vec3d;
//#if MC>=12105
//$$ import net.minecraft.client.render.VertexConsumer;
//#endif
//#if MC>=11700
//$$ import net.minecraft.util.math.Matrix4f;
//#endif
@@ -440,11 +444,19 @@ public class MCVer {
//$$ }
//#endif
//#if MC>=12105
//$$ public static void emitLine(MatrixStack matrixStack, VertexConsumer buffer, Vector2f p1, Vector2f p2, int color) {
//#else
public static void emitLine(MatrixStack matrixStack, BufferBuilder buffer, Vector2f p1, Vector2f p2, int color) {
//#endif
emitLine(matrixStack, buffer, new Vector3f(p1.x, p1.y, 0), new Vector3f(p2.x, p2.y, 0), color);
}
//#if MC>=12105
//$$ public static void emitLine(MatrixStack matrixStack, VertexConsumer buffer, Vector3f p1, Vector3f p2, int color) {
//#else
public static void emitLine(MatrixStack matrixStack, BufferBuilder buffer, Vector3f p1, Vector3f p2, int color) {
//#endif
int r = color >> 24 & 0xff;
int g = color >> 16 & 0xff;
int b = color >> 8 & 0xff;

View File

@@ -35,7 +35,11 @@ public abstract class MixinServerInfo implements ServerInfoExt {
private static void deserialize(CompoundTag tag, CallbackInfoReturnable<ServerInfo> ci) {
ServerInfoExt serverInfo = ServerInfoExt.from(ci.getReturnValue());
if (tag.contains("autoRecording")) {
//#if MC>=12105
//$$ serverInfo.setAutoRecording(tag.getBoolean("autoRecording").orElseThrow());
//#else
serverInfo.setAutoRecording(tag.getBoolean("autoRecording"));
//#endif
}
}

View File

@@ -16,6 +16,10 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#if MC>=12105
//$$ import net.minecraft.entity.Entity;
//#endif
//#if MC>=11802
//$$ import net.minecraft.util.registry.RegistryEntry;
//#endif
@@ -51,7 +55,10 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
// but are instead played directly by the client. The server only sends these sounds to
// other clients so we have to record them manually.
// E.g. Block place sounds
//#if MC>=11903
//#if MC>=12105
//$$ @Inject(method = "playSound(Lnet/minecraft/entity/Entity;DDDLnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/sound/SoundCategory;FFJ)V",
//$$ at = @At("HEAD"))
//#elseif MC>=11903
//$$ @Inject(method = "playSound(Lnet/minecraft/entity/player/PlayerEntity;DDDLnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/sound/SoundCategory;FFJ)V",
//$$ at = @At("HEAD"))
//#elseif MC>=11900
@@ -70,7 +77,12 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
//$$ at = @At("HEAD"))
//#endif
public void replayModRecording_recordClientSound(
PlayerEntity player, double x, double y, double z,
//#if MC>=12105
//$$ Entity player,
//#else
PlayerEntity player,
//#endif
double x, double y, double z,
//#if MC>=11903
//$$ RegistryEntry<SoundEvent> sound,
//#else
@@ -103,7 +115,14 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
//#else
//$$ @Inject(method = "playLevelEvent", at = @At("HEAD"))
//#endif
private void playLevelEvent (PlayerEntity player, int type, BlockPos pos, int data, CallbackInfo ci) {
private void playLevelEvent(
//#if MC>=12105
//$$ Entity player,
//#else
PlayerEntity player,
//#endif
int type, BlockPos pos, int data, CallbackInfo ci
) {
//#else
//$$ // These are handled in the World class, so we override the method in WorldClient and add our special handling.
//$$ @Override

View File

@@ -23,6 +23,13 @@ import static com.replaymod.core.versions.MCVer.resizeMainWindow;
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
//#if MC>=12105
//$$ import com.mojang.blaze3d.buffers.BufferType;
//$$ import com.mojang.blaze3d.buffers.BufferUsage;
//$$ import com.mojang.blaze3d.buffers.GpuBuffer;
//$$ import com.mojang.blaze3d.systems.GpuDevice;
//#endif
public abstract class OpenGlFrameCapturer<F extends Frame, D extends CaptureData> implements FrameCapturer<F> {
protected final WorldRenderer worldRenderer;
protected final RenderInfo renderInfo;
@@ -81,20 +88,30 @@ public abstract class OpenGlFrameCapturer<F extends Frame, D extends CaptureData
resizeMainWindow(mc, getFrameWidth(), getFrameHeight());
pushMatrix();
//#if MC<12105
frameBuffer().beginWrite(true);
//#endif
//#if MC>=12105
//$$ RenderSystem.getDevice()
//$$ .createCommandEncoder()
//$$ .clearColorAndDepthTextures(mc.getFramebuffer().getColorAttachment(), 0, mc.getFramebuffer().getDepthAttachment(), 1);
//#else
GlStateManager.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
//#if MC>=11400 && MC<12102
, false
//#endif
);
//#endif
//#if MC<11904
GlStateManager.enableTexture();
//#endif
worldRenderer.renderWorld(partialTicks, captureData);
//#if MC<12105
frameBuffer().endWrite();
//#endif
popMatrix();
return captureFrame(frameId, captureData);
@@ -102,9 +119,19 @@ public abstract class OpenGlFrameCapturer<F extends Frame, D extends CaptureData
protected OpenGlFrame captureFrame(int frameId, D captureData) {
ByteBuffer buffer = ByteBufferPool.allocate(getFrameWidth() * getFrameHeight() * 4);
//#if MC>=12105
//$$ GpuDevice device = RenderSystem.getDevice();
//$$ try (GpuBuffer gpuBuffer = device.createBuffer(null, BufferType.PIXEL_PACK, BufferUsage.STATIC_READ, getFrameWidth() * getFrameHeight() * 4)) {
//$$ device.createCommandEncoder().copyTextureToBuffer(frameBuffer().getColorAttachment(), gpuBuffer, 0, () -> {}, 0);
//$$ try (GpuBuffer.ReadView view = device.createCommandEncoder().readBuffer(gpuBuffer)) {
//$$ buffer.put(view.data());
//$$ }
//$$ }
//#else
frameBuffer().beginWrite(true);
GL11.glReadPixels(0, 0, getFrameWidth(), getFrameHeight(), GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, buffer);
frameBuffer().endWrite();
//#endif
buffer.rewind();
return new OpenGlFrame(frameId, new Dimension(getFrameWidth(), getFrameHeight()), 4, buffer);

View File

@@ -1,6 +1,5 @@
package com.replaymod.render.capturer;
import com.mojang.blaze3d.platform.GlStateManager;
import com.replaymod.render.frame.OpenGlFrame;
import com.replaymod.render.rendering.Channel;
import com.replaymod.render.rendering.Frame;
@@ -14,11 +13,24 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
//#if MC>=12105
//$$ import com.mojang.blaze3d.buffers.BufferType;
//$$ import com.mojang.blaze3d.buffers.BufferUsage;
//$$ import com.mojang.blaze3d.buffers.GpuBuffer;
//$$ import com.mojang.blaze3d.systems.CommandEncoder;
//$$ import com.mojang.blaze3d.systems.GpuDevice;
//$$ import com.mojang.blaze3d.systems.RenderSystem;
//#endif
public abstract class PboOpenGlFrameCapturer<F extends Frame, D extends Enum<D> & CaptureData>
extends OpenGlFrameCapturer<F, D> {
private final boolean withDepth;
private final D[] data;
//#if MC>=12105
//$$ private GpuBuffer pbo, otherPBO;
//#else
private PixelBufferObject pbo, otherPBO;
//#endif
public PboOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo, Class<D> type, int framePixels) {
super(worldRenderer, renderInfo);
@@ -26,14 +38,23 @@ public abstract class PboOpenGlFrameCapturer<F extends Frame, D extends Enum<D>
withDepth = renderInfo.getRenderSettings().isDepthMap();
data = type.getEnumConstants();
int bufferSize = framePixels * (4 /* bgra */ + (withDepth ? 4 /* float */ : 0)) * data.length;
//#if MC>=12105
//$$ pbo = RenderSystem.getDevice().createBuffer(null, BufferType.PIXEL_PACK, BufferUsage.STREAM_READ, bufferSize);
//$$ otherPBO = RenderSystem.getDevice().createBuffer(null, BufferType.PIXEL_PACK, BufferUsage.STREAM_READ, bufferSize);
//#else
pbo = new PixelBufferObject(bufferSize, PixelBufferObject.Usage.READ);
otherPBO = new PixelBufferObject(bufferSize, PixelBufferObject.Usage.READ);
//#endif
}
protected abstract F create(OpenGlFrame[] from);
private void swapPBOs() {
//#if MC>=12105
//$$ GpuBuffer old = pbo;
//#else
PixelBufferObject old = pbo;
//#endif
pbo = otherPBO;
otherPBO = old;
}
@@ -43,13 +64,26 @@ public abstract class PboOpenGlFrameCapturer<F extends Frame, D extends Enum<D>
return framesDone >= renderInfo.getTotalFrames() + 2;
}
private F readFromPbo(ByteBuffer pboBuffer, int bytesPerPixel) {
private F readFromPbo(ByteBuffer pboBuffer, int bytesPerPixel, boolean swapRB) {
OpenGlFrame[] frames = new OpenGlFrame[data.length];
int frameBufferSize = getFrameWidth() * getFrameHeight() * bytesPerPixel;
for (int i = 0; i < frames.length; i++) {
ByteBuffer frameBuffer = ByteBufferPool.allocate(frameBufferSize);
pboBuffer.limit(pboBuffer.position() + frameBufferSize);
frameBuffer.put(pboBuffer);
if (swapRB) {
for (int j = 0; j < frameBufferSize; j += 4) {
byte r = pboBuffer.get();
byte g = pboBuffer.get();
byte b = pboBuffer.get();
byte a = pboBuffer.get();
frameBuffer.put(b);
frameBuffer.put(g);
frameBuffer.put(r);
frameBuffer.put(a);
}
} else {
frameBuffer.put(pboBuffer);
}
frameBuffer.rewind();
frames[i] = new OpenGlFrame(framesDone - 2, frameSize, bytesPerPixel, frameBuffer);
}
@@ -62,17 +96,27 @@ public abstract class PboOpenGlFrameCapturer<F extends Frame, D extends Enum<D>
if (framesDone > 1) {
// Read pbo to memory
//#if MC>=12105
//$$ try (GpuBuffer.ReadView view = RenderSystem.getDevice().createCommandEncoder().readBuffer(pbo)) {
//$$ channels = new HashMap<>();
//$$ channels.put(Channel.BRGA, readFromPbo(view.data(), 4, true));
//$$ if (withDepth) {
//$$ channels.put(Channel.DEPTH, readFromPbo(view.data(), 4, false));
//$$ }
//$$ }
//#else
pbo.bind();
ByteBuffer pboBuffer = pbo.mapReadOnly();
channels = new HashMap<>();
channels.put(Channel.BRGA, readFromPbo(pboBuffer, 4));
channels.put(Channel.BRGA, readFromPbo(pboBuffer, 4, false));
if (withDepth) {
channels.put(Channel.DEPTH, readFromPbo(pboBuffer, 4));
channels.put(Channel.DEPTH, readFromPbo(pboBuffer, 4, false));
}
pbo.unmap();
pbo.unbind();
//#endif
}
if (framesDone < renderInfo.getTotalFrames()) {
@@ -90,6 +134,15 @@ public abstract class PboOpenGlFrameCapturer<F extends Frame, D extends Enum<D>
@Override
protected OpenGlFrame captureFrame(int frameId, D captureData) {
//#if MC>=12105
//$$ int offset = captureData.ordinal() * getFrameWidth() * getFrameHeight() * 4;
//$$ CommandEncoder cmd = RenderSystem.getDevice().createCommandEncoder();
//$$ cmd.copyTextureToBuffer(frameBuffer().getColorAttachment(), pbo, offset, () -> {}, 0);
//$$ if (withDepth) {
//$$ offset += data.length * getFrameWidth() * getFrameHeight() * 4;
//$$ cmd.copyTextureToBuffer(frameBuffer().getDepthAttachment(), pbo, offset, () -> {}, 0);
//$$ }
//#else
pbo.bind();
int offset = captureData.ordinal() * getFrameWidth() * getFrameHeight() * 4;
@@ -102,13 +155,14 @@ public abstract class PboOpenGlFrameCapturer<F extends Frame, D extends Enum<D>
frameBuffer().endWrite();
pbo.unbind();
//#endif
return null;
}
@Override
public void close() throws IOException {
super.close();
pbo.delete();
otherPBO.delete();
pbo.close();
otherPBO.close();
}
}

View File

@@ -240,7 +240,9 @@ public class GuiVideoRenderer extends GuiScreen implements Tickable {
final int videoHeight = videoSize.getHeight();
if (previewTexture == null) {
//#if MC>=11400
//#if MC>=12105
//$$ previewTexture = new NativeImageBackedTexture((String) null, videoWidth, videoHeight, true);
//#elseif MC>=11400
previewTexture = new NativeImageBackedTexture(videoWidth, videoHeight, true);
//#else
//$$ previewTexture = new DynamicTexture(videoWidth, videoHeight);
@@ -252,7 +254,11 @@ public class GuiVideoRenderer extends GuiScreen implements Tickable {
previewTextureDirty = false;
}
//#if MC>=12105
//$$ guiRenderer.bindTexture(previewTexture.getGlTexture());
//#else
guiRenderer.bindTexture(previewTexture.getGlId());
//#endif
renderPreviewTexture(guiRenderer, size, videoWidth, videoHeight);
}

View File

@@ -69,16 +69,24 @@ public class VirtualWindow implements Closeable {
public void beginWrite() {
MinecraftClientExt.get(mc).setFramebufferDelegate(guiFramebuffer);
//#if MC<12105
guiFramebuffer.beginWrite(true);
//#endif
}
public void endWrite() {
//#if MC<12105
guiFramebuffer.endWrite();
//#endif
MinecraftClientExt.get(mc).setFramebufferDelegate(null);
}
public void flip() {
//#if MC>=12105
//$$ guiFramebuffer.blitToScreen();
//#else
guiFramebuffer.draw(framebufferWidth, framebufferHeight);
//#endif
//#if MC>=12102
//$$ window.swapBuffers(null);

View File

@@ -21,6 +21,12 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
//#if MC>=12105
//$$ import org.spongepowered.asm.mixin.Mutable;
//$$ import java.util.AbstractQueue;
//$$ import java.util.Iterator;
//#endif
//#if MC>=12102
//$$ import net.minecraft.util.thread.SimpleConsecutiveExecutor;
//#endif
@@ -68,6 +74,9 @@ public abstract class Mixin_BlockOnChunkRebuilds implements ForceChunkLoadingHoo
@Shadow protected abstract void scheduleRunTasks();
//#if MC>=12105
//$$ @Mutable
//#endif
@Shadow @Final private Queue<Runnable> uploadQueue;
private final Lock waitingForWorkLock = new ReentrantLock();
private final Condition newWork = waitingForWorkLock.newCondition();
@@ -96,6 +105,29 @@ public abstract class Mixin_BlockOnChunkRebuilds implements ForceChunkLoadingHoo
}
}
//#if MC>=12105
//$$ @Inject(method = "<init>", at = @At("RETURN"))
//$$ private void notifyMainThreadOfNewUpload(CallbackInfo ci) {
//$$ Queue<Runnable> inner = this.uploadQueue;
//$$ this.uploadQueue = new AbstractQueue<>() {
//$$ @Override
//$$ public boolean offer(Runnable runnable) {
//$$ boolean result = inner.offer(runnable);
//$$ waitingForWorkLock.lock();
//$$ try {
//$$ newWork.signal();
//$$ } finally {
//$$ waitingForWorkLock.unlock();
//$$ }
//$$ return result;
//$$ }
//$$ @Override public Runnable poll() { return inner.poll(); }
//$$ @Override public Runnable peek() { return inner.peek(); }
//$$ @Override public int size() { return inner.size(); }
//$$ @Override public Iterator<Runnable> iterator() { return inner.iterator(); }
//$$ };
//$$ }
//#else
@Inject(method = "scheduleUpload", at = @At("RETURN"))
private void notifyMainThreadOfNewUpload(CallbackInfoReturnable<CompletableFuture<Void>> ci) {
this.waitingForWorkLock.lock();
@@ -105,6 +137,7 @@ public abstract class Mixin_BlockOnChunkRebuilds implements ForceChunkLoadingHoo
this.waitingForWorkLock.unlock();
}
}
//#endif
private boolean waitForMainThreadWork() {
//#if MC>=12102
@@ -125,6 +158,7 @@ public abstract class Mixin_BlockOnChunkRebuilds implements ForceChunkLoadingHoo
this.waitingForWorkLock.lock();
try {
while (true) {
//#if MC<11900
// Now, what is this call doing here you might be wondering. Well, from a quick look over everything
// it does not look like it would be required but have a **very** close look at [scheduleUpload]:
// It is not actually guaranteed to run the upload on the main thread, it just looks like it (and
@@ -138,6 +172,7 @@ public abstract class Mixin_BlockOnChunkRebuilds implements ForceChunkLoadingHoo
// dead-lock ourselves here (since the upload queue is already empty), if we did never do this call
// to run the upload scheduled via this particular path of code execution.
RenderSystem.replayQueue();
//#endif
if (this.allDone) {
return true;

View File

@@ -49,12 +49,19 @@ public abstract class Mixin_ChromaKeyColorSky {
if (handler != null) {
ReadableColor color = handler.getSettings().getChromaKeyingColor();
if (color != null) {
//#if MC>=12105
//$$ RenderSystem.getDevice().createCommandEncoder().clearColorTexture(
//$$ this.client.getFramebuffer().getColorAttachment(),
//$$ (0xff << 24) | (color.getRed() << 16) | (color.getGreen() << 8) | color.getBlue()
//$$ );
//#else
GlStateManager.clearColor(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1);
GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT
//#if MC>=11400 && MC<12102
, false
//#endif
);
//#endif
ci.cancel();
}
}

View File

@@ -495,22 +495,34 @@ public class VideoRenderer implements RenderInfo {
}
pushMatrix();
//#if MC>=12105
//$$ RenderSystem.getDevice()
//$$ .createCommandEncoder()
//$$ .clearColorAndDepthTextures(mc.getFramebuffer().getColorAttachment(), 0, mc.getFramebuffer().getDepthAttachment(), 1);
//#else
GlStateManager.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
//#if MC>=11400 && MC<12102
, false
//#endif
);
//#endif
//#if MC<11904
GlStateManager.enableTexture();
//#endif
guiWindow.beginWrite();
//#if MC>=11500
//#if MC>=12105
//$$ RenderSystem.getDevice()
//$$ .createCommandEncoder()
//$$ .clearColorAndDepthTextures(mc.getFramebuffer().getColorAttachment(), 0, mc.getFramebuffer().getDepthAttachment(), 1);
//#else
//#if MC>=12102
//$$ RenderSystem.clear(256);
//#else
RenderSystem.clear(256, MinecraftClient.IS_SYSTEM_MAC);
//#endif
//#endif
//#if MC>=11700
//$$ RenderSystem.setProjectionMatrix(Matrix4f.projectionMatrix(
//$$ 0,

View File

@@ -23,7 +23,7 @@ import static org.lwjgl.opengl.GL21.GL_PIXEL_PACK_BUFFER;
import static org.lwjgl.opengl.ARBVertexBufferObject.*;
//#endif
public class PixelBufferObject {
public class PixelBufferObject implements AutoCloseable {
public enum Usage {
COPY(GL_STREAM_COPY_ARB, GL_STREAM_COPY),
DRAW(GL_STREAM_DRAW_ARB, GL_STREAM_DRAW),
@@ -207,7 +207,8 @@ public class PixelBufferObject {
mapped.set(0);
}
public void delete() {
@Override
public void close() {
if (handle != -1) {
if (arb) {
//#if MC>=11400
@@ -227,7 +228,7 @@ public class PixelBufferObject {
super.finalize();
if (handle != -1) {
LogManager.getLogger().warn("PBO garbage collected before deleted!");
ReplayMod.instance.runLater(this::delete);
ReplayMod.instance.runLater(this::close);
}
}
}

View File

@@ -36,7 +36,6 @@ import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket;
import net.minecraft.network.packet.s2c.play.EntitiesDestroyS2CPacket;
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
import net.minecraft.network.packet.s2c.play.ExperienceBarUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
import net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket;
@@ -57,6 +56,11 @@ import net.minecraft.util.math.Vec3d;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
//#if MC>=12105
//#else
import net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket;
//#endif
//#if MC>=12005
//$$ import net.minecraft.network.packet.s2c.common.ServerTransferS2CPacket;
//#endif
@@ -501,7 +505,9 @@ public class FullReplaySender extends ChannelInboundHandlerAdapter implements Re
//#if MC<11600
//$$ || packet instanceof EntitySpawnGlobalS2CPacket
//#endif
//#if MC<12105
|| packet instanceof ExperienceOrbSpawnS2CPacket
//#endif
|| packet instanceof EntitiesDestroyS2CPacket;
if (!relevantPacket) {
return; // don't want to do it too often, only when there's likely to be a dead entity

View File

@@ -11,6 +11,15 @@ import net.minecraft.client.util.ScreenshotUtils;
import static com.replaymod.core.versions.MCVer.popMatrix;
import static com.replaymod.core.versions.MCVer.pushMatrix;
//#if MC>=12105
//$$ import com.mojang.blaze3d.buffers.BufferType;
//$$ import com.mojang.blaze3d.buffers.BufferUsage;
//$$ import com.mojang.blaze3d.buffers.GpuBuffer;
//$$ import com.mojang.blaze3d.systems.CommandEncoder;
//$$ import com.mojang.blaze3d.systems.GpuDevice;
//$$ import net.minecraft.client.texture.NativeImage;
//#endif
//#if MC>=12100
//$$ import net.minecraft.client.render.RenderTickCounter;
//#endif
@@ -66,6 +75,11 @@ public class NoGuiScreenshot {
// Render frame without GUI
pushMatrix();
//#if MC>=12105
//$$ RenderSystem.getDevice()
//$$ .createCommandEncoder()
//$$ .clearColorAndDepthTextures(mc.getFramebuffer().getColorAttachment(), 0, mc.getFramebuffer().getDepthAttachment(), 1);
//#else
GlStateManager.clear(
16640
//#if MC>=11400 && MC<12102
@@ -73,6 +87,7 @@ public class NoGuiScreenshot {
//#endif
);
mc.getFramebuffer().beginWrite(true);
//#endif
//#if MC<11904
GlStateManager.enableTexture();
//#endif
@@ -98,11 +113,15 @@ public class NoGuiScreenshot {
//#endif
//#endif
//#if MC<12105
mc.getFramebuffer().endWrite();
//#endif
popMatrix();
//#if MC<12105
pushMatrix();
mc.getFramebuffer().draw(frameWidth, frameHeight);
popMatrix();
//#endif
} catch (Throwable t) {
future.setException(t);
return;
@@ -114,7 +133,24 @@ public class NoGuiScreenshot {
// The frame without GUI has been rendered
// Read it, create the screenshot and finish the future
try {
//#if MC>=11400
//#if MC>=12105
//$$ Image image;
//$$ GpuDevice device = RenderSystem.getDevice();
//$$ try (GpuBuffer gpuBuffer = device.createBuffer(null, BufferType.PIXEL_PACK, BufferUsage.STATIC_READ, frameWidth * frameHeight * 4)) {
//$$ CommandEncoder cmd = device.createCommandEncoder();
//$$ cmd.copyTextureToBuffer(mc.getFramebuffer().getColorAttachment(), gpuBuffer, 0, () -> {}, 0);
//$$ try (GpuBuffer.ReadView readView = cmd.readBuffer(gpuBuffer)) {
//$$ NativeImage nativeImage = new NativeImage(frameWidth, frameHeight, false);
//$$ for (int y = 0; y < frameHeight; ++y) {
//$$ for (int x = 0; x < frameWidth; ++x) {
//$$ int color = readView.data().getInt((x + y * frameWidth) * 4);
//$$ nativeImage.setColor(x, frameHeight - y - 1, 0xff000000 | color);
//$$ }
//$$ }
//$$ image = new Image(nativeImage);
//$$ }
//$$ }
//#elseif MC>=11400
Image image = new Image(ScreenshotUtils.takeScreenshot(
//#if MC<11701
frameWidth, frameHeight,

View File

@@ -45,6 +45,10 @@ import net.minecraft.network.ClientConnection;
import java.io.IOException;
import java.util.*;
//#if MC>=12105
//$$ import net.minecraft.entity.PositionInterpolator;
//#endif
//#if MC>=12102
//$$ import com.mojang.blaze3d.systems.ProjectionType;
//#endif
@@ -713,22 +717,32 @@ public class ReplayHandler {
// Perform the rendering using OpenGL
pushMatrix();
//#if MC>=12105
//$$ RenderSystem.getDevice()
//$$ .createCommandEncoder()
//$$ .clearColorAndDepthTextures(mc.getFramebuffer().getColorAttachment(), 0, mc.getFramebuffer().getDepthAttachment(), 1);
//#else
GlStateManager.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
//#if MC>=11400 && MC<12102
, true
//#endif
);
//#endif
//#if MC<11904
GlStateManager.enableTexture();
//#endif
//#if MC<12105
mc.getFramebuffer().beginWrite(true);
//#endif
Window window = mc.getWindow();
//#if MC>=11500
//#if MC<12105
//#if MC>=12102
//$$ RenderSystem.clear(256);
//#else
RenderSystem.clear(256, MinecraftClient.IS_SYSTEM_MAC);
//#endif
//#endif
//#if MC>=11700
//$$ RenderSystem.setProjectionMatrix(Matrix4f.projectionMatrix(
//$$ 0,
@@ -788,10 +802,16 @@ public class ReplayHandler {
//#endif
guiScreen.toMinecraft().removed();
//#if MC<12105
mc.getFramebuffer().endWrite();
//#endif
popMatrix();
pushMatrix();
//#if MC>=12105
//$$ mc.getFramebuffer().blitToScreen();
//#else
mc.getFramebuffer().draw(mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight());
//#endif
popMatrix();
//#if MC>=12102
@@ -861,7 +881,13 @@ public class ReplayHandler {
}
private void skipTeleportInterpolation(Entity entity) {
//#if MC>=11400
//#if MC>=12105
//$$ PositionInterpolator i = entity.getInterpolator();
//$$ if (i != null && i.isInterpolating()) {
//$$ entity.refreshPositionAndAngles(i.getLerpedPos(), i.getLerpedYaw(), i.getLerpedPitch());
//$$ i.clear();
//$$ }
//#elseif MC>=11400
if (entity instanceof LivingEntity && !(entity instanceof CameraEntity)) {
LivingEntity e = (LivingEntity) entity;
EntityLivingBaseAccessor ea = (EntityLivingBaseAccessor) e;

View File

@@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(LivingEntity.class)
public interface EntityLivingBaseAccessor {
//#if MC>=11400
//#if MC>=11400 && MC<12105
@Accessor("serverX")
double getInterpTargetX();
@Accessor("serverY")

View File

@@ -37,9 +37,17 @@ import static de.johni0702.minecraft.gui.versions.MCVer.popScissorState;
import static de.johni0702.minecraft.gui.versions.MCVer.pushScissorState;
import static de.johni0702.minecraft.gui.versions.MCVer.setScissorDisabled;
//#if MC>=12105
//$$ import net.minecraft.client.render.RenderLayer;
//$$ import net.minecraft.client.render.VertexConsumer;
//$$ import net.minecraft.client.render.VertexConsumerProvider;
//#endif
//#if MC>=12102
//#if MC<12105
//$$ import net.minecraft.client.gl.ShaderProgramKeys;
//#endif
//#endif
//#if MC>=11700
//$$ import com.mojang.blaze3d.systems.RenderSystem;
@@ -157,6 +165,11 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
float positionXKeyframeTimeline = positonX + KEYFRAME_SIZE / 2f;
final int color = 0xff0000ff;
//#if MC>=12105
//$$ VertexConsumerProvider.Immediate immediate = getMinecraft().getBufferBuilders().getEntityVertexConsumers();
//$$ immediate.draw();
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayer.LINE_STRIP);
//#else
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINE_STRIP, VertexFormats.LINES);
@@ -164,6 +177,7 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINE_STRIP, VertexFormats.POSITION_COLOR);
//#endif
//#endif
// Start just below the top border of the replay timeline
Vector2f p1 = new Vector2f(replayTimelineLeft + positionXReplayTimeline, replayTimelineTop + BORDER_TOP);
@@ -179,6 +193,13 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
emitLine(matrixStack, buffer, p2, p3, color);
emitLine(matrixStack, buffer, p3, p4, color);
pushScissorState();
setScissorDisabled();
GL11.glLineWidth(2);
//#if MC>=12105
//$$ immediate.draw();
//#else
//#if MC>=12102
//$$ RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
//#elseif MC>=11700
@@ -187,9 +208,6 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glDisable(GL11.GL_TEXTURE_2D);
//#endif
pushScissorState();
setScissorDisabled();
GL11.glLineWidth(2);
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
@@ -197,11 +215,13 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
//#else
tessellator.draw();
//#endif
popScissorState();
//#if MC<11700
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
//#endif
//#endif
popScissorState();
}
}
});

View File

@@ -30,9 +30,17 @@ import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
import org.lwjgl.opengl.GL11;
//#if MC>=12105
//$$ import net.minecraft.client.render.RenderLayer;
//$$ import net.minecraft.client.render.VertexConsumer;
//$$ import net.minecraft.client.render.VertexConsumerProvider;
//#endif
//#if MC>=12102
//#if MC<12105
//$$ import net.minecraft.client.gl.ShaderProgramKeys;
//#endif
//#endif
//#if MC>=11700
//$$ import net.minecraft.client.render.GameRenderer;
@@ -173,9 +181,11 @@ public class PathPreviewRenderer extends EventRegistrations {
}
}
//#if MC<12105
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR);
GL11.glDisable(GL11.GL_DEPTH_TEST);
//#endif
//#if MC<11700
GL11.glEnable(GL11.GL_TEXTURE_2D);
//#endif
@@ -188,8 +198,10 @@ public class PathPreviewRenderer extends EventRegistrations {
.sorted(new KeyframeComparator(viewPos)) // Need to render the furthest first
.forEachOrdered(p -> drawPoint(viewPos, p.getRight(), p.getLeft()));
//#if MC<12105
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_DEPTH_TEST);
//#endif
int time = guiPathing.timeline.getCursorPosition();
Optional<Integer> entityId = path.getValue(SpectatorProperty.PROPERTY, time);
@@ -214,11 +226,13 @@ public class PathPreviewRenderer extends EventRegistrations {
}
} finally {
popMatrix();
//#if MC<12105
//#if MC>=11700
//$$ GL11.glDisable(GL11.GL_BLEND);
//#else
GL11.glPopAttrib();
//#endif
//#endif
}
}
@@ -252,6 +266,11 @@ public class PathPreviewRenderer extends EventRegistrations {
if (distanceSquared(view, pos1) > renderDistanceSquared) return;
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
//#if MC>=12105
//$$ VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
//$$ immediate.draw();
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayer.LINES);
//#else
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINES, VertexFormats.LINES);
@@ -259,9 +278,15 @@ public class PathPreviewRenderer extends EventRegistrations {
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
//#endif
//#endif
emitLine(new MatrixStack(), buffer, Vector3f.sub(pos1, view, null), Vector3f.sub(pos2, view, null), color);
GL11.glLineWidth(3);
//#if MC>=12105
//$$ immediate.draw();
//#else
//#if MC>=11700
//#if MC>=12102
//$$ RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
@@ -270,7 +295,6 @@ public class PathPreviewRenderer extends EventRegistrations {
//#endif
//$$ RenderSystem.disableCull();
//#endif
GL11.glLineWidth(3);
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
@@ -281,6 +305,7 @@ public class PathPreviewRenderer extends EventRegistrations {
//#if MC>=11700
//$$ RenderSystem.enableCull();
//#endif
//#endif
}
private void drawPoint(Vector3f view, Vector3f pos, Keyframe keyframe) {
@@ -304,18 +329,24 @@ public class PathPreviewRenderer extends EventRegistrations {
float maxX = 0.5f;
float maxY = 0.5f;
//#if MC>=12105
//$$ VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
//$$ immediate.draw();
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayer.getGuiTexturedOverlay(TEXTURE));
//#else
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
//#else
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE);
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
//#endif
//#endif
buffer.vertex(minX, minY, 0).texture(posX + size, posY + size).next();
buffer.vertex(minX, maxY, 0).texture(posX + size, posY).next();
buffer.vertex(maxX, maxY, 0).texture(posX, posY).next();
buffer.vertex(maxX, minY, 0).texture(posX, posY + size).next();
buffer.vertex(minX, minY, 0).texture(posX + size, posY + size).color(255, 255, 255, 255).next();
buffer.vertex(minX, maxY, 0).texture(posX + size, posY).color(255, 255, 255, 255).next();
buffer.vertex(maxX, maxY, 0).texture(posX, posY).color(255, 255, 255, 255).next();
buffer.vertex(maxX, minY, 0).texture(posX, posY + size).color(255, 255, 255, 255).next();
pushMatrix();
@@ -324,11 +355,14 @@ public class PathPreviewRenderer extends EventRegistrations {
GL11.glRotatef(-mc.getEntityRenderDispatcher().camera.getYaw(), 0, 1, 0);
GL11.glRotatef(mc.getEntityRenderDispatcher().camera.getPitch(), 1, 0, 0);
//#if MC>=12105
//$$ immediate.draw();
//#else
//#if MC>=12102
//$$ RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX);
//$$ RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
//#elseif MC>=11700
//$$ RenderSystem.applyModelViewMatrix();
//$$ RenderSystem.setShader(GameRenderer::getPositionTexShader);
//$$ RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
//#endif
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
@@ -337,6 +371,7 @@ public class PathPreviewRenderer extends EventRegistrations {
//#else
tessellator.draw();
//#endif
//#endif
popMatrix();
}
@@ -354,6 +389,11 @@ public class PathPreviewRenderer extends EventRegistrations {
GL11.glRotatef(rot.z, 0, 0, 1); // Roll
//draw the position line
//#if MC>=12105
//$$ VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
//$$ immediate.draw();
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayer.LINES);
//#else
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINES, VertexFormats.LINES);
@@ -361,9 +401,13 @@ public class PathPreviewRenderer extends EventRegistrations {
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
//#endif
//#endif
emitLine(new MatrixStack(), buffer, new Vector3f(0, 0, 0), new Vector3f(0, 0, 2), 0x00ff00aa);
//#if MC>=12105
//$$ immediate.draw();
//#else
//#if MC>=12102
//$$ RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
//#elseif MC>=11700
@@ -384,6 +428,7 @@ public class PathPreviewRenderer extends EventRegistrations {
//#if MC<11700
GL11.glEnable(GL11.GL_TEXTURE_2D);
//#endif
//#endif
// draw camera cube
@@ -395,7 +440,9 @@ public class PathPreviewRenderer extends EventRegistrations {
double r = -cubeSize/2;
//#endif
//#if MC>=12100
//#if MC>=12105
//$$ buffer = immediate.getBuffer(RenderLayer.getGuiTextured(CAMERA_HEAD));
//#elseif 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);
@@ -437,6 +484,9 @@ public class PathPreviewRenderer extends EventRegistrations {
buffer.vertex(r + cubeSize, r + cubeSize, r + cubeSize).texture(2*8/64f, 8/64f).color(255, 255, 255, 200).next();
buffer.vertex(r + cubeSize, r + cubeSize, r).texture(2 * 8 / 64f, 0).color(255, 255, 255, 200).next();
//#if MC>=12105
//$$ immediate.draw();
//#else
//#if MC>=12102
//$$ RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
//#elseif MC>=11700
@@ -450,6 +500,7 @@ public class PathPreviewRenderer extends EventRegistrations {
//#else
tessellator.draw();
//#endif
//#endif
popMatrix();
}

0
versions/1.21.5/.gitkeep Normal file
View File

View File

@@ -0,0 +1,2 @@
com.mojang.blaze3d.vertex.VertexFormat net.minecraft.client.render.VertexFormat
com.mojang.blaze3d.vertex.VertexFormatElement net.minecraft.client.render.VertexFormatElement