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

@@ -5,8 +5,8 @@ import com.replaymod.render.blend.data.DMaterial;
import com.replaymod.render.blend.data.DPackedFile;
import com.replaymod.render.blend.data.DTexture;
import de.johni0702.minecraft.gui.versions.Image;
import net.minecraft.client.util.GlAllocationUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import java.io.ByteArrayOutputStream;
@@ -25,7 +25,7 @@ public class BlendMaterials {
// Read raw image data from GL
int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
ByteBuffer buffer = GlAllocationUtils.allocateByteBuffer(width * height * 4);
ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4);
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
// Convert to Image

View File

@@ -5,13 +5,13 @@ import de.johni0702.minecraft.gui.utils.lwjgl.vector.Matrix4f;
import de.johni0702.minecraft.gui.utils.lwjgl.vector.Quaternion;
import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector3f;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.GlAllocationUtils;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntity;
import org.blender.dna.Link;
import org.blender.dna.ListBase;
import org.blender.utils.BlenderFactory;
import org.cakelab.blender.nio.CPointer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import java.io.IOException;
@@ -39,7 +39,7 @@ public class Util {
}
}
private static FloatBuffer floatBuffer = GlAllocationUtils.allocateByteBuffer(16 * 4).asFloatBuffer();
private static FloatBuffer floatBuffer = BufferUtils.createByteBuffer(16 * 4).asFloatBuffer();
public static Matrix4f getGlMatrix(int matrix) {
floatBuffer.clear();
//#if MC>=11400

View File

@@ -19,9 +19,11 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
private static final Identifier vertexResource = new Identifier("replaymod", "shader/ods.vert");
private static final Identifier fragmentResource = new Identifier("replaymod", "shader/ods.frag");
private static final Identifier vertexResource = identifier("replaymod", "shader/ods.vert");
private static final Identifier fragmentResource = identifier("replaymod", "shader/ods.frag");
private final CubicPboOpenGlFrameCapturer left, right;
private final Program shaderProgram;

View File

@@ -27,8 +27,10 @@ import net.minecraft.client.texture.NativeImage;
import java.nio.ByteBuffer;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
public class GuiVideoRenderer extends GuiScreen implements Tickable {
private static final Identifier NO_PREVIEW_TEXTURE = new Identifier("replaymod", "logo.png");
private static final Identifier NO_PREVIEW_TEXTURE = identifier("replaymod", "logo.png");
private final VideoRenderer renderer;

View File

@@ -93,7 +93,9 @@ public class EntityRendererHandler extends EventRegistrations implements WorldRe
gameRenderer.setRenderHand(false); // makes no sense, we wouldn't even know where to put it
}
//#if MC>=11400
//#if MC>=12100
//$$ mc.gameRenderer.render(mc.getRenderTickCounter(), true);
//#elseif MC>=11400
mc.gameRenderer.render(partialTicks, finishTimeNano, true);
//#else
//$$ mc.setIngameNotInFocus(); // this should already be the case but it somehow still sometimes is not

View File

@@ -36,7 +36,11 @@ public abstract class Mixin_Omnidirectional_Rotation {
}
//#if MC>=12005
//#if MC>=12100
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotation(Lorg/joml/Quaternionfc;)Lorg/joml/Matrix4f;"))
//#else
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;"))
//#endif
//$$ private Matrix4f replayModRender_setupCubicFrameRotation(Matrix4f matrix) {
//#else
//#if MC>=11500

View File

@@ -35,7 +35,11 @@ public abstract class Mixin_Stereoscopic_Camera implements EntityRendererHandler
}
//#if MC>=12005
//#if MC>=12100
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotation(Lorg/joml/Quaternionfc;)Lorg/joml/Matrix4f;"))
//#else
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;"))
//#endif
//$$ private Matrix4f replayModRender_setupStereoscopicProjection(Matrix4f matrix) {
//#else
@Inject(method = "renderWorld", at = @At("HEAD"))

View File

@@ -5,6 +5,7 @@ import com.replaymod.core.mixin.MinecraftAccessor;
import com.replaymod.core.mixin.TimerAccessor;
import com.replaymod.core.versions.MCVer;
import com.replaymod.pathing.player.AbstractTimelinePlayer;
import com.replaymod.pathing.player.ReplayTimer;
import com.replaymod.pathing.properties.TimestampProperty;
import com.replaymod.render.CameraPathExporter;
import com.replaymod.render.EXRWriter;
@@ -37,7 +38,6 @@ import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.crash.CrashException;
import net.minecraft.sound.SoundCategory;
import net.minecraft.client.render.RenderTickCounter;
import org.lwjgl.glfw.GLFW;
//#if MC>=12000
@@ -87,11 +87,12 @@ import static com.google.common.collect.Iterables.getLast;
import static com.replaymod.core.utils.Utils.DEFAULT_MS_PER_TICK;
import static com.replaymod.core.versions.MCVer.*;
import static com.replaymod.render.ReplayModRender.LOGGER;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
public class VideoRenderer implements RenderInfo {
private static final Identifier SOUND_RENDER_SUCCESS = new Identifier("replaymod", "render_success");
private static final Identifier SOUND_RENDER_SUCCESS = identifier("replaymod", "render_success");
private final MinecraftClient mc = MCVer.getMinecraft();
private final RenderSettings settings;
private final ReplayHandler replayHandler;
@@ -191,7 +192,7 @@ public class VideoRenderer implements RenderInfo {
// Because this might take some time to prepare we'll render the GUI at least once to not confuse the user
drawGui();
RenderTickCounter timer = ((MinecraftAccessor) mc).getTimer();
ReplayTimer timer = (ReplayTimer) ((MinecraftAccessor) mc).getTimer();
// Play up to one second before starting to render
// This is necessary in order to ensure that all entities have at least two position packets
@@ -268,7 +269,7 @@ public class VideoRenderer implements RenderInfo {
}
// Updating the timer will cause the timeline player to update the game state
RenderTickCounter timer = ((MinecraftAccessor) mc).getTimer();
ReplayTimer timer = (ReplayTimer) ((MinecraftAccessor) mc).getTimer();
//#if MC>=11600
int elapsedTicks =
//#endif
@@ -276,6 +277,9 @@ public class VideoRenderer implements RenderInfo {
//#if MC>=11400
MCVer.milliTime()
//#endif
//#if MC>=12100
//$$ , true
//#endif
);
//#if MC<11600
//$$ int elapsedTicks = timer.ticksThisFrame;