mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 06:28:48 +00:00
Public Release
This commit is contained in:
1 parent
666398e480
commit
61bb497a22
126 files changed
+8435
-1240
No files matched your search
@@ -4,10 +4,12 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.ReplayVisuals;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
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.CameraRotation;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
@@ -20,6 +22,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.joml.Quaternionf;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -29,7 +32,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class MixinGameRenderer {
|
||||
public abstract class MixinGameRenderer {
|
||||
|
||||
|
||||
@WrapOperation(method = "render", at=@At(value = "FIELD", target = "Lnet/minecraft/client/Options;pauseOnLostFocus:Z"))
|
||||
@@ -48,6 +51,9 @@ public class MixinGameRenderer {
|
||||
@Final
|
||||
private Minecraft minecraft;
|
||||
|
||||
@Shadow
|
||||
public abstract float getDepthFar();
|
||||
|
||||
@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) {
|
||||
if (Flashback.getSpectatingPlayer() != null) {
|
||||
@@ -60,8 +66,9 @@ public class MixinGameRenderer {
|
||||
public void renderItemInHand_renderHandsWithItems(ItemInHandRenderer instance, float f, PoseStack poseStack, MultiBufferSource.BufferSource bufferSource, LocalPlayer localPlayer, int i, Operation<Void> original) {
|
||||
AbstractClientPlayer spectatingPlayer = Flashback.getSpectatingPlayer();
|
||||
if (spectatingPlayer != null) {
|
||||
f = ((MinecraftExt)this.minecraft).flashback$getLocalPlayerPartialTick();
|
||||
((ItemInHandRendererExt)instance).flashback$renderHandsWithItems(f, poseStack, bufferSource, spectatingPlayer, i);
|
||||
Entity entity = this.minecraft.getCameraEntity() == null ? this.minecraft.player : this.minecraft.getCameraEntity();
|
||||
float frozenPartialTick = this.minecraft.level.tickRateManager().isEntityFrozen(entity) ? 1.0f : f;
|
||||
((ItemInHandRendererExt)instance).flashback$renderHandsWithItems(frozenPartialTick, poseStack, bufferSource, spectatingPlayer, i);
|
||||
} else {
|
||||
original.call(instance, f, poseStack, bufferSource, localPlayer, i);
|
||||
}
|
||||
@@ -70,11 +77,34 @@ public class MixinGameRenderer {
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setup(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/world/entity/Entity;ZZF)V"))
|
||||
public void renderLevel_setupCamera(Camera instance, BlockGetter blockGetter, Entity entity, boolean bl, boolean bl2, float f, Operation<Void> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
f = ((MinecraftExt)this.minecraft).flashback$getLocalPlayerPartialTick();
|
||||
f = ((MinecraftExt)this.minecraft).flashback$getLocalPlayerPartialTick(f);
|
||||
}
|
||||
original.call(instance, blockGetter, entity, bl, bl2, f);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;rotation()Lorg/joml/Quaternionf;"))
|
||||
public Quaternionf renderLevel(Camera instance, Operation<Quaternionf> original) {
|
||||
return CameraRotation.modifyViewQuaternion(original.call(instance));
|
||||
}
|
||||
|
||||
// @Inject(method = "getProjectionMatrix", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;perspective(FFFF)Lorg/joml/Matrix4f;", shift = At.Shift.BEFORE))
|
||||
// @Inject(method = "getProjectionMatrix", at = @At(value = "RETURN"))
|
||||
// public void getProjectionMatrix(double d, CallbackInfoReturnable<Matrix4f> cir) {
|
||||
// if (ReplayVisuals.overrideZoom) {
|
||||
// cir.getReturnValue().scaleLocal(ReplayVisuals.overrideZoomAmount, ReplayVisuals.overrideZoomAmount, 1.0f);
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Inject(method = "getProjectionMatrix", at = @At(value = "RETURN"), cancellable = true)
|
||||
// public void getProjectionMatrix(double d, CallbackInfoReturnable<Matrix4f> cir) {
|
||||
// if (ReplayVisuals.overrideZoom) {
|
||||
// Window window = Minecraft.getInstance().getWindow();
|
||||
// Matrix4f matrix4f = new Matrix4f().setOrtho(-10.0f, 10.0f, -10.0f, 10.0f, 0.05f, this.getDepthFar());
|
||||
// cir.setReturnValue(matrix4f);
|
||||
//// cir.setReturnValue(new Matrix4f().ortho());
|
||||
// }
|
||||
// }
|
||||
|
||||
@Inject(method = "tryTakeScreenshotIfNeeded", at = @At("HEAD"), cancellable = true)
|
||||
public void tryTakeScreenshotIfNeeded(CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
@@ -89,13 +119,13 @@ public class MixinGameRenderer {
|
||||
cir.setReturnValue(70.0);
|
||||
return;
|
||||
}
|
||||
|
||||
int fov = this.minecraft.options.fov().get().intValue();
|
||||
if (ReplayVisuals.overrideFov) {
|
||||
cir.setReturnValue((double) ReplayVisuals.overrideFovAmount);
|
||||
return;
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.replayVisuals.overrideFov) {
|
||||
cir.setReturnValue((double) editorState.replayVisuals.overrideFovAmount);
|
||||
} else {
|
||||
int fov = this.minecraft.options.fov().get().intValue();
|
||||
cir.setReturnValue((double) fov);
|
||||
}
|
||||
cir.setReturnValue((double) fov);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user