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

@@ -22,6 +22,7 @@ import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.util.InputUtil;
import net.minecraft.util.Identifier;
import static com.replaymod.core.ReplayMod.MOD_ID;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
//#else
//$$ import net.minecraftforge.fml.client.registry.ClientRegistry;
//#endif
@@ -66,7 +67,7 @@ public class KeyBindingRegistry extends EventRegistrations {
if (keyCode == 0) {
keyCode = -1;
}
Identifier id = new Identifier(MOD_ID, name.substring(LangResourcePack.LEGACY_KEY_PREFIX.length()));
Identifier id = identifier(MOD_ID, name.substring(LangResourcePack.LEGACY_KEY_PREFIX.length()));
//#if MC>=11600
String key = String.format("key.%s.%s", id.getNamespace(), id.getPath());
KeyBinding keyBinding = new KeyBinding(key, InputUtil.Type.KEYSYM, keyCode, CATEGORY);

View File

@@ -36,6 +36,8 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
//#if MC>=12006
//$$ import net.minecraft.resource.ResourcePackInfo;
//$$ import net.minecraft.resource.ResourcePackSource;
@@ -52,9 +54,9 @@ public class ReplayMod implements Module, Scheduler {
public static final String MOD_ID = "replaymod";
public static final Identifier TEXTURE = new Identifier("replaymod", "replay_gui.png");
public static final Identifier TEXTURE = identifier("replaymod", "replay_gui.png");
public static final int TEXTURE_SIZE = 256;
public static final Identifier LOGO_FAVICON = new Identifier("replaymod", "favicon_logo.png");
public static final Identifier LOGO_FAVICON = identifier("replaymod", "favicon_logo.png");
private static final MinecraftClient mc = MCVer.getMinecraft();

View File

@@ -6,8 +6,10 @@ import de.johni0702.minecraft.gui.element.GuiButton;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
import net.minecraft.util.Identifier;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
public class GuiReplayButton extends GuiButton {
public static final Identifier ICON = new Identifier("replaymod", "logo_button.png");
public static final Identifier ICON = identifier("replaymod", "logo_button.png");
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {

View File

@@ -29,6 +29,13 @@ import java.util.concurrent.CompletableFuture;
@Mixin(MinecraftClient.class)
public interface MinecraftAccessor {
//#if MC>=12100
//$$ @Accessor("renderTickCounter")
//$$ RenderTickCounter.Dynamic getTimer();
//$$ @Accessor("renderTickCounter")
//$$ @Mutable
//$$ void setTimer(RenderTickCounter.Dynamic value);
//#else
@Accessor("renderTickCounter")
RenderTickCounter getTimer();
@Accessor("renderTickCounter")
@@ -36,6 +43,7 @@ public interface MinecraftAccessor {
@Mutable
//#endif
void setTimer(RenderTickCounter value);
//#endif
//#if MC>=11400
@Accessor

View File

@@ -48,16 +48,22 @@ public abstract class MixinMinecraft
}
//#endif
//#if MC>=12100
//$$ private static final String GAME_RENDERER_RENDER = "Lnet/minecraft/client/render/GameRenderer;render(Lnet/minecraft/client/render/RenderTickCounter;Z)V";
//#else
private static final String GAME_RENDERER_RENDER = "Lnet/minecraft/client/render/GameRenderer;render(FJZ)V";
//#endif
@Inject(method = "render",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/render/GameRenderer;render(FJZ)V"))
target = GAME_RENDERER_RENDER))
private void preRender(boolean unused, CallbackInfo ci) {
PreRenderCallback.EVENT.invoker().preRender();
}
@Inject(method = "render",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/render/GameRenderer;render(FJZ)V",
target = GAME_RENDERER_RENDER,
shift = At.Shift.AFTER))
private void postRender(boolean unused, CallbackInfo ci) {
PostRenderCallback.EVENT.invoker().postRender();

View File

@@ -5,7 +5,11 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
//#if MC>=12100
//$$ @Mixin(RenderTickCounter.Dynamic.class)
//#else
@Mixin(RenderTickCounter.class)
//#endif
public interface TimerAccessor {
//#if MC>=11200
@Accessor("tickTime")

View File

@@ -10,6 +10,7 @@ import net.minecraft.network.PacketByteBuf;
//#if MC>=10904
import net.minecraft.util.Identifier;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
//#endif
//#if MC<=10710 || MC>=12002
@@ -22,7 +23,7 @@ import net.minecraft.util.Identifier;
*/
public class Restrictions {
//#if MC>=11400
public static final Identifier PLUGIN_CHANNEL = new Identifier("replaymod", "restrict");
public static final Identifier PLUGIN_CHANNEL = identifier("replaymod", "restrict");
//#else
//$$ public static final String PLUGIN_CHANNEL = "Replay|Restrict";
//#endif
@@ -77,7 +78,7 @@ public class Restrictions {
}
//#if MC>=12006
//$$ public static final CustomPayload.Id<Payload> ID = CustomPayload.id(PLUGIN_CHANNEL.toString());
//$$ public static final CustomPayload.Id<Payload> ID = new CustomPayload.Id<>(PLUGIN_CHANNEL);
//$$ public static final PacketCodec<? super PacketByteBuf, Payload> CODEC = PacketCodec.ofStatic(
//$$ (buf, payload) -> buf.writeBytes(payload.bytes()),
//$$ buf -> {

View File

@@ -68,6 +68,10 @@ import java.util.function.Consumer;
import static com.replaymod.core.versions.MCVer.getMinecraft;
//#if MC>=12100
//$$ import net.minecraft.util.crash.ReportType;
//#endif
public class Utils {
private static Logger LOGGER = LogManager.getLogger();
@@ -248,7 +252,11 @@ public class Utils {
public static GuiInfoPopup error(Logger logger, GuiContainer container, CrashReport crashReport, Runnable onClose) {
// Convert crash report to string
String crashReportStr = crashReport.asString();
String crashReportStr = crashReport.asString(
//#if MC>=12100
//$$ ReportType.MINECRAFT_CRASH_REPORT
//#endif
);
// Log via logger
logger.error(crashReportStr);
@@ -259,7 +267,11 @@ public class Utils {
File folder = new File(getMinecraft().runDirectory, "crash-reports");
File file = new File(folder, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt");
logger.debug("Saving crash report to file: {}", file);
//#if MC>=12100
//$$ crashReport.writeToFile(file.toPath(), ReportType.MINECRAFT_CRASH_REPORT);
//#else
crashReport.writeToFile(file);
//#endif
} catch (Throwable t) {
logger.error("Saving crash report file:", t);
}

View File

@@ -28,6 +28,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import static de.johni0702.minecraft.gui.versions.MCVer.identifier;
//#if FABRIC>=1
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
@@ -253,7 +255,7 @@ public class LangResourcePack extends AbstractFileResourcePack {
.map(LANG_FILE_NAME_PATTERN::matcher)
.filter(Matcher::matches)
.map(matcher -> String.format("%s_%s.json", matcher.group(1), matcher.group(1)))
.map(name -> new Identifier(ReplayMod.MOD_ID, "lang/" + name))
.map(name -> identifier(ReplayMod.MOD_ID, "lang/" + name))
.forEach(consumer);
} catch (IOException e) {
e.printStackTrace();

View File

@@ -454,13 +454,15 @@ public class MCVer {
//#if MC>=11700
//$$ .normal(n.x, n.y, n.z)
//#endif
.next();
;
buffer.next();
buffer.vertex(p2.x, p2.y, p2.z)
.color(r, g, b, a)
//#if MC>=11700
//$$ .normal(n.x, n.y, n.z)
//#endif
.next();
;
buffer.next();
}
public static void bindTexture(Identifier id) {

View File

@@ -46,6 +46,7 @@ import org.lwjgl.opengl.GL11;
//#endif
//#if MC>=11600
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.Matrix4f;
@@ -367,6 +368,9 @@ class Patterns {
//#endif
}
//#if MC>=12100
//$$ @Pattern private static void Tessellator_getBuffer() {}
//#else
@Pattern
private static BufferBuilder Tessellator_getBuffer(Tessellator tessellator) {
//#if MC>=10800
@@ -375,6 +379,20 @@ class Patterns {
//$$ return new BufferBuilder(tessellator);
//#endif
}
//#endif
//#if MC>=11600
@Pattern
private static void VertexConsumer_next(VertexConsumer buffer) {
//#if MC>=12100
//$$ buffer./*next()*/getClass();
//#else
buffer.next();
//#endif
}
//#else
//$$ private static void VertexConsumer_next() {}
//#endif
//#if MC<11700
@Pattern
@@ -477,7 +495,9 @@ class Patterns {
@Pattern
private static float getRenderPartialTicks(MinecraftClient mc) {
//#if MC>=10900
//#if MC>=12100
//$$ return mc.getRenderTickCounter().getTickDelta(true);
//#elseif MC>=10900
return mc.getTickDelta();
//#else
//$$ return ((com.replaymod.core.mixin.MinecraftAccessor) mc).getTimer().renderPartialTicks;
@@ -524,7 +544,7 @@ class Patterns {
//#endif
}
//#if MC>=11600
//#if MC>=11600 && MC<12100
@Pattern
private static void BufferBuilder_beginLineStrip(BufferBuilder buffer, VertexFormat vertexFormat) {
//#if MC>=11700

View File

@@ -9,6 +9,10 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
//#if MC>=12100
//$$ import net.minecraft.util.crash.ReportType;
//#endif
public class SchedulerImpl implements Scheduler {
private static final MinecraftClient mc = MinecraftClient.getInstance();
@@ -113,7 +117,11 @@ public class SchedulerImpl implements Scheduler {
runnable.run();
} catch (CrashException e) {
e.printStackTrace();
//#if MC>=12100
//$$ System.err.println(e.getReport().asString(ReportType.MINECRAFT_CRASH_REPORT));
//#else
System.err.println(e.getReport().asString());
//#endif
mc.setCrashReport(e.getReport());
} finally {
inRunLater = false;

View File

@@ -31,7 +31,11 @@ public abstract class AbstractTimelinePlayer extends EventRegistrations {
private Timeline timeline;
protected long startOffset;
private boolean wasAsyncMode;
//#if MC>=12100
//$$ private RenderTickCounter.Dynamic orgTimer;
//#else
private RenderTickCounter orgTimer;
//#endif
private long lastTime;
private long lastTimestamp;
private ListenableFuture<Void> future;

View File

@@ -6,7 +6,11 @@ import net.minecraft.client.render.RenderTickCounter;
/**
* A timer that does not advance by itself.
*/
//#if MC>=12100
//$$ public class ReplayTimer extends RenderTickCounter.Dynamic {
//#else
public class ReplayTimer extends RenderTickCounter {
//#endif
//#if MC>=11600
public int ticksThisFrame;
//#endif
@@ -37,13 +41,28 @@ public class ReplayTimer extends RenderTickCounter {
//#if MC>=11400
long sysClock
//#endif
//#if MC>=12100
//$$ , boolean tick
//#endif
) {
//#if MC>=12100
//$$ if (!tick) return 0;
//#endif
UpdatedCallback.EVENT.invoker().onUpdate();
//#if MC>=11600
return ticksThisFrame;
//#endif
}
//#if MC>=12100
//$$ public float tickDelta;
//$$
//$$ @Override
//$$ public float getTickDelta(boolean bl) {
//$$ return tickDelta;
//$$ }
//#endif
public interface UpdatedCallback {
Event<UpdatedCallback> EVENT = Event.create((listeners) ->
() -> {

View File

@@ -113,7 +113,21 @@ public class RecordingEventHandler extends EventRegistrations {
try {
ClientPlayerEntity player = mc.player;
assert player != null;
//#if MC>=12002
//#if MC>=12100
//$$ packetListener.save(new EntitySpawnS2CPacket(
//$$ player.getId(),
//$$ player.getUuid(),
//$$ player.getX(),
//$$ player.getY(),
//$$ player.getZ(),
//$$ player.getPitch(),
//$$ player.getYaw(),
//$$ player.getType(),
//$$ 0,
//$$ player.getVelocity(),
//$$ player.getHeadYaw()
//$$ ));
//#elseif MC>=12002
//$$ packetListener.save(new EntitySpawnS2CPacket(player));
//#else
packetListener.save(new PlayerSpawnS2CPacket(player));

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;

View File

@@ -11,6 +11,10 @@ import net.minecraft.client.util.ScreenshotUtils;
import static com.replaymod.core.versions.MCVer.popMatrix;
import static com.replaymod.core.versions.MCVer.pushMatrix;
//#if MC>=12100
//$$ import net.minecraft.client.render.RenderTickCounter;
//#endif
//#if MC>=11500
import net.minecraft.client.util.math.MatrixStack;
//#endif
@@ -73,6 +77,9 @@ public class NoGuiScreenshot {
GlStateManager.enableTexture();
//#endif
//#if MC>=12100
//$$ mc.gameRenderer.renderWorld(RenderTickCounter.ONE);
//#else
float tickDelta = mc.getTickDelta();
//#if MC>=12006
//$$ mc.gameRenderer.renderWorld(tickDelta, System.nanoTime());
@@ -89,6 +96,7 @@ public class NoGuiScreenshot {
//#endif
//#endif
//#endif
//#endif
mc.getFramebuffer().endWrite();
popMatrix();

View File

@@ -22,7 +22,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinCamera {
@Shadow @Final private MinecraftClient client;
//#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 applyRoll(Matrix4f matrix) {
//#else
@Inject(

View File

@@ -153,8 +153,12 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
final int color = 0xff0000ff;
Tessellator tessellator = Tessellator.getInstance();
//#if MC>=12100
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINE_STRIP, VertexFormats.LINES);
//#else
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINE_STRIP, VertexFormats.POSITION_COLOR);
//#endif
// Start just below the top border of the replay timeline
Vector2f p1 = new Vector2f(replayTimelineLeft + positionXReplayTimeline, replayTimelineTop + BORDER_TOP);
@@ -178,7 +182,13 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
pushScissorState();
setScissorDisabled();
GL11.glLineWidth(2);
//#if MC>=12100
//$$ try (var builtBuffer = buffer.end()) {
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
//$$ }
//#else
tessellator.draw();
//#endif
popScissorState();
//#if MC<11700
GL11.glEnable(GL11.GL_TEXTURE_2D);

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();
}