mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 06:28:48 +00:00
0.7.0
This commit is contained in:
1 parent
7f1d199704
commit
be99313e81
47 files changed
+1247
-337
No files matched your search
@@ -9,7 +9,6 @@ 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.VertexFormat;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
@@ -32,6 +31,7 @@ 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.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
@@ -224,7 +224,7 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
private final DeltaTracker.Timer localPlayerTimer = new DeltaTracker.Timer(20.0f, 0, FloatUnaryOperator.identity());
|
||||
|
||||
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;Z)V", at = @At("HEAD"))
|
||||
public void disconnect(Screen screen, boolean isTransferring, CallbackInfo ci) {
|
||||
public void disconnectHead(Screen screen, boolean isTransferring, CallbackInfo ci) {
|
||||
try {
|
||||
if (Flashback.getConfig().automaticallyFinish && Flashback.RECORDER != null && !isTransferring) {
|
||||
Flashback.finishRecordingReplay();
|
||||
@@ -234,14 +234,9 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MouseHandler;handleAccumulatedMovement()V", shift = At.Shift.AFTER))
|
||||
public void runTick_handleAccumulatedMovement(boolean runTick, CallbackInfo ci) {
|
||||
if (Flashback.RECORDER != null && this.player != null) {
|
||||
float partialTick = this.timer.deltaTickResidual;
|
||||
Flashback.RECORDER.trackPartialPosition(this.player, partialTick);
|
||||
}
|
||||
|
||||
AccurateEntityPositionHandler.apply(this.level, this.timer.deltaTickResidual);
|
||||
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;Z)V", at = @At("RETURN"))
|
||||
public void disconnectReturn(Screen screen, boolean bl, CallbackInfo ci) {
|
||||
Flashback.updateIsInReplay();
|
||||
}
|
||||
|
||||
@Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;runAllTasks()V", shift = At.Shift.AFTER))
|
||||
@@ -326,6 +321,7 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
this.progressListener.set(storingChunkProgressListener);
|
||||
return ProcessorChunkProgressListener.createStarted(storingChunkProgressListener, this.progressTasks::add);
|
||||
}, playbackUUID, path));
|
||||
Flashback.updateIsInReplay();
|
||||
this.isLocalServer = true;
|
||||
this.updateReportEnvironment(ReportEnvironment.local());
|
||||
// this.quickPlayLog.setWorldData(QuickPlayLog.Type.SINGLEPLAYER, levelStorageAccess.getLevelId(), worldStem.worldData().getLevelName());
|
||||
|
||||
@@ -22,6 +22,13 @@ public class MixinMouseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = {"onPress", "onScroll", "onMove"}, at = @At("HEAD"), cancellable = true)
|
||||
public void onUseMouse(CallbackInfo ci) {
|
||||
if (Flashback.isExporting()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "grabMouse", at=@At("HEAD"), cancellable = true)
|
||||
public void grabMouse(CallbackInfo ci) {
|
||||
if (ReplayUI.isActive() || Flashback.isExporting()) {
|
||||
|
||||
@@ -3,8 +3,15 @@ package com.moulberry.flashback.mixin;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
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.VertexFormat;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
@@ -14,12 +21,17 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Mixin(value = RenderTarget.class, priority = 800)
|
||||
public abstract class MixinRenderTarget {
|
||||
|
||||
@Shadow
|
||||
public int frameBufferId;
|
||||
|
||||
@Shadow
|
||||
public abstract int getColorTextureId();
|
||||
|
||||
@Inject(method = "blitToScreen(IIZ)V", at = @At("HEAD"), cancellable = true)
|
||||
public void blitToScreenSodium(int width, int height, boolean noBlend, CallbackInfo ci) {
|
||||
if ((Object)this == Minecraft.getInstance().getMainRenderTarget() && ReplayUI.isActive()) {
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.moulberry.flashback.mixin.compat.distanthorizons;
|
||||
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@IfModLoaded("distanthorizons")
|
||||
@Mixin(value = SharedApi.class, remap = false)
|
||||
public abstract class MixinSharedApi {
|
||||
|
||||
/*
|
||||
* Override any changes to the DhWorld, changing it to our proxy world
|
||||
*/
|
||||
|
||||
// @Inject(method = "setDhWorld", at = @At("HEAD"), cancellable = true)
|
||||
// private static void setDhWorld(AbstractDhWorld newWorld, CallbackInfo ci) {
|
||||
// if (Flashback.isInReplay() && newWorld != null && !(newWorld instanceof ProxyDhWorld)) {
|
||||
// SharedApi.setDhWorld(new ProxyDhWorld());
|
||||
// ci.cancel();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
||||
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.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(AbstractMinecart.class)
|
||||
public class MixinAbstractMinecart {
|
||||
|
||||
@Shadow
|
||||
private int lerpSteps;
|
||||
|
||||
@Inject(method = "lerpTo", at = @At("RETURN"))
|
||||
public void modifyLerpTime(double d, double e, double f, float g, float h, int i, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
this.lerpSteps = 3;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
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;
|
||||
|
||||
@Mixin(Boat.class)
|
||||
public class MixinBoat {
|
||||
|
||||
@Shadow
|
||||
private int lerpSteps;
|
||||
|
||||
@Inject(method = "lerpTo", at = @At("RETURN"))
|
||||
public void modifyLerpTime(double d, double e, double f, float g, float h, int i, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
this.lerpSteps = 3;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.moulberry.flashback.visuals.AccurateEntityPositionHandler;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3d;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public class MixinCamera {
|
||||
|
||||
@Shadow
|
||||
private float eyeHeightOld;
|
||||
|
||||
@Shadow
|
||||
public float eyeHeight;
|
||||
|
||||
@WrapOperation(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setRotation(FF)V", ordinal = 0))
|
||||
public void setRotation(Camera instance, float yaw, float pitch, Operation<Void> original,
|
||||
@Local(argsOnly = true) Entity entity, @Local(argsOnly = true) float partialTick) {
|
||||
Vector2f rotation = AccurateEntityPositionHandler.getAccurateRotation(entity, partialTick);
|
||||
if (rotation != null) {
|
||||
pitch = rotation.x;
|
||||
yaw = rotation.y;
|
||||
}
|
||||
original.call(instance, yaw, pitch);
|
||||
}
|
||||
|
||||
|
||||
@WrapOperation(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setPosition(DDD)V", ordinal = 0))
|
||||
public void setPosition(Camera instance, double x, double y, double z, Operation<Void> original,
|
||||
@Local(argsOnly = true) Entity entity, @Local(argsOnly = true) float partialTick) {
|
||||
Vector3d position = AccurateEntityPositionHandler.getAccuratePosition(entity, partialTick);
|
||||
if (position != null) {
|
||||
x = position.x;
|
||||
y = position.y + Mth.lerp(partialTick, this.eyeHeightOld, this.eyeHeight);
|
||||
z = position.z;
|
||||
}
|
||||
original.call(instance, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,4 +53,5 @@ public abstract class MixinEntity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import com.moulberry.flashback.ext.ItemInHandRendererExt;
|
||||
import com.moulberry.flashback.ext.MinecraftExt;
|
||||
import com.moulberry.flashback.visuals.AccurateEntityPositionHandler;
|
||||
import com.moulberry.flashback.visuals.CameraRotation;
|
||||
import com.moulberry.flashback.visuals.ShaderManager;
|
||||
import net.minecraft.client.Camera;
|
||||
@@ -55,19 +56,26 @@ public abstract class MixinGameRenderer {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Minecraft minecraft;
|
||||
Minecraft minecraft;
|
||||
|
||||
@Shadow
|
||||
public abstract float getDepthFar();
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
public void renderHead(DeltaTracker deltaTracker, boolean bl, CallbackInfo ci) {
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
|
||||
@Shadow
|
||||
public abstract void renderLevel(DeltaTracker deltaTracker);
|
||||
if (Flashback.RECORDER != null && player != null) {
|
||||
float partialTick = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||
Flashback.RECORDER.trackPartialPosition(player, partialTick);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private @Nullable PostChain postEffect;
|
||||
AccurateEntityPositionHandler.apply(Minecraft.getInstance().level, deltaTracker);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private boolean effectActive;
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(IZ)V", remap = false, ordinal = 0), cancellable = true)
|
||||
public void render_noGui(DeltaTracker deltaTracker, boolean bl, CallbackInfo ci) {
|
||||
if (Flashback.isExporting() && Flashback.EXPORT_JOB.getSettings().noGui()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
@@ -63,7 +63,12 @@ public abstract class MixinLevelChunk extends ChunkAccess implements LevelChunkE
|
||||
@Override
|
||||
public void flashback$setBlockStateWithoutUpdates(BlockPos blockPos, BlockState blockState) {
|
||||
int y = blockPos.getY();
|
||||
LevelChunkSection levelChunkSection = this.getSection(this.getSectionIndex(y));
|
||||
int sectionY = this.getSectionIndex(y);
|
||||
if (sectionY < 0 || sectionY >= this.getSectionsCount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LevelChunkSection levelChunkSection = this.getSection(sectionY);
|
||||
boolean oldHasOnlyAir = levelChunkSection.hasOnlyAir();
|
||||
if (oldHasOnlyAir && blockState.isAir()) {
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.moulberry.flashback.mixin.record;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Mixin(LocalPlayer.class)
|
||||
public class MixinLocalPlayer {
|
||||
|
||||
@WrapOperation(method = "playSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;playLocalSound(DDDLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFZ)V"))
|
||||
public void playSound(Level instance, double x, double y, double z, SoundEvent soundEvent, SoundSource soundSource,
|
||||
float volume, float pitch, boolean global, Operation<Void> original) {
|
||||
if (Flashback.RECORDER != null && !Flashback.RECORDER.isPaused()) {
|
||||
|
||||
Optional<Holder.Reference<SoundEvent>> builtinSoundEvent = BuiltInRegistries.SOUND_EVENT.getHolder(soundEvent.getLocation());
|
||||
Holder<SoundEvent> holder;
|
||||
if (builtinSoundEvent.isEmpty()) {
|
||||
holder = Holder.direct(soundEvent);
|
||||
} else {
|
||||
holder = builtinSoundEvent.get();
|
||||
}
|
||||
|
||||
Flashback.RECORDER.writeSound(holder, soundSource, x, y, z, volume, pitch,
|
||||
ThreadLocalRandom.current().nextLong());
|
||||
}
|
||||
original.call(instance, x, y, z, soundEvent, soundSource, volume, pitch, global);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.moulberry.flashback.mixin.record;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.resources.sounds.Sound;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundManager;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Mixin(MultiPlayerGameMode.class)
|
||||
public class MixinMultiPlayerGameMode {
|
||||
|
||||
@WrapOperation(method = "continueDestroyBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sounds/SoundManager;play(Lnet/minecraft/client/resources/sounds/SoundInstance;)V"))
|
||||
public void playBreakingSound(SoundManager instance, SoundInstance soundInstance, Operation<Void> original) {
|
||||
original.call(instance, soundInstance);
|
||||
|
||||
if (Flashback.RECORDER != null && !Flashback.RECORDER.isPaused()) {
|
||||
if (soundInstance.getSound() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<Holder.Reference<SoundEvent>> builtinSoundEvent = BuiltInRegistries.SOUND_EVENT.getHolder(soundInstance.getLocation());
|
||||
Holder<SoundEvent> holder;
|
||||
if (builtinSoundEvent.isEmpty()) {
|
||||
holder = Holder.direct(SoundEvent.createVariableRangeEvent(soundInstance.getLocation()));
|
||||
} else {
|
||||
holder = builtinSoundEvent.get();
|
||||
}
|
||||
|
||||
SoundSource soundSource = soundInstance.getSource();
|
||||
float volume = soundInstance.getVolume();
|
||||
float pitch = soundInstance.getPitch();
|
||||
double x = soundInstance.getX();
|
||||
double y = soundInstance.getY();
|
||||
double z = soundInstance.getZ();
|
||||
|
||||
Flashback.RECORDER.writeSound(holder, soundSource, x, y, z, volume, pitch,
|
||||
ThreadLocalRandom.current().nextLong());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class MixinServerEntity {
|
||||
|
||||
@ModifyVariable(method = "<init>", at = @At("HEAD"), argsOnly = true)
|
||||
private static int init_modifyUpdateInterval(int updateInterval, @Local(argsOnly = true) ServerLevel level) {
|
||||
if (updateInterval <= 3 && level != null && level.getServer() instanceof ReplayServer) {
|
||||
if (updateInterval < 20 && level != null && level.getServer() instanceof ReplayServer) {
|
||||
return 1;
|
||||
}
|
||||
return updateInterval;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.moulberry.flashback.mixin.replay_server;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.server.ServerTickRateManager;
|
||||
import net.minecraft.world.TickRateManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
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;
|
||||
|
||||
@Mixin(TickRateManager.class)
|
||||
public abstract class MixinTickRateManager {
|
||||
|
||||
|
||||
|
||||
@Inject(method = "isEntityFrozen", at = @At("RETURN"))
|
||||
public void isEntityFrozen(Entity entity, CallbackInfoReturnable<Boolean> cir) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.screen.FlashbackButton;
|
||||
import com.moulberry.flashback.screen.SelectReplayScreen;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.Screens;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.AbstractButton;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
@@ -14,10 +16,13 @@ import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.AlertScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -87,7 +92,21 @@ public class MixinTitleScreen extends Screen {
|
||||
|
||||
if (!overlapsWithExistingButton) {
|
||||
this.openSelectReplayScreenButton = new FlashbackButton(x, y, size, size, Component.literal("Open Replays"), button -> {
|
||||
this.minecraft.setScreen(new SelectReplayScreen(this));
|
||||
List<String> incompatibleMods = Screen.hasShiftDown() ? List.of() : Flashback.getReplayIncompatibleMods();
|
||||
|
||||
if (incompatibleMods.isEmpty()) {
|
||||
this.minecraft.setScreen(new SelectReplayScreen(this));
|
||||
} else {
|
||||
String mods = StringUtils.join(incompatibleMods, ", ");
|
||||
String description = """
|
||||
You have mods which are known to cause crashes when loading replays
|
||||
Please remove the following mods in order to be able to load replays:
|
||||
|
||||
""";
|
||||
this.minecraft.setScreen(new AlertScreen(() -> Minecraft.getInstance().setScreen(this),
|
||||
Component.literal("Incompatible Mods"), Component.literal(description).append(Component.literal(mods).withStyle(ChatFormatting.RED))));
|
||||
}
|
||||
|
||||
});
|
||||
this.addRenderableWidget(this.openSelectReplayScreenButton);
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,36 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(ClientLevel.class)
|
||||
public class MixinClientLevel {
|
||||
|
||||
/*
|
||||
* Some entities have weird behaviour when rotating in a replay
|
||||
* This code here ensures that the interpolation of yRotO -> yRot will always be the shortest path
|
||||
*/
|
||||
|
||||
@Inject(method = "tickNonPassenger", at = @At("RETURN"))
|
||||
public void tickNonPassengerEnd(Entity entity, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
entity.xRotO = Mth.wrapDegrees(entity.xRotO - entity.getXRot()) + entity.getXRot();
|
||||
entity.yRotO = Mth.wrapDegrees(entity.yRotO - entity.getYRot()) + entity.getYRot();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tickPassenger", at = @At("RETURN"))
|
||||
public void tickPassengerEnd(Entity vehicle, Entity entity, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
entity.xRotO = Mth.wrapDegrees(entity.xRotO - entity.getXRot()) + entity.getXRot();
|
||||
entity.yRotO = Mth.wrapDegrees(entity.yRotO - entity.getYRot()) + entity.getYRot();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -86,6 +86,14 @@ public abstract class MixinGui {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderHotbarAndDecorations", at = @At("HEAD"), cancellable = true)
|
||||
public void renderHotbarAndDecorations(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && !editorState.replayVisuals.showHotbar) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderHotbarAndDecorations", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;getPlayerMode()Lnet/minecraft/world/level/GameType;"))
|
||||
public GameType renderHotbarAndDecorations_getPlayerMode(MultiPlayerGameMode instance, Operation<GameType> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
|
||||
Reference in new issue
Block a user