mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 14:38:50 +00:00
0.3.1
This commit is contained in:
1 parent
60f19e7662
commit
fcf1b4168f
26 files changed
+489
-65
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ yarn_mappings=1.21+build.9
|
|||||||
loader_version=0.15.11
|
loader_version=0.15.11
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.3.0
|
mod_version=0.3.1
|
||||||
maven_group=com.moulberry.flashback
|
maven_group=com.moulberry.flashback
|
||||||
archives_base_name=flashback
|
archives_base_name=flashback
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package com.moulberry.flashback;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.realmsclient.RealmsMainScreen;
|
import com.mojang.realmsclient.RealmsMainScreen;
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
import com.moulberry.flashback.action.*;
|
import com.moulberry.flashback.action.*;
|
||||||
|
import com.moulberry.flashback.command.BetterColorArgument;
|
||||||
import com.moulberry.flashback.configuration.FlashbackConfig;
|
import com.moulberry.flashback.configuration.FlashbackConfig;
|
||||||
import com.moulberry.flashback.exporting.ExportJob;
|
import com.moulberry.flashback.exporting.ExportJob;
|
||||||
import com.moulberry.flashback.ext.MinecraftExt;
|
import com.moulberry.flashback.ext.MinecraftExt;
|
||||||
@@ -26,6 +29,7 @@ import com.moulberry.flashback.playback.ReplayServer;
|
|||||||
import com.moulberry.flashback.record.FlashbackMeta;
|
import com.moulberry.flashback.record.FlashbackMeta;
|
||||||
import com.moulberry.flashback.record.Recorder;
|
import com.moulberry.flashback.record.Recorder;
|
||||||
import com.moulberry.flashback.record.ReplayExporter;
|
import com.moulberry.flashback.record.ReplayExporter;
|
||||||
|
import com.moulberry.flashback.record.ReplayMarker;
|
||||||
import com.moulberry.flashback.screen.ConfigScreen;
|
import com.moulberry.flashback.screen.ConfigScreen;
|
||||||
import com.moulberry.flashback.screen.SaveReplayScreen;
|
import com.moulberry.flashback.screen.SaveReplayScreen;
|
||||||
import com.moulberry.flashback.visuals.ShaderManager;
|
import com.moulberry.flashback.visuals.ShaderManager;
|
||||||
@@ -40,6 +44,7 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
|||||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.FileUtil;
|
import net.minecraft.FileUtil;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -52,6 +57,7 @@ import net.minecraft.client.player.AbstractClientPlayer;
|
|||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.client.server.IntegratedServer;
|
import net.minecraft.client.server.IntegratedServer;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
|
import net.minecraft.commands.arguments.ColorArgument;
|
||||||
import net.minecraft.core.*;
|
import net.minecraft.core.*;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -77,6 +83,7 @@ import net.minecraft.world.level.storage.LevelStorageSource;
|
|||||||
import net.minecraft.world.level.storage.PrimaryLevelData;
|
import net.minecraft.world.level.storage.PrimaryLevelData;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.joml.Vector3f;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -210,6 +217,26 @@ public class Flashback implements ModInitializer, ClientModInitializer {
|
|||||||
flashback.then(ClientCommandManager.literal("finish").executes(this::finishRecordingReplay));
|
flashback.then(ClientCommandManager.literal("finish").executes(this::finishRecordingReplay));
|
||||||
flashback.then(ClientCommandManager.literal("end").executes(this::finishRecordingReplay));
|
flashback.then(ClientCommandManager.literal("end").executes(this::finishRecordingReplay));
|
||||||
flashback.then(ClientCommandManager.literal("config").executes(this::openFlashbackConfig));
|
flashback.then(ClientCommandManager.literal("config").executes(this::openFlashbackConfig));
|
||||||
|
flashback.then(ClientCommandManager.literal("mark")
|
||||||
|
.executes(command -> {
|
||||||
|
this.addMarker(command, null, null, null);
|
||||||
|
return 0;
|
||||||
|
}).then(ClientCommandManager.argument("color", BetterColorArgument.color()).executes(command -> {
|
||||||
|
int colour = command.getArgument("color", Integer.class);
|
||||||
|
this.addMarker(command, colour, null, null);
|
||||||
|
return 0;
|
||||||
|
}).then(ClientCommandManager.argument("savePosition", BoolArgumentType.bool()).executes(command -> {
|
||||||
|
int colour = command.getArgument("color", Integer.class);
|
||||||
|
boolean savePosition = command.getArgument("savePosition", Boolean.class);
|
||||||
|
this.addMarker(command, colour, savePosition, null);
|
||||||
|
return 0;
|
||||||
|
}).then(ClientCommandManager.argument("description", StringArgumentType.greedyString()).executes(command -> {
|
||||||
|
int colour = command.getArgument("color", Integer.class);
|
||||||
|
boolean savePosition = command.getArgument("savePosition", Boolean.class);
|
||||||
|
String description = command.getArgument("description", String.class);
|
||||||
|
this.addMarker(command, colour, savePosition, description);
|
||||||
|
return 0;
|
||||||
|
})))));
|
||||||
dispatcher.register(flashback);
|
dispatcher.register(flashback);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -256,6 +283,35 @@ public class Flashback implements ModInitializer, ClientModInitializer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addMarker(CommandContext<FabricClientCommandSource> command, @Nullable Integer colour, @Nullable Boolean savePosition, @Nullable String description) {
|
||||||
|
if (RECORDER == null) {
|
||||||
|
command.getSource().sendError(Component.literal("Not recording"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colour == null) {
|
||||||
|
colour = 0xFF5555;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReplayMarker.MarkerPosition position = null;
|
||||||
|
if (savePosition == null || savePosition) {
|
||||||
|
Entity camera = Minecraft.getInstance().getCameraEntity();
|
||||||
|
if (camera != null) {
|
||||||
|
position = new ReplayMarker.MarkerPosition(camera.getEyePosition().toVector3f(),
|
||||||
|
camera.level().dimension().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (description != null) {
|
||||||
|
description = description.trim();
|
||||||
|
if (description.isEmpty()) {
|
||||||
|
description = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RECORDER.addMarker(new ReplayMarker(colour, position, description));
|
||||||
|
}
|
||||||
|
|
||||||
private void deleteUnusedReplayStates() {
|
private void deleteUnusedReplayStates() {
|
||||||
Path flashbackDir = Flashback.getDataDirectory();
|
Path flashbackDir = Flashback.getDataDirectory();
|
||||||
Path replayDir = flashbackDir.resolve("replays");
|
Path replayDir = flashbackDir.resolve("replays");
|
||||||
|
|||||||
@@ -45,9 +45,11 @@ public enum VideoCodec implements ComboOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsTransparency() {
|
public boolean supportsTransparency() {
|
||||||
if (this == VP9) {
|
if (this == VP9 || this == H264 || this == H265) {
|
||||||
// VP9 supports transparency (yuva420p), but apparently most decoders for it do not. Let's not mark it as supporting transparency
|
// VP9 supports transparency (yuva420p), but apparently most decoders for it do not. Let's not mark it as supporting transparency
|
||||||
// See also: https://trac.ffmpeg.org/ticket/8468
|
// See also: https://trac.ffmpeg.org/ticket/8468
|
||||||
|
|
||||||
|
// H264/H265 sometimes claim to support transparency but don't, also ignore them as well
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.encoders == null) {
|
if (this.encoders == null) {
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.moulberry.flashback.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.StringReader;
|
||||||
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||||
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
|
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.commands.SharedSuggestionProvider;
|
||||||
|
import net.minecraft.commands.arguments.ColorArgument;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class BetterColorArgument implements ArgumentType<Integer> {
|
||||||
|
|
||||||
|
private static final Collection<String> EXAMPLES = Arrays.asList("red", "green");
|
||||||
|
public static final DynamicCommandExceptionType ERROR_INVALID_VALUE = new DynamicCommandExceptionType(object -> Component.translatableEscape("argument.color.invalid", object));
|
||||||
|
|
||||||
|
private BetterColorArgument() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BetterColorArgument color() {
|
||||||
|
return new BetterColorArgument();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer parse(StringReader stringReader) {
|
||||||
|
String string = stringReader.readUnquotedString();
|
||||||
|
|
||||||
|
ChatFormatting chatFormatting = ChatFormatting.getByName(string);
|
||||||
|
if (chatFormatting != null && chatFormatting.getColor() != null) {
|
||||||
|
return chatFormatting.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.startsWith("#")) {
|
||||||
|
string = string.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Integer.parseInt(string.trim(), 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> commandContext, SuggestionsBuilder suggestionsBuilder) {
|
||||||
|
return SharedSuggestionProvider.suggest(ChatFormatting.getNames(true, false), suggestionsBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> getExamples() {
|
||||||
|
return EXAMPLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -46,6 +46,10 @@ public class FlashbackConfig {
|
|||||||
@OptionDescription("flashback.option.hide_pause_menu_controls.description")
|
@OptionDescription("flashback.option.hide_pause_menu_controls.description")
|
||||||
public boolean hidePauseMenuControls = false;
|
public boolean hidePauseMenuControls = false;
|
||||||
|
|
||||||
|
@OptionCaption("flashback.option.mark_dimension_changes")
|
||||||
|
@OptionDescription("flashback.option.mark_dimension_changes.description")
|
||||||
|
public boolean markDimensionChanges = true;
|
||||||
|
|
||||||
public Set<String> openedWindows = new HashSet<>();
|
public Set<String> openedWindows = new HashSet<>();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.moulberry.flashback.keyframe.KeyframeType;
|
|||||||
import com.moulberry.flashback.keyframe.KeyframeRegistry;
|
import com.moulberry.flashback.keyframe.KeyframeRegistry;
|
||||||
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
||||||
import com.moulberry.flashback.keyframe.types.TimelapseKeyframeType;
|
import com.moulberry.flashback.keyframe.types.TimelapseKeyframeType;
|
||||||
|
import com.moulberry.flashback.record.ReplayMarker;
|
||||||
import com.moulberry.flashback.state.EditorStateHistoryAction;
|
import com.moulberry.flashback.state.EditorStateHistoryAction;
|
||||||
import com.moulberry.flashback.keyframe.impl.TimelapseKeyframe;
|
import com.moulberry.flashback.keyframe.impl.TimelapseKeyframe;
|
||||||
import com.moulberry.flashback.state.EditorStateHistoryEntry;
|
import com.moulberry.flashback.state.EditorStateHistoryEntry;
|
||||||
@@ -256,6 +257,12 @@ public class TimelineWindow {
|
|||||||
zoomBarHovered = mouseY >= y + height - zoomBarHeight && mouseY <= y + height &&
|
zoomBarHovered = mouseY >= y + height - zoomBarHeight && mouseY <= y + height &&
|
||||||
mouseX >= zoomBarMin && mouseX <= zoomBarMax;
|
mouseX >= zoomBarMin && mouseX <= zoomBarMax;
|
||||||
|
|
||||||
|
// Middle divider (x)
|
||||||
|
drawList.addLine(x + middleX, y + timestampHeight, x + middleX, y + height, -1);
|
||||||
|
|
||||||
|
// Middle divider (y)
|
||||||
|
drawList.addLine(0, y + middleY, width, y + middleY, -1);
|
||||||
|
|
||||||
renderKeyframeElements(replayServer, editorState, x, y + middleY, cursorTicks, middleX);
|
renderKeyframeElements(replayServer, editorState, x, y + middleY, cursorTicks, middleX);
|
||||||
|
|
||||||
drawList.pushClipRect(x + middleX, y, x + width, y + height);
|
drawList.pushClipRect(x + middleX, y, x + width, y + height);
|
||||||
@@ -267,6 +274,32 @@ public class TimelineWindow {
|
|||||||
drawList.popClipRect();
|
drawList.popClipRect();
|
||||||
|
|
||||||
renderSeparators(minorsPerMajor, x, middleX, minorSeparatorWidth, errorOffset, width, drawList, y, timestampHeight, middleY, minTicks, ticksPerMinor, showSubSeconds, majorSeparatorHeight, minorSeparatorHeight);
|
renderSeparators(minorsPerMajor, x, middleX, minorSeparatorWidth, errorOffset, width, drawList, y, timestampHeight, middleY, minTicks, ticksPerMinor, showSubSeconds, majorSeparatorHeight, minorSeparatorHeight);
|
||||||
|
|
||||||
|
// render markers
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int tick = minTicks; tick <= minTicks + availableTicks; tick++) {
|
||||||
|
Map.Entry<Integer, ReplayMarker> markerEntry = metadata.replayMarkers.ceilingEntry(tick);
|
||||||
|
if (markerEntry == null || markerEntry.getKey() > minTicks + availableTicks) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int markerTick = markerEntry.getKey();
|
||||||
|
ReplayMarker marker = markerEntry.getValue();
|
||||||
|
|
||||||
|
float markerX = x + replayTickToTimelineX(markerTick);
|
||||||
|
int colour = marker.colour();
|
||||||
|
colour = ((colour >> 16) & 0xFF) | (colour & 0xFF00) | ((colour << 16) & 0xFF0000) | 0xFF000000; // change endianness
|
||||||
|
drawList.addCircleFilled(markerX, y+middleY, 5, colour);
|
||||||
|
|
||||||
|
if (!ImGui.isAnyMouseDown() && marker.description() != null && Math.abs(markerX - mouseX) <= 5 && Math.abs(y+middleY - mouseY) <= 5) {
|
||||||
|
ImGuiHelper.drawTooltip(marker.description());
|
||||||
|
}
|
||||||
|
|
||||||
|
tick = markerTick + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderPlaybackHead(cursorX, x, middleX, width, cursorTicks, currentReplayTick, drawList, y, middleY, timestampHeight, height, zoomBarHeight);
|
renderPlaybackHead(cursorX, x, middleX, width, cursorTicks, currentReplayTick, drawList, y, middleY, timestampHeight, height, zoomBarHeight);
|
||||||
|
|
||||||
if (dragSelectOrigin != null) {
|
if (dragSelectOrigin != null) {
|
||||||
@@ -286,11 +319,6 @@ public class TimelineWindow {
|
|||||||
if (editorState.zoomMax >= 1.0) {
|
if (editorState.zoomMax >= 1.0) {
|
||||||
drawList.addLine(x + width -2, y + timestampHeight, x + width -2, y + height - zoomBarHeight, -1);
|
drawList.addLine(x + width -2, y + timestampHeight, x + width -2, y + height - zoomBarHeight, -1);
|
||||||
}
|
}
|
||||||
// Middle divider (x)
|
|
||||||
drawList.addLine(x + middleX, y + timestampHeight, x + middleX, y + height, -1);
|
|
||||||
|
|
||||||
// Middle divider (y)
|
|
||||||
drawList.addLine(0, y + middleY, width, y + middleY, -1);
|
|
||||||
|
|
||||||
// Zoom Bar
|
// Zoom Bar
|
||||||
if (zoomBarExpanded) {
|
if (zoomBarExpanded) {
|
||||||
@@ -488,20 +516,20 @@ public class TimelineWindow {
|
|||||||
boolean pressedCopy = ctrlPressed && ImGui.isKeyPressed(GLFW.GLFW_KEY_C, false);
|
boolean pressedCopy = ctrlPressed && ImGui.isKeyPressed(GLFW.GLFW_KEY_C, false);
|
||||||
boolean pressedPaste = ctrlPressed && ImGui.isKeyPressed(GLFW.GLFW_KEY_V, false);
|
boolean pressedPaste = ctrlPressed && ImGui.isKeyPressed(GLFW.GLFW_KEY_V, false);
|
||||||
|
|
||||||
boolean pressedDelete = ImGui.isKeyPressed(GLFW.GLFW_KEY_DELETE) || ImGui.isKeyPressed(GLFW.GLFW_KEY_BACKSPACE);
|
boolean pressedDelete = ImGui.isKeyPressed(GLFW.GLFW_KEY_DELETE, false) || ImGui.isKeyPressed(GLFW.GLFW_KEY_BACKSPACE, false);
|
||||||
|
|
||||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_LEFT)) {
|
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_LEFT, false)) {
|
||||||
pendingStepBackwardsTicks += 1;
|
pendingStepBackwardsTicks += 1;
|
||||||
} else if (pendingStepBackwardsTicks > 0 && !ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT)) {
|
} else if (pendingStepBackwardsTicks > 0 && !ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT)) {
|
||||||
replayServer.goToReplayTick(Math.max(0, replayServer.getReplayTick() - pendingStepBackwardsTicks));
|
replayServer.goToReplayTick(Math.max(0, replayServer.getReplayTick() - pendingStepBackwardsTicks));
|
||||||
replayServer.forceApplyKeyframes.set(true);
|
replayServer.forceApplyKeyframes.set(true);
|
||||||
pendingStepBackwardsTicks = 0;
|
pendingStepBackwardsTicks = 0;
|
||||||
}
|
}
|
||||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_RIGHT)) {
|
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_RIGHT, false)) {
|
||||||
replayServer.goToReplayTick(Math.min(totalTicks, cursorTicks + 1));
|
replayServer.goToReplayTick(Math.min(totalTicks, cursorTicks + 1));
|
||||||
replayServer.forceApplyKeyframes.set(true);
|
replayServer.forceApplyKeyframes.set(true);
|
||||||
}
|
}
|
||||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_UP)) {
|
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_UP, false)) {
|
||||||
int nextKeyframeTick;
|
int nextKeyframeTick;
|
||||||
if (editorState.exportStartTicks >= 0 && editorState.exportStartTicks > cursorTicks) {
|
if (editorState.exportStartTicks >= 0 && editorState.exportStartTicks > cursorTicks) {
|
||||||
nextKeyframeTick = editorState.exportStartTicks;
|
nextKeyframeTick = editorState.exportStartTicks;
|
||||||
@@ -510,6 +538,13 @@ public class TimelineWindow {
|
|||||||
} else {
|
} else {
|
||||||
nextKeyframeTick = totalTicks;
|
nextKeyframeTick = totalTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlashbackMeta meta = replayServer.getMetadata();
|
||||||
|
Integer nextMarker = meta.replayMarkers.ceilingKey(cursorTicks + 1);
|
||||||
|
if (nextMarker != null && nextMarker < nextKeyframeTick) {
|
||||||
|
nextKeyframeTick = nextMarker;
|
||||||
|
}
|
||||||
|
|
||||||
for (KeyframeTrack track : editorState.keyframeTracks) {
|
for (KeyframeTrack track : editorState.keyframeTracks) {
|
||||||
Integer ceilingKey = track.keyframesByTick.ceilingKey(cursorTicks+1);
|
Integer ceilingKey = track.keyframesByTick.ceilingKey(cursorTicks+1);
|
||||||
if (ceilingKey != null && ceilingKey < nextKeyframeTick) {
|
if (ceilingKey != null && ceilingKey < nextKeyframeTick) {
|
||||||
@@ -519,7 +554,7 @@ public class TimelineWindow {
|
|||||||
replayServer.goToReplayTick(nextKeyframeTick);
|
replayServer.goToReplayTick(nextKeyframeTick);
|
||||||
replayServer.forceApplyKeyframes.set(true);
|
replayServer.forceApplyKeyframes.set(true);
|
||||||
}
|
}
|
||||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_DOWN)) {
|
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_DOWN, false)) {
|
||||||
int previousKeyframeTick;
|
int previousKeyframeTick;
|
||||||
if (editorState.exportEndTicks >= 0 && editorState.exportEndTicks < cursorTicks) {
|
if (editorState.exportEndTicks >= 0 && editorState.exportEndTicks < cursorTicks) {
|
||||||
previousKeyframeTick = editorState.exportEndTicks;
|
previousKeyframeTick = editorState.exportEndTicks;
|
||||||
@@ -528,6 +563,13 @@ public class TimelineWindow {
|
|||||||
} else {
|
} else {
|
||||||
previousKeyframeTick = 0;
|
previousKeyframeTick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlashbackMeta meta = replayServer.getMetadata();
|
||||||
|
Integer lastMarker = meta.replayMarkers.floorKey(cursorTicks - 1);
|
||||||
|
if (lastMarker != null && lastMarker > previousKeyframeTick) {
|
||||||
|
previousKeyframeTick = lastMarker;
|
||||||
|
}
|
||||||
|
|
||||||
for (KeyframeTrack track : editorState.keyframeTracks) {
|
for (KeyframeTrack track : editorState.keyframeTracks) {
|
||||||
Integer floorKey = track.keyframesByTick.floorKey(cursorTicks-1);
|
Integer floorKey = track.keyframesByTick.floorKey(cursorTicks-1);
|
||||||
if (floorKey != null && floorKey > previousKeyframeTick) {
|
if (floorKey != null && floorKey > previousKeyframeTick) {
|
||||||
@@ -537,10 +579,10 @@ public class TimelineWindow {
|
|||||||
replayServer.goToReplayTick(previousKeyframeTick);
|
replayServer.goToReplayTick(previousKeyframeTick);
|
||||||
replayServer.forceApplyKeyframes.set(true);
|
replayServer.forceApplyKeyframes.set(true);
|
||||||
}
|
}
|
||||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_Z) && (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL))) {
|
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_Z, false) && (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL))) {
|
||||||
editorState.undo(ReplayUI::setInfoOverlayShort);
|
editorState.undo(ReplayUI::setInfoOverlayShort);
|
||||||
}
|
}
|
||||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_Y) && (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL))) {
|
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_Y, false) && (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL))) {
|
||||||
editorState.redo(ReplayUI::setInfoOverlayShort);
|
editorState.redo(ReplayUI::setInfoOverlayShort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +684,14 @@ public class TimelineWindow {
|
|||||||
if (hoveredControls) {
|
if (hoveredControls) {
|
||||||
// Skip backwards
|
// Skip backwards
|
||||||
if (hoveredSkipBackwards) {
|
if (hoveredSkipBackwards) {
|
||||||
replayServer.goToReplayTick(0);
|
FlashbackMeta meta = replayServer.getMetadata();
|
||||||
|
Integer lastMarker = meta.replayMarkers.floorKey(cursorTicks - 1);
|
||||||
|
|
||||||
|
if (lastMarker != null) {
|
||||||
|
replayServer.goToReplayTick(lastMarker);
|
||||||
|
} else {
|
||||||
|
replayServer.goToReplayTick(0);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,7 +742,14 @@ public class TimelineWindow {
|
|||||||
|
|
||||||
// Skip forward
|
// Skip forward
|
||||||
if (hoveredSkipForwards) {
|
if (hoveredSkipForwards) {
|
||||||
replayServer.goToReplayTick(replayServer.getTotalReplayTicks());
|
FlashbackMeta meta = replayServer.getMetadata();
|
||||||
|
Integer nextMarker = meta.replayMarkers.ceilingKey(cursorTicks + 1);
|
||||||
|
|
||||||
|
if (nextMarker != null) {
|
||||||
|
replayServer.goToReplayTick(nextMarker);
|
||||||
|
} else {
|
||||||
|
replayServer.goToReplayTick(replayServer.getTotalReplayTicks());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ public class ExportJob {
|
|||||||
private long encodeTimeNanos = 0;
|
private long encodeTimeNanos = 0;
|
||||||
private long downloadTimeNanos = 0;
|
private long downloadTimeNanos = 0;
|
||||||
|
|
||||||
|
private double currentTickDouble = 0.0;
|
||||||
|
|
||||||
private double audioSamples = 0.0;
|
private double audioSamples = 0.0;
|
||||||
|
|
||||||
private final AtomicBoolean finishedServerTick = new AtomicBoolean(false);
|
private final AtomicBoolean finishedServerTick = new AtomicBoolean(false);
|
||||||
@@ -101,6 +103,10 @@ public class ExportJob {
|
|||||||
return this.settings.resolutionY() * (this.settings.ssaa() ? 2 : 1);
|
return this.settings.resolutionY() * (this.settings.ssaa() ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getCurrentTickDouble() {
|
||||||
|
return this.currentTickDouble;
|
||||||
|
}
|
||||||
|
|
||||||
public Random getParticleRandom() {
|
public Random getParticleRandom() {
|
||||||
return this.particleRandom;
|
return this.particleRandom;
|
||||||
}
|
}
|
||||||
@@ -189,7 +195,7 @@ public class ExportJob {
|
|||||||
double lastTickDouble = 0;
|
double lastTickDouble = 0;
|
||||||
|
|
||||||
for (int tickIndex = 0; tickIndex < ticks.size(); tickIndex++) {
|
for (int tickIndex = 0; tickIndex < ticks.size(); tickIndex++) {
|
||||||
double currentTickDouble = ticks.getDouble(tickIndex);
|
this.currentTickDouble = ticks.getDouble(tickIndex);
|
||||||
float deltaTicksFloat = (float)(currentTickDouble - lastTickDouble);
|
float deltaTicksFloat = (float)(currentTickDouble - lastTickDouble);
|
||||||
lastTickDouble = currentTickDouble;
|
lastTickDouble = currentTickDouble;
|
||||||
int currentTick = (int) currentTickDouble;
|
int currentTick = (int) currentTickDouble;
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ public interface ServerLevelExt {
|
|||||||
boolean flashback$shouldSendChunk(long pos);
|
boolean flashback$shouldSendChunk(long pos);
|
||||||
void flashback$markChunkAsSendable(long pos);
|
void flashback$markChunkAsSendable(long pos);
|
||||||
|
|
||||||
|
void flashback$setCanSpawnEntities(boolean canSpawnEntities);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.moulberry.flashback.io;
|
package com.moulberry.flashback.io;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
import com.mojang.blaze3d.platform.NativeImage;
|
||||||
import com.moulberry.flashback.CachedChunkPacket;
|
import com.moulberry.flashback.CachedChunkPacket;
|
||||||
import com.moulberry.flashback.Flashback;
|
import com.moulberry.flashback.Flashback;
|
||||||
@@ -196,7 +197,12 @@ public class AsyncReplaySaver {
|
|||||||
registryFriendlyByteBuf.writeFloat(localPlayer.getYHeadRot());
|
registryFriendlyByteBuf.writeFloat(localPlayer.getYHeadRot());
|
||||||
registryFriendlyByteBuf.writeVec3(localPlayer.getDeltaMovement());
|
registryFriendlyByteBuf.writeVec3(localPlayer.getDeltaMovement());
|
||||||
|
|
||||||
ByteBufCodecs.GAME_PROFILE.encode(registryFriendlyByteBuf, localPlayer.getGameProfile());
|
GameProfile currentProfile = localPlayer.getGameProfile();
|
||||||
|
GameProfile newProfile = new GameProfile(currentProfile.getId(), currentProfile.getName());
|
||||||
|
newProfile.getProperties().putAll(Minecraft.getInstance().getGameProfile().getProperties());
|
||||||
|
newProfile.getProperties().putAll(currentProfile.getProperties());
|
||||||
|
|
||||||
|
ByteBufCodecs.GAME_PROFILE.encode(registryFriendlyByteBuf, newProfile);
|
||||||
|
|
||||||
registryFriendlyByteBuf.writeVarInt(Minecraft.getInstance().gameMode.getPlayerMode().getId());
|
registryFriendlyByteBuf.writeVarInt(Minecraft.getInstance().gameMode.getPlayerMode().getId());
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -3,14 +3,16 @@ package com.moulberry.flashback.mixin.compat.bobby;
|
|||||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||||
import de.johni0702.minecraft.bobby.FakeChunkManager;
|
import de.johni0702.minecraft.bobby.FakeChunkManager;
|
||||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@IfModLoaded("bobby")
|
@IfModLoaded("bobby")
|
||||||
@Mixin(FakeChunkManager.class)
|
@Mixin(value = FakeChunkManager.class, remap = false)
|
||||||
public interface FakeChunkManagerAccessor {
|
public interface FakeChunkManagerAccessor {
|
||||||
|
|
||||||
@Invoker(value = "getCurrentWorldOrServerName", remap = false)
|
@Invoker(value = "getCurrentWorldOrServerName")
|
||||||
|
@Contract
|
||||||
static String getCurrentWorldOrServerName(ClientPacketListener clientPacketListener) {
|
static String getCurrentWorldOrServerName(ClientPacketListener clientPacketListener) {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.moulberry.flashback.mixin.compat.bobby;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
|
import com.moulberry.flashback.playback.ReplayServer;
|
||||||
|
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||||
|
import de.johni0702.minecraft.bobby.Bobby;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.server.IntegratedServer;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
|
@IfModLoaded("bobby")
|
||||||
|
@Mixin(value = Bobby.class, remap = false)
|
||||||
|
public class MixinBobby {
|
||||||
|
|
||||||
|
@WrapOperation(method = "isEnabled", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSingleplayerServer()Lnet/minecraft/client/server/IntegratedServer;"))
|
||||||
|
public IntegratedServer isEnabled_getSingleplayerServer(Minecraft instance, Operation<IntegratedServer> original) {
|
||||||
|
IntegratedServer server = original.call(instance);
|
||||||
|
if (server instanceof ReplayServer) {
|
||||||
|
return null; // Turn bobby on when viewing replay, even if disabled in singleplayer
|
||||||
|
}
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
-2
@@ -4,9 +4,11 @@ import com.moulberry.flashback.Flashback;
|
|||||||
import com.moulberry.flashback.playback.ReplayServer;
|
import com.moulberry.flashback.playback.ReplayServer;
|
||||||
import com.moulberry.flashback.record.FlashbackMeta;
|
import com.moulberry.flashback.record.FlashbackMeta;
|
||||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||||
|
import de.johni0702.minecraft.bobby.ChunkSerializer;
|
||||||
import de.johni0702.minecraft.bobby.FakeChunkManager;
|
import de.johni0702.minecraft.bobby.FakeChunkManager;
|
||||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||||
import net.minecraft.world.level.chunk.LevelChunk;
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -15,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@IfModLoaded("bobby")
|
@IfModLoaded("bobby")
|
||||||
@Mixin(FakeChunkManager.class)
|
@Mixin(value = FakeChunkManager.class, remap = false)
|
||||||
public class MixinBobbyFakeChunkManager {
|
public class MixinBobbyFakeChunkManager {
|
||||||
|
|
||||||
@Inject(method = "getCurrentWorldOrServerName", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getCurrentWorldOrServerName", at = @At("HEAD"), cancellable = true)
|
||||||
@@ -35,7 +37,8 @@ public class MixinBobbyFakeChunkManager {
|
|||||||
@Inject(method = "save", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "save", at = @At("HEAD"), cancellable = true)
|
||||||
public void save(LevelChunk chunk, CallbackInfoReturnable<Supplier<LevelChunk>> cir) {
|
public void save(LevelChunk chunk, CallbackInfoReturnable<Supplier<LevelChunk>> cir) {
|
||||||
if (Flashback.isInReplay()) {
|
if (Flashback.isInReplay()) {
|
||||||
cir.setReturnValue(() -> chunk);
|
Pair<LevelChunk, Supplier<LevelChunk>> copy = ChunkSerializer.shallowCopy(chunk);
|
||||||
|
cir.setReturnValue(copy.getRight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package com.moulberry.flashback.mixin.compat.iris;
|
||||||
|
|
||||||
|
import com.moulberry.flashback.Flashback;
|
||||||
|
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||||
|
import net.irisshaders.iris.uniforms.SystemTimeUniforms;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@IfModLoaded("iris")
|
||||||
|
@Mixin(value = SystemTimeUniforms.Timer.class, remap = false)
|
||||||
|
public class MixinIrisSystemTimeUniforms {
|
||||||
|
|
||||||
|
@Inject(method = "getFrameTimeCounter", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void getFrameTimeCounter(CallbackInfoReturnable<Float> cir) {
|
||||||
|
if (Flashback.isExporting()) {
|
||||||
|
double currentTick = Flashback.EXPORT_JOB.getCurrentTickDouble();
|
||||||
|
cir.setReturnValue((float)(currentTick / 20));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getLastFrameTime", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void getLastFrameTime(CallbackInfoReturnable<Float> cir) {
|
||||||
|
if (Flashback.isExporting()) {
|
||||||
|
cir.setReturnValue((float)(1 / Flashback.EXPORT_JOB.getSettings().framerate()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -69,30 +69,6 @@ public abstract class MixinGameRenderer {
|
|||||||
@Shadow
|
@Shadow
|
||||||
private boolean effectActive;
|
private boolean effectActive;
|
||||||
|
|
||||||
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void render(DeltaTracker deltaTracker, boolean bl, CallbackInfo ci) {
|
|
||||||
if (Flashback.isExporting()) {
|
|
||||||
int i = (int)(this.minecraft.mouseHandler.xpos() * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth());
|
|
||||||
int j = (int)(this.minecraft.mouseHandler.ypos() * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight());
|
|
||||||
RenderSystem.viewport(0, 0, this.minecraft.getWindow().getWidth(), this.minecraft.getWindow().getHeight());
|
|
||||||
boolean bl2 = this.minecraft.isGameLoadFinished();
|
|
||||||
if (bl2 && bl && this.minecraft.level != null) {
|
|
||||||
this.minecraft.getProfiler().push("level");
|
|
||||||
this.renderLevel(deltaTracker);
|
|
||||||
this.minecraft.levelRenderer.doEntityOutline();
|
|
||||||
if (this.postEffect != null && this.effectActive) {
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
RenderSystem.disableDepthTest();
|
|
||||||
RenderSystem.resetTextureMatrix();
|
|
||||||
this.postEffect.process(deltaTracker.getGameTimeDeltaTicks());
|
|
||||||
}
|
|
||||||
this.minecraft.getMainRenderTarget().bindWrite(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@WrapOperation(method = "renderItemInHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;getPlayerMode()Lnet/minecraft/world/level/GameType;"))
|
@WrapOperation(method = "renderItemInHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;getPlayerMode()Lnet/minecraft/world/level/GameType;"))
|
||||||
public GameType getPlayerMode(MultiPlayerGameMode instance, Operation<GameType> original) {
|
public GameType getPlayerMode(MultiPlayerGameMode instance, Operation<GameType> original) {
|
||||||
if (Flashback.getSpectatingPlayer() != null) {
|
if (Flashback.getSpectatingPlayer() != null) {
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
package com.moulberry.flashback.mixin.replay_server;
|
package com.moulberry.flashback.mixin.replay_server;
|
||||||
|
|
||||||
import com.moulberry.flashback.ext.ServerLevelExt;
|
import com.moulberry.flashback.ext.ServerLevelExt;
|
||||||
|
import com.moulberry.flashback.playback.ReplayPlayer;
|
||||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
import net.minecraft.core.SectionPos;
|
import net.minecraft.core.SectionPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(ServerLevel.class)
|
@Mixin(ServerLevel.class)
|
||||||
public abstract class MixinServerLevel implements ServerLevelExt {
|
public abstract class MixinServerLevel implements ServerLevelExt {
|
||||||
@@ -38,4 +44,19 @@ public abstract class MixinServerLevel implements ServerLevelExt {
|
|||||||
this.validChunks.add(pos);
|
this.validChunks.add(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private boolean canSpawnEntities = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flashback$setCanSpawnEntities(boolean canSpawnEntities) {
|
||||||
|
this.canSpawnEntities = canSpawnEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "addFreshEntity", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void addFreshEntity(Entity entity, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (!(entity instanceof Player) && !this.canSpawnEntities) {
|
||||||
|
cir.setReturnValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+12
@@ -1,8 +1,11 @@
|
|||||||
package com.moulberry.flashback.mixin.replay_server;
|
package com.moulberry.flashback.mixin.replay_server;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.moulberry.flashback.playback.ReplayServer;
|
import com.moulberry.flashback.playback.ReplayServer;
|
||||||
|
import net.minecraft.network.protocol.login.ClientboundGameProfilePacket;
|
||||||
import net.minecraft.network.protocol.login.ServerboundHelloPacket;
|
import net.minecraft.network.protocol.login.ServerboundHelloPacket;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
||||||
@@ -43,4 +46,13 @@ public abstract class MixinServerLoginPacketListenerImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable strict error handling
|
||||||
|
@WrapOperation(method = "finishLoginAndWaitForClient", at = @At(value = "NEW", target = "net/minecraft/network/protocol/login/ClientboundGameProfilePacket"))
|
||||||
|
public ClientboundGameProfilePacket wrapCreateClientboundGameProfilePacket(GameProfile gameProfile, boolean strict, Operation<ClientboundGameProfilePacket> original) {
|
||||||
|
if (this.server instanceof ReplayServer) {
|
||||||
|
strict = false;
|
||||||
|
}
|
||||||
|
return original.call(gameProfile, strict);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import com.moulberry.flashback.editor.ui.ReplayUI;
|
|||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -50,6 +51,15 @@ public class MixinGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "renderVignette", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void renderVignette(GuiGraphics guiGraphics, Entity entity, CallbackInfo ci) {
|
||||||
|
// The vignette ruins the transparency when trying to export with alpha
|
||||||
|
// The vignette is also probably unwanted in general when trying to record, so lets just get rid of it
|
||||||
|
if (Flashback.isInReplay()) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "canRenderCrosshairForSpectator", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "canRenderCrosshairForSpectator", at = @At("HEAD"), cancellable = true)
|
||||||
public void canRenderCrosshairForSpectator(HitResult hitResult, CallbackInfoReturnable<Boolean> cir) {
|
public void canRenderCrosshairForSpectator(HitResult hitResult, CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (Flashback.isExporting()) {
|
if (Flashback.isExporting()) {
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.moulberry.flashback.mixin.visuals;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
|
import com.moulberry.flashback.Flashback;
|
||||||
|
import net.minecraft.client.renderer.RenderStateShard;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
|
@Mixin(RenderStateShard.class)
|
||||||
|
public class MixinRenderStateShard {
|
||||||
|
|
||||||
|
@WrapOperation(method = "setupGlintTexturing", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;getMillis()J"))
|
||||||
|
private static long setupGlintTexturing(Operation<Long> original) {
|
||||||
|
if (Flashback.isExporting()) {
|
||||||
|
double currentTick = Flashback.EXPORT_JOB.getCurrentTickDouble();
|
||||||
|
return (long)(currentTick / 20 * 1000);
|
||||||
|
}
|
||||||
|
return original.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -145,7 +145,10 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((ServerLevelExt) level).flashback$setCanSpawnEntities(true);
|
||||||
level.addFreshEntity(pendingEntity);
|
level.addFreshEntity(pendingEntity);
|
||||||
|
((ServerLevelExt) level).flashback$setCanSpawnEntities(false);
|
||||||
|
|
||||||
ChunkPos chunkPos = new ChunkPos(pendingEntity.blockPosition());
|
ChunkPos chunkPos = new ChunkPos(pendingEntity.blockPosition());
|
||||||
level.getChunkSource().addRegionTicket(ReplayServer.ENTITY_LOAD_TICKET, chunkPos, 3, chunkPos);
|
level.getChunkSource().addRegionTicket(ReplayServer.ENTITY_LOAD_TICKET, chunkPos, 3, chunkPos);
|
||||||
}
|
}
|
||||||
@@ -263,7 +266,10 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
|||||||
existingEntity.discard();
|
existingEntity.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.level().addFreshEntity(entity);
|
ServerLevel level = this.level();
|
||||||
|
((ServerLevelExt) level).flashback$setCanSpawnEntities(true);
|
||||||
|
level.addFreshEntity(entity);
|
||||||
|
((ServerLevelExt) level).flashback$setCanSpawnEntities(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -636,7 +642,8 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
|||||||
GameProfile gameProfile = ByteBufCodecs.GAME_PROFILE.decode(registryFriendlyByteBuf);
|
GameProfile gameProfile = ByteBufCodecs.GAME_PROFILE.decode(registryFriendlyByteBuf);
|
||||||
GameType gameType = GameType.byId(registryFriendlyByteBuf.readVarInt());
|
GameType gameType = GameType.byId(registryFriendlyByteBuf.readVarInt());
|
||||||
|
|
||||||
if (this.getEntityOrPending(this.localPlayerId) == null) {
|
Entity existing = this.localPlayerId == -1 ? null : this.getEntityOrPending(this.localPlayerId);
|
||||||
|
if (existing == null) {
|
||||||
this.spawnPlayer(addEntityPacket, gameProfile, gameType);
|
this.spawnPlayer(addEntityPacket, gameProfile, gameType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -669,7 +676,6 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
|||||||
false, commonPlayerSpawnInfo.seed(), List.of(), false, null);
|
false, commonPlayerSpawnInfo.seed(), List.of(), false, null);
|
||||||
serverLevel.noSave = true;
|
serverLevel.noSave = true;
|
||||||
this.replayServer.levels.put(dimension, serverLevel);
|
this.replayServer.levels.put(dimension, serverLevel);
|
||||||
this.replayServer.followLocalPlayerNextTick = true;
|
|
||||||
|
|
||||||
if (oldLevel != null) {
|
if (oldLevel != null) {
|
||||||
this.replayServer.closeLevel(oldLevel);
|
this.replayServer.closeLevel(oldLevel);
|
||||||
@@ -677,16 +683,14 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerLevel newLevel = this.replayServer.getLevel(dimension);
|
ServerLevel newLevel = this.replayServer.getLevel(dimension);
|
||||||
|
((ServerLevelExt) newLevel).flashback$setCanSpawnEntities(false);
|
||||||
((ServerLevelExt) newLevel).flashback$setSeedHash(commonPlayerSpawnInfo.seed());
|
((ServerLevelExt) newLevel).flashback$setSeedHash(commonPlayerSpawnInfo.seed());
|
||||||
|
this.replayServer.followLocalPlayerNextTickIfWrongDimension = true;
|
||||||
|
|
||||||
if (newLevel == oldLevel) {
|
if (newLevel == oldLevel) {
|
||||||
// Change to new dimension
|
// Change to new dimension
|
||||||
this.currentDimension = commonPlayerSpawnInfo.dimension();
|
this.currentDimension = commonPlayerSpawnInfo.dimension();
|
||||||
this.replayServer.spawnLevel = this.currentDimension;
|
this.replayServer.spawnLevel = this.currentDimension;
|
||||||
|
|
||||||
if (!this.replayServer.isProcessingSnapshot) {
|
|
||||||
this.replayServer.followLocalPlayerNextTickIfFar = true;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,9 +699,10 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
|||||||
localPlayer.teleportTo(newLevel, 0.0, 0.0, 0.0, Set.of(), 0.0f, 0.0f);
|
localPlayer.teleportTo(newLevel, 0.0, 0.0, 0.0, Set.of(), 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
for (ReplayPlayer replayViewer : this.replayServer.getReplayViewers()) {
|
for (ReplayPlayer replayViewer : this.replayServer.getReplayViewers()) {
|
||||||
replayViewer.teleportTo(newLevel, 0.0, 0.0, 0.0, Set.of(), 0.0f, 0.0f);
|
replayViewer.teleportTo(newLevel, replayViewer.getX(), replayViewer.getY(), replayViewer.getZ(), Set.of(),
|
||||||
|
replayViewer.getYRot(), replayViewer.getXRot());
|
||||||
|
replayViewer.followLocalPlayerNextTick = true;
|
||||||
}
|
}
|
||||||
this.replayServer.followLocalPlayerNextTick = true;
|
|
||||||
|
|
||||||
// Delete current dimension
|
// Delete current dimension
|
||||||
if (this.currentDimension == Level.OVERWORLD) {
|
if (this.currentDimension == Level.OVERWORLD) {
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ public class ReplayServer extends IntegratedServer {
|
|||||||
private StreamCodec<ByteBuf, Packet<? super ClientGamePacketListener>> gamePacketCodec;
|
private StreamCodec<ByteBuf, Packet<? super ClientGamePacketListener>> gamePacketCodec;
|
||||||
private final StreamCodec<ByteBuf, Packet<? super ClientConfigurationPacketListener>> configurationPacketCodec;
|
private final StreamCodec<ByteBuf, Packet<? super ClientConfigurationPacketListener>> configurationPacketCodec;
|
||||||
private final List<ReplayPlayer> replayViewers = new ArrayList<>();
|
private final List<ReplayPlayer> replayViewers = new ArrayList<>();
|
||||||
public boolean followLocalPlayerNextTick = false;
|
public boolean followLocalPlayerNextTickIfWrongDimension = false;
|
||||||
public boolean followLocalPlayerNextTickIfFar = false;
|
|
||||||
public boolean isProcessingSnapshot = false;
|
public boolean isProcessingSnapshot = false;
|
||||||
private boolean processedSnapshot = false;
|
private boolean processedSnapshot = false;
|
||||||
private volatile boolean fastForwarding = false;
|
private volatile boolean fastForwarding = false;
|
||||||
@@ -963,9 +962,9 @@ public class ReplayServer extends IntegratedServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ReplayPlayer replayViewer : this.getReplayViewers()) {
|
for (ReplayPlayer replayViewer : this.getReplayViewers()) {
|
||||||
boolean shouldFollow = replayViewer.followLocalPlayerNextTick || this.followLocalPlayerNextTick;
|
boolean shouldFollow = replayViewer.followLocalPlayerNextTick;
|
||||||
if (this.followLocalPlayerNextTickIfFar) {
|
if (this.followLocalPlayerNextTickIfWrongDimension) {
|
||||||
shouldFollow |= replayViewer.level() != currentLevel || replayViewer.distanceToSqr(follow) > 256*256;
|
shouldFollow |= replayViewer.level() != currentLevel;
|
||||||
}
|
}
|
||||||
if (shouldFollow) {
|
if (shouldFollow) {
|
||||||
replayViewer.followLocalPlayerNextTick = false;
|
replayViewer.followLocalPlayerNextTick = false;
|
||||||
@@ -974,8 +973,7 @@ public class ReplayServer extends IntegratedServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.followLocalPlayerNextTick = false;
|
this.followLocalPlayerNextTickIfWrongDimension = false;
|
||||||
this.followLocalPlayerNextTickIfFar = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopWithReason(Component reason) {
|
private void stopWithReason(Component reason) {
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
package com.moulberry.flashback.record;
|
package com.moulberry.flashback.record;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.moulberry.flashback.FlashbackGson;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FlashbackMeta {
|
public class FlashbackMeta {
|
||||||
@@ -17,6 +22,8 @@ public class FlashbackMeta {
|
|||||||
public int dataVersion = 0;
|
public int dataVersion = 0;
|
||||||
public int protocolVersion = 0;
|
public int protocolVersion = 0;
|
||||||
|
|
||||||
|
public TreeMap<Integer, ReplayMarker> replayMarkers = new TreeMap<>();
|
||||||
|
|
||||||
public int totalTicks = -1;
|
public int totalTicks = -1;
|
||||||
public LinkedHashMap<String, FlashbackChunkMeta> chunks = new LinkedHashMap<>();
|
public LinkedHashMap<String, FlashbackChunkMeta> chunks = new LinkedHashMap<>();
|
||||||
|
|
||||||
@@ -42,6 +49,14 @@ public class FlashbackMeta {
|
|||||||
meta.addProperty("total_ticks", this.totalTicks);
|
meta.addProperty("total_ticks", this.totalTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.replayMarkers.isEmpty()) {
|
||||||
|
JsonObject jsonMarkers = new JsonObject();
|
||||||
|
for (Map.Entry<Integer, ReplayMarker> entry : this.replayMarkers.entrySet()) {
|
||||||
|
jsonMarkers.add(""+entry.getKey(), FlashbackGson.COMPRESSED.toJsonTree(entry.getValue()));
|
||||||
|
}
|
||||||
|
meta.add("markers", jsonMarkers);
|
||||||
|
}
|
||||||
|
|
||||||
JsonObject chunksJson = new JsonObject();
|
JsonObject chunksJson = new JsonObject();
|
||||||
for (Map.Entry<String, FlashbackChunkMeta> entry : this.chunks.entrySet()) {
|
for (Map.Entry<String, FlashbackChunkMeta> entry : this.chunks.entrySet()) {
|
||||||
chunksJson.add(entry.getKey(), entry.getValue().toJson());
|
chunksJson.add(entry.getKey(), entry.getValue().toJson());
|
||||||
@@ -85,6 +100,16 @@ public class FlashbackMeta {
|
|||||||
flashbackMeta.totalTicks = meta.get("total_ticks").getAsInt();
|
flashbackMeta.totalTicks = meta.get("total_ticks").getAsInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (meta.has("markers")) {
|
||||||
|
JsonObject markers = meta.getAsJsonObject("markers");
|
||||||
|
for (Map.Entry<String, JsonElement> entry : markers.entrySet()) {
|
||||||
|
try {
|
||||||
|
int tick = Integer.parseInt(entry.getKey());
|
||||||
|
flashbackMeta.replayMarkers.put(tick, FlashbackGson.COMPRESSED.fromJson(entry.getValue(), ReplayMarker.class));
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Chunks
|
// Chunks
|
||||||
if (!meta.has("chunks")) {
|
if (!meta.has("chunks")) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -139,6 +139,10 @@ public class Recorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMarker(ReplayMarker marker) {
|
||||||
|
this.metadata.replayMarkers.put(this.writtenTicks, marker);
|
||||||
|
}
|
||||||
|
|
||||||
public void setRegistryAccess(RegistryAccess registryAccess) {
|
public void setRegistryAccess(RegistryAccess registryAccess) {
|
||||||
this.asyncReplaySaver.submit(writer -> writer.setRegistryAccess(registryAccess));
|
this.asyncReplaySaver.submit(writer -> writer.setRegistryAccess(registryAccess));
|
||||||
this.gamePacketCodec = GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryAccess)).codec();
|
this.gamePacketCodec = GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryAccess)).codec();
|
||||||
@@ -225,6 +229,10 @@ public class Recorder {
|
|||||||
int chunkId = this.metadata.chunks.size();
|
int chunkId = this.metadata.chunks.size();
|
||||||
String chunkName = "c" + chunkId + ".flashback";
|
String chunkName = "c" + chunkId + ".flashback";
|
||||||
|
|
||||||
|
if (changedDimensions && Flashback.getConfig().markDimensionChanges) {
|
||||||
|
this.addMarker(new ReplayMarker(0xAA00AA, null, "Changed Dimension"));
|
||||||
|
}
|
||||||
|
|
||||||
var chunkMeta = new FlashbackChunkMeta();
|
var chunkMeta = new FlashbackChunkMeta();
|
||||||
chunkMeta.duration = this.writtenTicksInChunk;
|
chunkMeta.duration = this.writtenTicksInChunk;
|
||||||
this.metadata.chunks.put(chunkName, chunkMeta);
|
this.metadata.chunks.put(chunkName, chunkMeta);
|
||||||
@@ -387,6 +395,10 @@ public class Recorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedPositions.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.asyncReplaySaver.submit(writer -> {
|
this.asyncReplaySaver.submit(writer -> {
|
||||||
writer.startAction(ActionMoveEntities.INSTANCE);
|
writer.startAction(ActionMoveEntities.INSTANCE);
|
||||||
RegistryFriendlyByteBuf friendlyByteBuf = writer.friendlyByteBuf();
|
RegistryFriendlyByteBuf friendlyByteBuf = writer.friendlyByteBuf();
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.moulberry.flashback.record;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
public record ReplayMarker(int colour, @Nullable MarkerPosition position, @Nullable String description) {
|
||||||
|
|
||||||
|
public record MarkerPosition(Vector3f position, String dimension) {}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,13 +1,26 @@
|
|||||||
package com.moulberry.flashback.visuals;
|
package com.moulberry.flashback.visuals;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
|
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||||
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
|
import com.mojang.blaze3d.vertex.MeshData;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.moulberry.flashback.Flashback;
|
import com.moulberry.flashback.Flashback;
|
||||||
import com.moulberry.flashback.playback.ReplayServer;
|
import com.moulberry.flashback.playback.ReplayServer;
|
||||||
|
import com.moulberry.flashback.record.FlashbackMeta;
|
||||||
|
import com.moulberry.flashback.record.ReplayMarker;
|
||||||
import com.moulberry.flashback.state.EditorState;
|
import com.moulberry.flashback.state.EditorState;
|
||||||
import com.moulberry.flashback.state.EditorStateManager;
|
import com.moulberry.flashback.state.EditorStateManager;
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
public class WorldRenderHook {
|
public class WorldRenderHook {
|
||||||
@@ -15,9 +28,72 @@ public class WorldRenderHook {
|
|||||||
public static void renderHook(PoseStack poseStack, float partialTick, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
|
public static void renderHook(PoseStack poseStack, float partialTick, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
|
||||||
LightTexture lightTexture, Matrix4f projection) {
|
LightTexture lightTexture, Matrix4f projection) {
|
||||||
ReplayServer replayServer = Flashback.getReplayServer();
|
ReplayServer replayServer = Flashback.getReplayServer();
|
||||||
|
if (replayServer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EditorState editorState = EditorStateManager.getCurrent();
|
EditorState editorState = EditorStateManager.getCurrent();
|
||||||
if (replayServer != null && editorState != null && !Flashback.isExporting() && editorState.replayVisuals.cameraPath) {
|
if (editorState != null && !Flashback.isExporting() && editorState.replayVisuals.cameraPath) {
|
||||||
CameraPath.renderCameraPath(poseStack, camera, replayServer);
|
CameraPath.renderCameraPath(poseStack, camera, replayServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlashbackMeta meta = replayServer.getMetadata();
|
||||||
|
if (!meta.replayMarkers.isEmpty()) {
|
||||||
|
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||||
|
var multiBufferSource = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||||
|
|
||||||
|
String dimension = Minecraft.getInstance().level.dimension().toString();
|
||||||
|
|
||||||
|
multiBufferSource.endBatch();
|
||||||
|
|
||||||
|
for (ReplayMarker marker : meta.replayMarkers.values()) {
|
||||||
|
if (marker.position() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReplayMarker.MarkerPosition position = marker.position();
|
||||||
|
if (!position.dimension().equals(dimension)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
poseStack.translate(
|
||||||
|
position.position().x - camera.getPosition().x,
|
||||||
|
position.position().y - camera.getPosition().y,
|
||||||
|
position.position().z - camera.getPosition().z
|
||||||
|
);
|
||||||
|
poseStack.mulPose(camera.rotation());
|
||||||
|
|
||||||
|
final float width = 0.2f;
|
||||||
|
bufferBuilder.addVertex(poseStack.last(), -width, -width, 0.0f).setUv(0f, 0f).setColor(marker.colour() | 0xFF000000);
|
||||||
|
bufferBuilder.addVertex(poseStack.last(), width, -width, 0.0f).setUv(1f, 0f).setColor(marker.colour() | 0xFF000000);
|
||||||
|
bufferBuilder.addVertex(poseStack.last(), width, width, 0.0f).setUv(1f, 1f).setColor(marker.colour() | 0xFF000000);
|
||||||
|
bufferBuilder.addVertex(poseStack.last(), -width, width, 0.0f).setUv(0f, 1f).setColor(marker.colour() | 0xFF000000);
|
||||||
|
|
||||||
|
if (marker.description() != null) {
|
||||||
|
Font font = Minecraft.getInstance().font;
|
||||||
|
|
||||||
|
Matrix4f matrix4f = poseStack.last().pose();
|
||||||
|
matrix4f.rotate((float)Math.PI, 0.0f, 1.0f, 0.0f);
|
||||||
|
matrix4f.scale(-0.025f, -0.025f, -0.025f);
|
||||||
|
int descriptionWidth = font.width(marker.description());
|
||||||
|
font.drawInBatch(marker.description(), -descriptionWidth/2f, -20f, 0xFFFFFFFF,
|
||||||
|
true, matrix4f, multiBufferSource, Font.DisplayMode.NORMAL, 0, 0xF000F0);
|
||||||
|
}
|
||||||
|
|
||||||
|
poseStack.popPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
MeshData meshData = bufferBuilder.build();
|
||||||
|
if (meshData != null) {
|
||||||
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.defaultBlendFunc();
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||||
|
RenderSystem.setShaderTexture(0, ResourceLocation.parse("flashback:world_marker_circle.png"));
|
||||||
|
BufferUploader.drawWithShader(meshData);
|
||||||
|
}
|
||||||
|
|
||||||
|
multiBufferSource.endBatch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,5 +16,7 @@
|
|||||||
"flashback.option.quicksave": "Quicksave",
|
"flashback.option.quicksave": "Quicksave",
|
||||||
"flashback.option.quicksave.description": "Save the replay with default values instead of opening the Save Replay screen",
|
"flashback.option.quicksave.description": "Save the replay with default values instead of opening the Save Replay screen",
|
||||||
"flashback.option.hide_pause_menu_controls": "Hide Pause Controls",
|
"flashback.option.hide_pause_menu_controls": "Hide Pause Controls",
|
||||||
"flashback.option.hide_pause_menu_controls.description": "Hide Pause (ESC) menu controls for starting/finishing a replay. The commands will still work"
|
"flashback.option.hide_pause_menu_controls.description": "Hide Pause (ESC) menu controls for starting/finishing a replay. The commands will still work",
|
||||||
|
"flashback.option.mark_dimension_changes": "Mark Dimension Changes",
|
||||||
|
"flashback.option.mark_dimension_changes.description": "Automatically add a marker to the replay when switching dimensions"
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,8 @@
|
|||||||
"visuals.MixinLivingEntityRenderer",
|
"visuals.MixinLivingEntityRenderer",
|
||||||
"visuals.MixinLoadingOverlay",
|
"visuals.MixinLoadingOverlay",
|
||||||
"visuals.MixinMouseHandler",
|
"visuals.MixinMouseHandler",
|
||||||
"visuals.MixinOptions"
|
"visuals.MixinOptions",
|
||||||
|
"visuals.MixinRenderStateShard"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
@@ -42,7 +43,9 @@
|
|||||||
"compat.MixinFabricMinecraftServer",
|
"compat.MixinFabricMinecraftServer",
|
||||||
"compat.MixinSodiumWorldRenderer",
|
"compat.MixinSodiumWorldRenderer",
|
||||||
"compat.bobby.FakeChunkManagerAccessor",
|
"compat.bobby.FakeChunkManagerAccessor",
|
||||||
|
"compat.bobby.MixinBobby",
|
||||||
"compat.bobby.MixinBobbyFakeChunkManager",
|
"compat.bobby.MixinBobbyFakeChunkManager",
|
||||||
|
"compat.iris.MixinIrisSystemTimeUniforms",
|
||||||
"playback.MixinAttributeInstance",
|
"playback.MixinAttributeInstance",
|
||||||
"playback.MixinChunkHolder",
|
"playback.MixinChunkHolder",
|
||||||
"playback.MixinEntity",
|
"playback.MixinEntity",
|
||||||
|
|||||||
Reference in new issue
Block a user