mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 14:38:50 +00:00
0.11.0
This commit is contained in:
1 parent
63535e6b3d
commit
aadd309397
20 files changed
+228
-101
No files matched your search
@@ -1,25 +0,0 @@
|
||||
package com.moulberry.flashback;
|
||||
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
|
||||
public class FixedDeltaTracker implements DeltaTracker {
|
||||
private final float deltaTick;
|
||||
private final float partialTick;
|
||||
|
||||
public FixedDeltaTracker(float deltaTick, float partialTick) {
|
||||
this.deltaTick = deltaTick;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
public float getGameTimeDeltaTicks() {
|
||||
return this.deltaTick;
|
||||
}
|
||||
|
||||
public float getGameTimeDeltaPartialTick(boolean bl) {
|
||||
return this.partialTick;
|
||||
}
|
||||
|
||||
public float getRealtimeDeltaTicks() {
|
||||
return this.deltaTick;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import org.joml.Vector3d;
|
||||
|
||||
public class Interpolation {
|
||||
|
||||
public static double linear(double from, double to, float amount) {
|
||||
public static double linear(double from, double to, double amount) {
|
||||
return from + (to - from) * amount;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,14 @@ public class Interpolation {
|
||||
return from + (to - from) * amount;
|
||||
}
|
||||
|
||||
|
||||
public static float linearAngle(float from, float to, float amount) {
|
||||
float delta = Mth.wrapDegrees(to - from);
|
||||
return from + Math.max(-180, Math.min(180, delta * amount));
|
||||
}
|
||||
|
||||
public static double linearAngle(double from, double to, double amount) {
|
||||
double delta = Mth.wrapDegrees(to - from);
|
||||
return from + Math.max(-180, Math.min(180, delta * amount));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.moulberry.flashback.combo_options;
|
||||
|
||||
public enum WeatherOverride implements ComboOption {
|
||||
|
||||
NONE("No Override"),
|
||||
CLEAR("Clear"),
|
||||
OVERCAST("Overcast"),
|
||||
RAINING("Raining"),
|
||||
SNOWING("Snowing"),
|
||||
THUNDERING("Thundering");
|
||||
|
||||
private final String text;
|
||||
|
||||
WeatherOverride(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String text() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import java.util.Locale;
|
||||
public class MovementWindow {
|
||||
|
||||
private static WindowOpenState wasOpen = WindowOpenState.UNKNOWN;
|
||||
private static boolean wasDocked = false;
|
||||
|
||||
public static void render() {
|
||||
if (!Flashback.getConfig().openedWindows.contains("movement")) {
|
||||
@@ -43,7 +44,13 @@ public class MovementWindow {
|
||||
FlashbackConfig config = Flashback.getConfig();
|
||||
|
||||
ImGui.setNextWindowSizeConstraints(250, 50, 5000, 5000);
|
||||
if (ImGui.begin("Movement###Movement", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoFocusOnAppearing)) {
|
||||
int flags = ImGuiWindowFlags.NoFocusOnAppearing;
|
||||
if (!wasDocked) {
|
||||
flags |= ImGuiWindowFlags.AlwaysAutoResize;
|
||||
}
|
||||
if (ImGui.begin("Movement###Movement", flags)) {
|
||||
wasDocked = ImGui.isWindowDocked();
|
||||
|
||||
int[] direction = new int[]{config.flightCameraDirection ? 1 : 0};
|
||||
|
||||
ImGuiHelper.combo("Direction", direction, new String[]{
|
||||
|
||||
@@ -67,7 +67,6 @@ public class StartExportWindow {
|
||||
|
||||
private static String installedIncompatibleModsString = null;
|
||||
private static final List<String> potentialIncompatibleMods = List.of(
|
||||
"essential", // causes a crash due to casting the DeltaTracker without an instanceof
|
||||
"g4mespeed", // causes rendering issues due to overriding partial tick time
|
||||
"feather" // causes miscellaneous crashes and issues that are impossible to debug
|
||||
);
|
||||
|
||||
@@ -292,6 +292,8 @@ public class VisualsWindow {
|
||||
}
|
||||
}
|
||||
|
||||
visuals.overrideWeatherMode = ImGuiHelper.enumCombo("Weather", visuals.overrideWeatherMode);
|
||||
|
||||
ImGuiHelper.separatorWithText("Other");
|
||||
|
||||
if (ImGui.checkbox("Rule of Thirds Guide", visuals.ruleOfThirdsGuide)) {
|
||||
|
||||
@@ -6,9 +6,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.moulberry.flashback.FixedDeltaTracker;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.SneakyThrow;
|
||||
import com.moulberry.flashback.Utils;
|
||||
import com.moulberry.flashback.combo_options.VideoContainer;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
@@ -19,25 +17,21 @@ import com.moulberry.flashback.keyframe.types.SpeedKeyframeType;
|
||||
import com.moulberry.flashback.keyframe.types.TimelapseKeyframeType;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import com.moulberry.flashback.visuals.AccurateEntityPositionHandler;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleList;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.CreditsAndAttributionScreen;
|
||||
import net.minecraft.client.gui.screens.WinScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bytedeco.ffmpeg.global.avutil;
|
||||
@@ -267,7 +261,7 @@ public class ExportJob {
|
||||
RenderTarget renderTarget = Minecraft.getInstance().mainRenderTarget;
|
||||
renderTarget.bindWrite(true);
|
||||
RenderSystem.clear(16640, Minecraft.ON_OSX);
|
||||
Minecraft.getInstance().gameRenderer.render(new FixedDeltaTracker(0.0f, 0.0f), true);
|
||||
Minecraft.getInstance().gameRenderer.render(Minecraft.getInstance().timer, true);
|
||||
renderTarget.unbindWrite();
|
||||
|
||||
this.shouldChangeFramebufferSize = false;
|
||||
@@ -305,13 +299,17 @@ public class ExportJob {
|
||||
PerfectFrames.waitUntilFrameReady();
|
||||
FogRenderer.setupNoFog();
|
||||
RenderSystem.enableCull();
|
||||
Minecraft.getInstance().timer.deltaTicks = deltaTicksFloat;
|
||||
Minecraft.getInstance().timer.realtimeDeltaTicks = deltaTicksFloat;
|
||||
Minecraft.getInstance().timer.deltaTickResidual = (float) partialTick;
|
||||
Minecraft.getInstance().timer.pausedDeltaTickResidual = (float) partialTick;
|
||||
|
||||
DeltaTracker.Timer timer = Minecraft.getInstance().timer;
|
||||
timer.updateFrozenState(false);
|
||||
timer.updatePauseState(false);
|
||||
timer.deltaTicks = deltaTicksFloat;
|
||||
timer.realtimeDeltaTicks = deltaTicksFloat;
|
||||
timer.deltaTickResidual = (float) partialTick;
|
||||
timer.pausedDeltaTickResidual = (float) partialTick;
|
||||
|
||||
start = System.nanoTime();
|
||||
Minecraft.getInstance().gameRenderer.render(new FixedDeltaTracker(deltaTicksFloat, (float) partialTick), true);
|
||||
Minecraft.getInstance().gameRenderer.render(timer, true);
|
||||
renderTimeNanos += System.nanoTime() - start;
|
||||
|
||||
renderTarget.unbindWrite();
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class ReplayCombiner {
|
||||
|
||||
public static void combine(RegistryAccess registryAccess, Path first, Path second, Path output) throws Exception {
|
||||
public static void combine(RegistryAccess registryAccess, String replayName, Path first, Path second, Path output) throws Exception {
|
||||
StreamCodec<ByteBuf, Packet<? super ClientGamePacketListener>> gamePacketCodec = GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryAccess)).codec();
|
||||
|
||||
try (FileSystem firstFileSystem = FileSystems.newFileSystem(first);
|
||||
@@ -81,6 +81,7 @@ public class ReplayCombiner {
|
||||
}
|
||||
|
||||
firstMetadata.replayIdentifier = UUID.randomUUID();
|
||||
firstMetadata.name = replayName;
|
||||
for (Map.Entry<Integer, ReplayMarker> entry : secondMetadata.replayMarkers.entrySet()) {
|
||||
firstMetadata.replayMarkers.put(entry.getKey() + firstMetadata.totalTicks, entry.getValue());
|
||||
}
|
||||
@@ -134,6 +135,7 @@ public class ReplayCombiner {
|
||||
zipOut.write(bytes);
|
||||
zipOut.closeEntry();
|
||||
|
||||
lastCacheIndex = cacheIndex;
|
||||
chunkCacheOutput = new RegistryFriendlyByteBuf(Unpooled.buffer(), registryAccess);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.moulberry.flashback.keyframe.handler;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.keyframe.KeyframeType;
|
||||
import com.moulberry.flashback.keyframe.types.CameraKeyframeType;
|
||||
import com.moulberry.flashback.keyframe.types.CameraOrbitKeyframeType;
|
||||
@@ -10,6 +11,7 @@ import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -106,8 +106,6 @@ public class CameraKeyframe extends Keyframe {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void apply(KeyframeHandler keyframeHandler) {
|
||||
keyframeHandler.applyCameraPosition(this.position, this.yaw, this.pitch, this.roll);
|
||||
|
||||
@@ -31,15 +31,17 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.chunk.RenderRegionCache;
|
||||
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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.CallbackInfo;
|
||||
@@ -153,6 +155,40 @@ public abstract class MixinLevelRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private Biome.Precipitation forcePrecipitation = null;
|
||||
|
||||
@Inject(method = "renderSnowAndRain", at = @At("HEAD"))
|
||||
public void renderSnowAndRain(LightTexture lightTexture, float f, double d, double e, double g, CallbackInfo ci) {
|
||||
this.forcePrecipitation = null;
|
||||
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null) {
|
||||
switch (editorState.replayVisuals.overrideWeatherMode) {
|
||||
case CLEAR, OVERCAST -> forcePrecipitation = Biome.Precipitation.NONE;
|
||||
case RAINING, THUNDERING -> forcePrecipitation = Biome.Precipitation.RAIN;
|
||||
case SNOWING -> forcePrecipitation = Biome.Precipitation.SNOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderSnowAndRain", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;hasPrecipitation()Z"))
|
||||
public boolean renderSnowAndRain_hasPrecipitation(Biome instance, Operation<Boolean> original) {
|
||||
if (this.forcePrecipitation != null) {
|
||||
return this.forcePrecipitation != Biome.Precipitation.NONE;
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderSnowAndRain", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;getPrecipitationAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/biome/Biome$Precipitation;"))
|
||||
public Biome.Precipitation renderSnowAndRain_getPrecipitationAt(Biome instance, BlockPos blockPos, Operation<Biome.Precipitation> original) {
|
||||
if (this.forcePrecipitation != null) {
|
||||
return this.forcePrecipitation;
|
||||
} else {
|
||||
return original.call(instance, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Options;getCloudsType()Lnet/minecraft/client/CloudStatus;"), require = 0)
|
||||
public CloudStatus renderLevel_getCloudsType(Options instance, Operation<CloudStatus> original) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.moulberry.flashback.playback.ReplayServer;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -12,6 +13,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.visuals.ReplayVisuals;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Level.class)
|
||||
public abstract class MixinLevel {
|
||||
|
||||
@Inject(method = "getRainLevel", at = @At("HEAD"), cancellable = true)
|
||||
public void getRainLevel(float f, CallbackInfoReturnable<Float> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && (Object)this instanceof ClientLevel) {
|
||||
switch (editorState.replayVisuals.overrideWeatherMode) {
|
||||
case CLEAR -> cir.setReturnValue(0.0f);
|
||||
case OVERCAST, RAINING, SNOWING, THUNDERING -> cir.setReturnValue(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "getThunderLevel", at = @At("HEAD"), cancellable = true)
|
||||
public void getThunderLevel(float f, CallbackInfoReturnable<Float> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && (Object)this instanceof ClientLevel) {
|
||||
switch (editorState.replayVisuals.overrideWeatherMode) {
|
||||
case CLEAR, OVERCAST, RAINING, SNOWING -> cir.setReturnValue(0.0f);
|
||||
case THUNDERING -> cir.setReturnValue(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,6 +49,7 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.world.entity.Leashable;
|
||||
import net.minecraft.world.entity.LightningBolt;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
@@ -124,7 +125,15 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
|
||||
public void flushPendingEntities() {
|
||||
ServerLevel level = this.level();
|
||||
boolean canSpawnLightningBolt = switch (this.replayServer.getEditorState().replayVisuals.overrideWeatherMode) {
|
||||
case NONE, THUNDERING -> true;
|
||||
case CLEAR, OVERCAST, RAINING, SNOWING -> false;
|
||||
};
|
||||
for (Entity pendingEntity : this.pendingEntities.values()) {
|
||||
if (pendingEntity instanceof LightningBolt && !canSpawnLightningBolt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Entity existingEntity = level.getEntity(pendingEntity.getId());
|
||||
if (existingEntity != null) {
|
||||
if (existingEntity instanceof ServerPlayer existingPlayer) {
|
||||
@@ -288,6 +297,8 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
if (existingEntity instanceof ExperienceOrb) {
|
||||
existingEntity.restoreFrom(entity);
|
||||
return;
|
||||
} else if (existingEntity instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.connection.disconnect(Component.empty());
|
||||
} else if (existingEntity != null) {
|
||||
existingEntity.discard();
|
||||
}
|
||||
@@ -691,6 +702,9 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
Entity existing = this.localPlayerId == -1 ? null : this.getEntityOrPending(this.localPlayerId);
|
||||
if (existing == null) {
|
||||
this.spawnPlayer(addEntityPacket, gameProfile, gameType);
|
||||
} else {
|
||||
existing.moveTo(x, y, z, yRot, xRot);
|
||||
existing.setDeltaMovement(velocity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,30 +748,27 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
((ServerLevelExt) newLevel).flashback$setSeedHash(commonPlayerSpawnInfo.seed());
|
||||
this.replayServer.followLocalPlayerNextTickIfWrongDimension = true;
|
||||
|
||||
if (newLevel == oldLevel) {
|
||||
// Change to new dimension
|
||||
this.currentDimension = commonPlayerSpawnInfo.dimension();
|
||||
this.replayServer.spawnLevel = this.currentDimension;
|
||||
return;
|
||||
}
|
||||
|
||||
// Move local player and replay viewer
|
||||
if (localPlayer != null) {
|
||||
localPlayer.teleportTo(newLevel, 0.0, 0.0, 0.0, Set.of(), 0.0f, 0.0f);
|
||||
}
|
||||
for (ReplayPlayer replayViewer : this.replayServer.getReplayViewers()) {
|
||||
replayViewer.teleportTo(newLevel, replayViewer.getX(), replayViewer.getY(), replayViewer.getZ(), Set.of(),
|
||||
replayViewer.getYRot(), replayViewer.getXRot());
|
||||
replayViewer.followLocalPlayerNextTick = true;
|
||||
if (newLevel != oldLevel) {
|
||||
// Move local player and replay viewer
|
||||
if (localPlayer != null) {
|
||||
localPlayer.teleportTo(newLevel, 0.0, 0.0, 0.0, Set.of(), 0.0f, 0.0f);
|
||||
}
|
||||
for (ReplayPlayer replayViewer : this.replayServer.getReplayViewers()) {
|
||||
replayViewer.teleportTo(newLevel, replayViewer.getX(), replayViewer.getY(), replayViewer.getZ(), Set.of(),
|
||||
replayViewer.getYRot(), replayViewer.getXRot());
|
||||
replayViewer.followLocalPlayerNextTick = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete current dimension
|
||||
if (this.currentDimension == Level.OVERWORLD) {
|
||||
this.replayServer.clearLevel(this.level());
|
||||
} else if (this.currentDimension != null) {
|
||||
ServerLevel level = this.replayServer.levels.remove(this.currentDimension);
|
||||
if (level != null) {
|
||||
this.replayServer.closeLevel(level);
|
||||
if (this.currentDimension != null && this.currentDimension != dimension) {
|
||||
if (this.currentDimension == Level.OVERWORLD) {
|
||||
this.replayServer.clearLevel(this.level());
|
||||
} else if (this.currentDimension != null) {
|
||||
ServerLevel level = this.replayServer.levels.remove(this.currentDimension);
|
||||
if (level != null) {
|
||||
this.replayServer.closeLevel(level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,7 +1149,11 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
|
||||
Entity taken = this.level().getEntity(clientboundTakeItemEntityPacket.getItemId());
|
||||
if (taken != null) {
|
||||
taken.discard();
|
||||
if (taken instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.connection.disconnect(Component.empty());
|
||||
} else {
|
||||
taken.discard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ public class ReplayPlayer extends ServerPlayer {
|
||||
public boolean followLocalPlayerNextTick = false;
|
||||
public UUID spectatingUuid = null;
|
||||
public int spectatingUuidTickCount = 0;
|
||||
public int forceRespectateTickCount = 0;
|
||||
|
||||
public UUID lastFirstPersonDataUUID = null;
|
||||
public int lastFirstPersonSelectedSlot = -1;
|
||||
|
||||
@@ -662,16 +662,21 @@ public class ReplayServer extends IntegratedServer {
|
||||
this.configurationPacketHandler.flushPendingConfiguration();
|
||||
this.gamePacketHandler.flushPendingEntities();
|
||||
|
||||
int x = packet.getX();
|
||||
int z = packet.getZ();
|
||||
LevelChunk chunk = this.gamePacketHandler.level().getChunk(x, z);
|
||||
try {
|
||||
int x = packet.getX();
|
||||
int z = packet.getZ();
|
||||
LevelChunk chunk = this.gamePacketHandler.level().getChunk(x, z);
|
||||
|
||||
if (!doesCachedChunkIdMatch(chunk, index)) {
|
||||
packet.handle(this.gamePacketHandler);
|
||||
if (!doesCachedChunkIdMatch(chunk, index)) {
|
||||
packet.handle(this.gamePacketHandler);
|
||||
|
||||
if (chunk instanceof LevelChunkExt ext) {
|
||||
ext.flashback$setCachedChunkId(index);
|
||||
if (chunk instanceof LevelChunkExt ext) {
|
||||
ext.flashback$setCachedChunkId(index);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// Some mods are apparently incapable of returning a chunk when requesting it which causes an error here
|
||||
// Why a mod would be designed to do that? Only god knows
|
||||
}
|
||||
} else {
|
||||
Flashback.LOGGER.error("Missing cached level chunk: {}", index);
|
||||
@@ -706,7 +711,7 @@ public class ReplayServer extends IntegratedServer {
|
||||
}
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for (Entity entity : serverLevel.getAllEntities()) {
|
||||
if (entity instanceof ReplayPlayer) {
|
||||
if (entity instanceof ServerPlayer) {
|
||||
continue;
|
||||
}
|
||||
entities.add(entity);
|
||||
@@ -754,6 +759,7 @@ public class ReplayServer extends IntegratedServer {
|
||||
if (replayPlayer.isShiftKeyDown()) {
|
||||
replayPlayer.spectatingUuid = null;
|
||||
replayPlayer.spectatingUuidTickCount = 0;
|
||||
replayPlayer.forceRespectateTickCount = 0;
|
||||
} else {
|
||||
Entity cameraEntity = replayPlayer.getCamera();
|
||||
if (cameraEntity != null && cameraEntity != replayPlayer) {
|
||||
@@ -832,14 +838,21 @@ public class ReplayServer extends IntegratedServer {
|
||||
// Ensure replay viewers are still spectating
|
||||
if (replayViewer.spectatingUuid != null) {
|
||||
Entity camera = replayViewer.getCamera();
|
||||
if (camera == null || camera == replayViewer || camera.isRemoved()) {
|
||||
if (replayViewer.forceRespectateTickCount > 0 || camera == null || camera == replayViewer || camera.isRemoved()) {
|
||||
Entity targetEntity = replayViewer.serverLevel().getEntity(replayViewer.spectatingUuid);
|
||||
if (targetEntity != null && !targetEntity.isRemoved()) {
|
||||
replayViewer.setCamera(null);
|
||||
replayViewer.setCamera(targetEntity);
|
||||
|
||||
if (replayViewer.forceRespectateTickCount == 0) {
|
||||
replayViewer.forceRespectateTickCount = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (replayViewer.forceRespectateTickCount > 0) {
|
||||
replayViewer.forceRespectateTickCount -= 1;
|
||||
}
|
||||
|
||||
Entity camera = replayViewer.getCamera();
|
||||
if (camera != replayViewer && camera instanceof Player playerCamera) {
|
||||
|
||||
@@ -168,7 +168,7 @@ public class CombineReplayScreen extends Screen {
|
||||
complete.specialWorldProperty(), complete.lifecycle()), complete.dimensionsRegistryAccess());
|
||||
}, WorldStem::new, Util.backgroundExecutor(), executor)).get();
|
||||
|
||||
ReplayCombiner.combine(worldStem.registries().compositeAccess(), this.firstReplay, this.secondReplay, this.output);
|
||||
ReplayCombiner.combine(worldStem.registries().compositeAccess(), this.newReplayName, this.firstReplay, this.secondReplay, this.output);
|
||||
Minecraft.getInstance().setScreen(new TitleScreen());
|
||||
|
||||
worldStem.close();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.moulberry.flashback.spline;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.Interpolation;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.joml.Vector3d;
|
||||
@@ -188,10 +189,13 @@ public class CatmullRom {
|
||||
}
|
||||
|
||||
public static float degrees(float p0, float p1, float p2, float p3, float time1, float time2, float time3, float amount) {
|
||||
float delta1 = Mth.wrapDegrees(p1 - p0);
|
||||
float delta2 = Mth.wrapDegrees(p2 - p1);
|
||||
float delta3 = Mth.wrapDegrees(p3 - p2);
|
||||
p0 = Mth.wrapDegrees(p0);
|
||||
p1 = Mth.wrapDegrees(p1);
|
||||
p2 = Mth.wrapDegrees(p2);
|
||||
p3 = Mth.wrapDegrees(p3);
|
||||
p1 = p0 + delta1;
|
||||
p2 = p1 + delta2;
|
||||
p3 = p2 + delta3;
|
||||
|
||||
float tj1 = degreesCentripetalTj(p0, p1);
|
||||
float tj2 = degreesCentripetalTj(p1, p2);
|
||||
@@ -205,24 +209,27 @@ public class CatmullRom {
|
||||
float averageTime = time3 / 3f;
|
||||
float relation = averageTime / averageTj;
|
||||
|
||||
final float minFactor = 0.4f;
|
||||
final float maxFactor = 2.5f;
|
||||
|
||||
float deltaTime1 = 0.0f;
|
||||
if (time1 > 0.0f) {
|
||||
float factor1 = (tj1 * relation) / time1;
|
||||
factor1 = Math.max(0.4f, Math.min(2.5f, factor1));
|
||||
factor1 = Math.max(minFactor, Math.min(maxFactor, factor1));
|
||||
deltaTime1 = (tj1 * relation) / factor1;
|
||||
}
|
||||
|
||||
float deltaTime2 = 0.0f;
|
||||
if (time2 - time1 > 0.0f) {
|
||||
float factor2 = (tj2 * relation) / (time2 - time1);
|
||||
factor2 = Math.max(0.4f, Math.min(2.5f, factor2));
|
||||
factor2 = Math.max(minFactor, Math.min(maxFactor, factor2));
|
||||
deltaTime2 = (tj2 * relation) / factor2;
|
||||
}
|
||||
|
||||
float deltaTime3 = 0.0f;
|
||||
if (time3 - time2 > 0.0f) {
|
||||
float factor3 = (tj3 * relation) / (time3 - time2);
|
||||
factor3 = Math.max(0.4f, Math.min(2.5f, factor3));
|
||||
factor3 = Math.max(minFactor, Math.min(maxFactor, factor3));
|
||||
deltaTime3 = (tj3 * relation) / factor3;
|
||||
}
|
||||
|
||||
@@ -235,44 +242,40 @@ public class CatmullRom {
|
||||
|
||||
float a1;
|
||||
if (t0 == t1) {
|
||||
a1 = Interpolation.linearAngle(p0, p1, 0.5f);
|
||||
a1 = Interpolation.linear(p0, p1, 0.5f);
|
||||
} else {
|
||||
a1 = Interpolation.linearAngle(p0, p1, (t - t0)/(t1 - t0));
|
||||
a1 = Interpolation.linear(p0, p1, (t - t0)/(t1 - t0));
|
||||
}
|
||||
|
||||
float a2;
|
||||
if (t1 == t2) {
|
||||
a2 = Interpolation.linearAngle(p1, p2, 0.5f);
|
||||
a2 = Interpolation.linear(p1, p2, 0.5f);
|
||||
} else {
|
||||
a2 = Interpolation.linearAngle(p1, p2, (t - t1)/(t2 - t1));
|
||||
a2 = Interpolation.linear(p1, p2, (t - t1)/(t2 - t1));
|
||||
}
|
||||
|
||||
float a3;
|
||||
if (t2 == t3) {
|
||||
a3 = Interpolation.linearAngle(p2, p3, 0.5f);
|
||||
a3 = Interpolation.linear(p2, p3, 0.5f);
|
||||
} else {
|
||||
a3 = Interpolation.linearAngle(p2, p3, (t - t2)/(t3 - t2));
|
||||
a3 = Interpolation.linear(p2, p3, (t - t2)/(t3 - t2));
|
||||
}
|
||||
|
||||
float b1;
|
||||
if (t0 == t2) {
|
||||
b1 = Interpolation.linearAngle(a1, a2, 0.5f);
|
||||
b1 = Interpolation.linear(a1, a2, 0.5f);
|
||||
} else {
|
||||
b1 = Interpolation.linearAngle(a1, a2, (t - t0)/(t2 - t0));
|
||||
b1 = Interpolation.linear(a1, a2, (t - t0)/(t2 - t0));
|
||||
}
|
||||
|
||||
float b2;
|
||||
if (t1 == t3) {
|
||||
b2 = Interpolation.linearAngle(a2, a3, 0.5f);
|
||||
b2 = Interpolation.linear(a2, a3, 0.5f);
|
||||
} else {
|
||||
b2 = Interpolation.linearAngle(a2, a3, (t - t1)/(t3 - t1));
|
||||
b2 = Interpolation.linear(a2, a3, (t - t1)/(t3 - t1));
|
||||
}
|
||||
|
||||
if (t1 == t2) {
|
||||
return Interpolation.linearAngle(b1, b2, 0.5f);
|
||||
} else {
|
||||
return Interpolation.linearAngle(b1, b2, (t - t1)/(t2 - t1));
|
||||
}
|
||||
return Interpolation.linear(b1, b2, amount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.moulberry.flashback.visuals;
|
||||
|
||||
import com.moulberry.flashback.combo_options.AspectRatio;
|
||||
import com.moulberry.flashback.combo_options.Sizing;
|
||||
import com.moulberry.flashback.combo_options.WeatherOverride;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ReplayVisuals {
|
||||
@@ -41,6 +42,8 @@ public class ReplayVisuals {
|
||||
public boolean overrideRoll = false;
|
||||
public float overrideRollAmount = 0.0f;
|
||||
|
||||
public WeatherOverride overrideWeatherMode = WeatherOverride.NONE;
|
||||
|
||||
public long overrideTimeOfDay = -1;
|
||||
|
||||
public boolean overrideNightVision = false;
|
||||
|
||||
@@ -48,8 +48,8 @@
|
||||
},
|
||||
"mixins": [
|
||||
"MixinThreadedLevelLightEngine",
|
||||
"compat.axiom.MixinAxiomEditorUI",
|
||||
"compat.MixinSodiumWorldRenderer",
|
||||
"compat.axiom.MixinAxiomEditorUI",
|
||||
"compat.axiom.MixinAxiomServerIntegration",
|
||||
"compat.bobby.FakeChunkManagerAccessor",
|
||||
"compat.bobby.MixinBobby",
|
||||
@@ -83,6 +83,7 @@
|
||||
"replay_server.MixinServerEntity",
|
||||
"replay_server.MixinServerGamePacketListenerImpl",
|
||||
"replay_server.MixinServerLevel",
|
||||
"replay_server.MixinServerLoginPacketListenerImpl"
|
||||
"replay_server.MixinServerLoginPacketListenerImpl",
|
||||
"visuals.MixinLevel"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user