mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 22:17:10 +00:00
0.4.0
This commit is contained in:
1 parent
fcf1b4168f
commit
2fbe1f5480
46 files changed
+1846
-132
No files matched your search
@@ -5,7 +5,6 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.configuration.FlashbackConfig;
|
||||
import com.moulberry.flashback.exporting.ExportJob;
|
||||
import com.moulberry.flashback.exporting.ExportJobQueue;
|
||||
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
||||
@@ -15,6 +14,7 @@ import com.moulberry.flashback.exporting.PerfectFrames;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import com.moulberry.flashback.ext.MinecraftExt;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import com.moulberry.flashback.visuals.AccurateEntityPositionHandler;
|
||||
import it.unimi.dsi.fastutil.floats.FloatUnaryOperator;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.ReportedException;
|
||||
@@ -43,13 +43,12 @@ import net.minecraft.server.level.progress.ProcessorChunkProgressListener;
|
||||
import net.minecraft.server.level.progress.StoringChunkProgressListener;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.players.GameProfileCache;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.TickRateManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -69,7 +68,6 @@ import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
@@ -140,6 +138,10 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
@Nullable
|
||||
public Entity cameraEntity;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public DeltaTracker.Timer timer;
|
||||
|
||||
@Inject(method="<init>", at=@At("RETURN"))
|
||||
public void init(GameConfig gameConfig, CallbackInfo ci) {
|
||||
ReplayUI.init();
|
||||
@@ -163,13 +165,10 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
@WrapOperation(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sounds/SoundManager;updateSource(Lnet/minecraft/client/Camera;)V"))
|
||||
public void runTick_updateSource(SoundManager instance, Camera camera, Operation<Void> original) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.audioSourceEntity != null && this.level != null) {
|
||||
Entity sourceEntity = this.level.getEntities().get(editorState.audioSourceEntity);
|
||||
if (sourceEntity != null) {
|
||||
Camera dummyCamera = new Camera();
|
||||
dummyCamera.eyeHeight = sourceEntity.getEyeHeight();
|
||||
dummyCamera.setup(this.level, sourceEntity, false, false, 1.0f);
|
||||
instance.updateSource(dummyCamera);
|
||||
if (editorState != null) {
|
||||
Camera audioCamera = editorState.getAudioCamera();
|
||||
if (audioCamera != null) {
|
||||
original.call(instance, audioCamera);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -235,6 +234,16 @@ 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 = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;runAllTasks()V", shift = At.Shift.AFTER))
|
||||
public void runTick_runAllTasks(boolean runTick, CallbackInfo ci) {
|
||||
if (ExportJobQueue.drainingQueue) {
|
||||
|
||||
@@ -11,10 +11,11 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@IfModLoaded("bobby")
|
||||
@Mixin(value = Bobby.class, remap = false)
|
||||
@Mixin(value = Bobby.class)
|
||||
public class MixinBobby {
|
||||
|
||||
@WrapOperation(method = "isEnabled", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSingleplayerServer()Lnet/minecraft/client/server/IntegratedServer;"))
|
||||
@WrapOperation(method = "isEnabled", require = 0, remap = false, 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) {
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import java.util.function.Supplier;
|
||||
@Mixin(value = FakeChunkManager.class, remap = false)
|
||||
public class MixinBobbyFakeChunkManager {
|
||||
|
||||
@Inject(method = "getCurrentWorldOrServerName", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "getCurrentWorldOrServerName", require = 0, at = @At("HEAD"), cancellable = true)
|
||||
private static void getCurrentWorldOrServerName(ClientPacketListener networkHandler, CallbackInfoReturnable<String> cir) {
|
||||
ReplayServer replayServer = Flashback.getReplayServer();
|
||||
if (replayServer != null) {
|
||||
@@ -34,7 +34,7 @@ public class MixinBobbyFakeChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "save", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "save", at = @At("HEAD"), require = 0, cancellable = true)
|
||||
public void save(LevelChunk chunk, CallbackInfoReturnable<Supplier<LevelChunk>> cir) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Pair<LevelChunk, Supplier<LevelChunk>> copy = ChunkSerializer.shallowCopy(chunk);
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.moulberry.flashback.mixin.compat.voice_chat;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import de.maxhenkel.voicechat.voice.client.speaker.ALSpeakerBase;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@IfModLoaded("voicechat")
|
||||
@Mixin(ALSpeakerBase.class)
|
||||
public class MixinVoiceChatALSpeakerBase {
|
||||
|
||||
@WrapOperation(method = "setPositionSync", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;getMainCamera()Lnet/minecraft/client/Camera;"))
|
||||
public Camera setPositionSync_getMainCamera(GameRenderer instance, Operation<Camera> original) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null) {
|
||||
Camera audioCamera = editorState.getAudioCamera();
|
||||
if (audioCamera != null) {
|
||||
return audioCamera;
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.moulberry.flashback.mixin.compat.voice_chat;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import de.maxhenkel.voicechat.voice.client.ClientVoicechat;
|
||||
import de.maxhenkel.voicechat.voice.client.ClientVoicechatConnection;
|
||||
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;
|
||||
|
||||
@IfModLoaded("voicechat")
|
||||
@Mixin(value = ClientVoicechat.class, remap = false)
|
||||
public class MixinVoiceChatClientVoicechat {
|
||||
|
||||
@Inject(method = "startMicThread", at = @At("HEAD"), cancellable = true)
|
||||
public void startMicThread(ClientVoicechatConnection connection, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.moulberry.flashback.mixin.compat.voice_chat;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import de.maxhenkel.voicechat.voice.client.RenderEvents;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@IfModLoaded("voicechat")
|
||||
@Mixin(value = RenderEvents.class, remap = false)
|
||||
public class MixinVoiceChatRenderEvents {
|
||||
|
||||
@Inject(method = "shouldShowIcons", at = @At("HEAD"), cancellable = true)
|
||||
public void shouldShowIcons(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Flashback.isInReplay()) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderIcon", at = @At("HEAD"), cancellable = true)
|
||||
public void renderIcon(GuiGraphics guiGraphics, ResourceLocation texture, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.moulberry.flashback.mixin.compat.voice_chat;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import de.maxhenkel.voicechat.voice.client.SoundManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.openal.EXTThreadLocalContext;
|
||||
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("voicechat")
|
||||
@Mixin(value = SoundManager.class, remap = false)
|
||||
public class MixinVoiceChatSoundManager {
|
||||
|
||||
@Inject(method = "openContext", at = @At("HEAD"), cancellable = true)
|
||||
public void openContext(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Flashback.isExporting() && Flashback.EXPORT_JOB.getSettings().recordAudio()) {
|
||||
long context = Minecraft.getInstance().getSoundManager().soundEngine.library.context;
|
||||
cir.setReturnValue(EXTThreadLocalContext.alcSetThreadContext(context));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,19 +2,25 @@ package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.ext.ItemInHandRendererExt;
|
||||
import com.moulberry.flashback.ext.RemotePlayerExt;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -43,6 +49,42 @@ public abstract class MixinItemInHandRenderer implements ItemInHandRendererExt {
|
||||
@Shadow
|
||||
private ItemStack offHandItem;
|
||||
|
||||
@Shadow
|
||||
private static boolean isChargedCrossbow(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static final int RENDER_MAIN_HAND = 1;
|
||||
@Unique
|
||||
private static final int RENDER_OFF_HAND = 2;
|
||||
@Unique
|
||||
private static final int RENDER_BOTH_HANDS = RENDER_MAIN_HAND | RENDER_OFF_HAND;
|
||||
|
||||
@Unique
|
||||
private static int evaluateWhichHandsToRender(AbstractClientPlayer player) {
|
||||
ItemStack mainStack = player.getMainHandItem();
|
||||
ItemStack offStack = player.getOffhandItem();
|
||||
boolean isHoldingBow = mainStack.is(Items.BOW) || offStack.is(Items.BOW);
|
||||
boolean isHoldingCrossbow = mainStack.is(Items.CROSSBOW) || offStack.is(Items.CROSSBOW);
|
||||
if (!isHoldingBow && !isHoldingCrossbow) {
|
||||
return RENDER_BOTH_HANDS;
|
||||
}
|
||||
if (player.isUsingItem()) {
|
||||
ItemStack useStack = player.getUseItem();
|
||||
InteractionHand interactionHand = player.getUsedItemHand();
|
||||
if (!useStack.is(Items.BOW) && !useStack.is(Items.CROSSBOW)) {
|
||||
return interactionHand == InteractionHand.MAIN_HAND && isChargedCrossbow(player.getOffhandItem()) ? RENDER_MAIN_HAND : RENDER_BOTH_HANDS;
|
||||
} else {
|
||||
return interactionHand == InteractionHand.MAIN_HAND ? RENDER_MAIN_HAND : RENDER_OFF_HAND;
|
||||
}
|
||||
}
|
||||
if (isChargedCrossbow(mainStack)) {
|
||||
return RENDER_MAIN_HAND;
|
||||
}
|
||||
return RENDER_BOTH_HANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flashback$renderHandsWithItems(float partialTick, PoseStack poseStack, MultiBufferSource.BufferSource bufferSource, AbstractClientPlayer clientPlayer, int i) {
|
||||
float m;
|
||||
@@ -50,19 +92,19 @@ public abstract class MixinItemInHandRenderer implements ItemInHandRendererExt {
|
||||
float g = clientPlayer.getAttackAnim(partialTick);
|
||||
InteractionHand interactionHand = MoreObjects.firstNonNull(clientPlayer.swingingArm, InteractionHand.MAIN_HAND);
|
||||
float h = Mth.lerp(partialTick, clientPlayer.xRotO, clientPlayer.getXRot());
|
||||
// todo: hand selection
|
||||
// ItemInHandRenderer.HandRenderSelection handRenderSelection = evaluateWhichHandsToRender(clientPlayer);
|
||||
// todo: bob
|
||||
// float j = Mth.lerp((float)f, (float)clientPlayer.xBobO, (float)clientPlayer.xBob);
|
||||
// float k = Mth.lerp((float)f, (float)clientPlayer.yBobO, (float)clientPlayer.yBob);
|
||||
// poseStack.mulPose(Axis.XP.rotationDegrees((clientPlayer.getViewXRot(f) - j) * 0.1f));
|
||||
// poseStack.mulPose(Axis.YP.rotationDegrees((clientPlayer.getViewYRot(f) - k) * 0.1f));
|
||||
if (true) {
|
||||
int handRenderSelection = evaluateWhichHandsToRender(clientPlayer);
|
||||
if (clientPlayer instanceof RemotePlayerExt remotePlayerExt) {
|
||||
// float xBob = remotePlayerExt.flashback$getXBob(partialTick);
|
||||
// float yBob = remotePlayerExt.flashback$getYBob(partialTick);
|
||||
// poseStack.mulPose(Axis.XP.rotationDegrees((clientPlayer.getViewXRot(partialTick) - xBob) * 0.1f));
|
||||
// poseStack.mulPose(Axis.YP.rotationDegrees((clientPlayer.getViewYRot(partialTick) - yBob) * 0.1f));
|
||||
}
|
||||
if ((handRenderSelection & RENDER_MAIN_HAND) != 0) {
|
||||
l = interactionHand == InteractionHand.MAIN_HAND ? g : 0.0f;
|
||||
m = 1.0f - Mth.lerp(partialTick, this.oMainHandHeight, this.mainHandHeight);
|
||||
renderArmWithItem(clientPlayer, partialTick, h, InteractionHand.MAIN_HAND, l, this.mainHandItem, m, poseStack, bufferSource, i);
|
||||
}
|
||||
if (true) {
|
||||
if ((handRenderSelection & RENDER_OFF_HAND) != 0) {
|
||||
l = interactionHand == InteractionHand.OFF_HAND ? g : 0.0f;
|
||||
m = 1.0f - Mth.lerp(partialTick, this.oOffHandHeight, this.offHandHeight);
|
||||
renderArmWithItem(clientPlayer, partialTick, h, InteractionHand.OFF_HAND, l, this.offHandItem, m, poseStack, bufferSource, i);
|
||||
@@ -70,9 +112,32 @@ public abstract class MixinItemInHandRenderer implements ItemInHandRendererExt {
|
||||
bufferSource.endBatch();
|
||||
}
|
||||
|
||||
// todo: change first person FOV when pulling bows, etc.
|
||||
@ModifyArg(method = "renderPlayerArm", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;getRenderer(Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/client/renderer/entity/EntityRenderer;"))
|
||||
public Entity renderPlayerArm_getRenderer(Entity entity) {
|
||||
AbstractClientPlayer spectatingPlayer = Flashback.getSpectatingPlayer();
|
||||
if (spectatingPlayer != null) {
|
||||
return spectatingPlayer;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
// todo: show arm (need to replace usage of LocalPlayer in renderPlayerArm
|
||||
@ModifyArg(method = "renderPlayerArm", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/player/PlayerRenderer;renderLeftHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;)V"))
|
||||
public AbstractClientPlayer renderPlayerArm_renderLeftHand(AbstractClientPlayer entity) {
|
||||
AbstractClientPlayer spectatingPlayer = Flashback.getSpectatingPlayer();
|
||||
if (spectatingPlayer != null) {
|
||||
return spectatingPlayer;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "renderPlayerArm", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/player/PlayerRenderer;renderRightHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;)V"))
|
||||
public AbstractClientPlayer renderPlayerArm_renderRightHand(AbstractClientPlayer entity) {
|
||||
AbstractClientPlayer spectatingPlayer = Flashback.getSpectatingPlayer();
|
||||
if (spectatingPlayer != null) {
|
||||
return spectatingPlayer;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private UUID lastSpectatingPlayer = null;
|
||||
@@ -104,15 +169,9 @@ public abstract class MixinItemInHandRenderer implements ItemInHandRendererExt {
|
||||
if (ItemStack.matches(this.offHandItem, newOffHandItem)) {
|
||||
this.offHandItem = newOffHandItem;
|
||||
}
|
||||
if (false /*clientPlayer.isHandsBusy()*/) {
|
||||
this.mainHandHeight = Mth.clamp((float)(this.mainHandHeight - 0.4f), (float)0.0f, (float)1.0f);
|
||||
this.offHandHeight = Mth.clamp((float)(this.offHandHeight - 0.4f), (float)0.0f, (float)1.0f);
|
||||
} else {
|
||||
// todo: attack strength
|
||||
float f = 1.0f;//spectatingPlayer.getAttackStrengthScale(1.0f);
|
||||
this.mainHandHeight += Mth.clamp((this.mainHandItem == newMainHandItem ? f * f * f : 0.0f) - this.mainHandHeight, -0.4f, 0.4f);
|
||||
this.offHandHeight += Mth.clamp((float)(this.offHandItem == newOffHandItem ? 1 : 0) - this.offHandHeight, -0.4f, 0.4f);
|
||||
}
|
||||
float str = spectatingPlayer.getAttackStrengthScale(1.0f);
|
||||
this.mainHandHeight += Mth.clamp((this.mainHandItem == newMainHandItem ? str * str * str : 0.0f) - this.mainHandHeight, -0.4f, 0.4f);
|
||||
this.offHandHeight += Mth.clamp((float)(this.offHandItem == newOffHandItem ? 1 : 0) - this.offHandHeight, -0.4f, 0.4f);
|
||||
if (this.mainHandHeight < 0.1f) {
|
||||
this.mainHandItem = newMainHandItem;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
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;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.ext.RemotePlayerExt;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.RemotePlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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;
|
||||
|
||||
@Mixin(RemotePlayer.class)
|
||||
public class MixinRemotePlayer extends AbstractClientPlayer implements RemotePlayerExt {
|
||||
|
||||
@Unique
|
||||
private boolean wasSwinging = false;
|
||||
|
||||
@Unique
|
||||
private float xBobO = 0.0f;
|
||||
@Unique
|
||||
private float xBob = 0.0f;
|
||||
@Unique
|
||||
private float yBobO = 0.0f;
|
||||
@Unique
|
||||
private float yBob = 0.0f;
|
||||
|
||||
private MixinRemotePlayer(ClientLevel clientLevel, GameProfile gameProfile) {
|
||||
super(clientLevel, gameProfile);
|
||||
}
|
||||
|
||||
@Inject(method = "aiStep", at = @At("RETURN"))
|
||||
public void aiStep(CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
if (!this.wasSwinging && this.swinging) {
|
||||
this.resetAttackStrengthTicker();
|
||||
}
|
||||
this.wasSwinging = this.swinging;
|
||||
|
||||
this.xBobO = xBob;
|
||||
this.xBob += Mth.wrapDegrees(this.getXRot() - this.xBob) * 0.5f;
|
||||
this.yBobO = yBob;
|
||||
this.yBob += Mth.wrapDegrees(this.getYRot() - this.yBob) * 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float flashback$getXBob(float partialTick) {
|
||||
return Mth.lerp(partialTick, this.xBobO, this.xBob);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float flashback$getYBob(float partialTick) {
|
||||
return Mth.lerp(partialTick, this.yBobO, this.yBob);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,58 @@
|
||||
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 com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.editor.ui.CustomImGuiImplGlfw;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Gui.class)
|
||||
public class MixinGui {
|
||||
public abstract class MixinGui {
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
protected abstract Player getCameraPlayer();
|
||||
|
||||
@Unique
|
||||
private GameType cameraGameType = GameType.DEFAULT_MODE;
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
public void render_updateCameraGameType(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
var connection = Minecraft.getInstance().getConnection();
|
||||
if (connection != null) {
|
||||
var playerInfo = connection.getPlayerInfo(player.getUUID());
|
||||
if (playerInfo != null) {
|
||||
this.cameraGameType = playerInfo.getGameMode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cameraGameType = Minecraft.getInstance().gameMode.getPlayerMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderChat", at = @At("HEAD"), cancellable = true)
|
||||
public void renderChat(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) {
|
||||
@@ -51,6 +86,84 @@ public class MixinGui {
|
||||
}
|
||||
}
|
||||
|
||||
@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()) {
|
||||
return this.cameraGameType;
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderHotbarAndDecorations", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;canHurtPlayer()Z"))
|
||||
public boolean renderHotbarAndDecorations_canHurtPlayer(MultiPlayerGameMode instance, Operation<Boolean> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
return this.cameraGameType.isSurvival();
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@Inject(method = "isExperienceBarVisible", at = @At("HEAD"), cancellable = true)
|
||||
public void isExperienceBarVisible(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Flashback.isInReplay()) {
|
||||
cir.setReturnValue(this.cameraGameType.isSurvival());
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderExperienceBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getXpNeededForNextLevel()I"))
|
||||
public int renderExperienceBar_getXpNeededForNextLevel(LocalPlayer instance, Operation<Integer> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.getXpNeededForNextLevel();
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderExperienceBar", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;experienceProgress:F"))
|
||||
public float renderExperienceBar_experienceProgress(LocalPlayer instance, Operation<Float> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.experienceProgress;
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getAttackStrengthScale(F)F"))
|
||||
public float renderCrosshair_getAttackStrengthScale(LocalPlayer instance, float partialTick, Operation<Float> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.getAttackStrengthScale(partialTick);
|
||||
}
|
||||
}
|
||||
return original.call(instance, partialTick);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getCurrentItemAttackStrengthDelay()F"))
|
||||
public float renderCrosshair_getCurrentItemAttackStrengthDelay(LocalPlayer instance, Operation<Float> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.getCurrentItemAttackStrengthDelay();
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderExperienceLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;experienceLevel:I"))
|
||||
public int renderExperienceLevel_experienceLevel(LocalPlayer instance, Operation<Integer> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.experienceLevel;
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@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
|
||||
@@ -62,16 +175,12 @@ public class MixinGui {
|
||||
|
||||
@Inject(method = "canRenderCrosshairForSpectator", at = @At("HEAD"), cancellable = true)
|
||||
public void canRenderCrosshairForSpectator(HitResult hitResult, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Flashback.isExporting()) {
|
||||
cir.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
if (ReplayUI.isActive() && ReplayUI.imguiGlfw.getMouseHandledBy() == CustomImGuiImplGlfw.MouseHandledBy.GAME) {
|
||||
cir.setReturnValue(true);
|
||||
return;
|
||||
}
|
||||
if (Flashback.getSpectatingPlayer() != null) {
|
||||
cir.setReturnValue(true);
|
||||
if (Flashback.isInReplay()) {
|
||||
if (!Flashback.isExporting() && ReplayUI.isActive() && ReplayUI.imguiGlfw.getMouseHandledBy() == CustomImGuiImplGlfw.MouseHandledBy.GAME) {
|
||||
cir.setReturnValue(true);
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(Flashback.getSpectatingPlayer() != null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user