mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 06:28:48 +00:00
0.3.1
This commit is contained in:
1 parent
60f19e7662
commit
fcf1b4168f
26 files changed
+489
-65
No files matched your search
+4
-2
@@ -3,14 +3,16 @@ package com.moulberry.flashback.mixin.compat.bobby;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import de.johni0702.minecraft.bobby.FakeChunkManager;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@IfModLoaded("bobby")
|
||||
@Mixin(FakeChunkManager.class)
|
||||
@Mixin(value = FakeChunkManager.class, remap = false)
|
||||
public interface FakeChunkManagerAccessor {
|
||||
|
||||
@Invoker(value = "getCurrentWorldOrServerName", remap = false)
|
||||
@Invoker(value = "getCurrentWorldOrServerName")
|
||||
@Contract
|
||||
static String getCurrentWorldOrServerName(ClientPacketListener clientPacketListener) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.moulberry.flashback.mixin.compat.bobby;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import de.johni0702.minecraft.bobby.Bobby;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@IfModLoaded("bobby")
|
||||
@Mixin(value = Bobby.class, remap = false)
|
||||
public class MixinBobby {
|
||||
|
||||
@WrapOperation(method = "isEnabled", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSingleplayerServer()Lnet/minecraft/client/server/IntegratedServer;"))
|
||||
public IntegratedServer isEnabled_getSingleplayerServer(Minecraft instance, Operation<IntegratedServer> original) {
|
||||
IntegratedServer server = original.call(instance);
|
||||
if (server instanceof ReplayServer) {
|
||||
return null; // Turn bobby on when viewing replay, even if disabled in singleplayer
|
||||
}
|
||||
return server;
|
||||
}
|
||||
|
||||
}
|
||||
+5
-2
@@ -4,9 +4,11 @@ import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import com.moulberry.flashback.record.FlashbackMeta;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import de.johni0702.minecraft.bobby.ChunkSerializer;
|
||||
import de.johni0702.minecraft.bobby.FakeChunkManager;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -15,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@IfModLoaded("bobby")
|
||||
@Mixin(FakeChunkManager.class)
|
||||
@Mixin(value = FakeChunkManager.class, remap = false)
|
||||
public class MixinBobbyFakeChunkManager {
|
||||
|
||||
@Inject(method = "getCurrentWorldOrServerName", at = @At("HEAD"), cancellable = true)
|
||||
@@ -35,7 +37,8 @@ public class MixinBobbyFakeChunkManager {
|
||||
@Inject(method = "save", at = @At("HEAD"), cancellable = true)
|
||||
public void save(LevelChunk chunk, CallbackInfoReturnable<Supplier<LevelChunk>> cir) {
|
||||
if (Flashback.isInReplay()) {
|
||||
cir.setReturnValue(() -> chunk);
|
||||
Pair<LevelChunk, Supplier<LevelChunk>> copy = ChunkSerializer.shallowCopy(chunk);
|
||||
cir.setReturnValue(copy.getRight());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.moulberry.flashback.mixin.compat.iris;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.mixinconstraints.annotations.IfModLoaded;
|
||||
import net.irisshaders.iris.uniforms.SystemTimeUniforms;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@IfModLoaded("iris")
|
||||
@Mixin(value = SystemTimeUniforms.Timer.class, remap = false)
|
||||
public class MixinIrisSystemTimeUniforms {
|
||||
|
||||
@Inject(method = "getFrameTimeCounter", at = @At("HEAD"), cancellable = true)
|
||||
public void getFrameTimeCounter(CallbackInfoReturnable<Float> cir) {
|
||||
if (Flashback.isExporting()) {
|
||||
double currentTick = Flashback.EXPORT_JOB.getCurrentTickDouble();
|
||||
cir.setReturnValue((float)(currentTick / 20));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getLastFrameTime", at = @At("HEAD"), cancellable = true)
|
||||
public void getLastFrameTime(CallbackInfoReturnable<Float> cir) {
|
||||
if (Flashback.isExporting()) {
|
||||
cir.setReturnValue((float)(1 / Flashback.EXPORT_JOB.getSettings().framerate()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,30 +69,6 @@ public abstract class MixinGameRenderer {
|
||||
@Shadow
|
||||
private boolean effectActive;
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
|
||||
public void render(DeltaTracker deltaTracker, boolean bl, CallbackInfo ci) {
|
||||
if (Flashback.isExporting()) {
|
||||
int i = (int)(this.minecraft.mouseHandler.xpos() * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth());
|
||||
int j = (int)(this.minecraft.mouseHandler.ypos() * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight());
|
||||
RenderSystem.viewport(0, 0, this.minecraft.getWindow().getWidth(), this.minecraft.getWindow().getHeight());
|
||||
boolean bl2 = this.minecraft.isGameLoadFinished();
|
||||
if (bl2 && bl && this.minecraft.level != null) {
|
||||
this.minecraft.getProfiler().push("level");
|
||||
this.renderLevel(deltaTracker);
|
||||
this.minecraft.levelRenderer.doEntityOutline();
|
||||
if (this.postEffect != null && this.effectActive) {
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.resetTextureMatrix();
|
||||
this.postEffect.process(deltaTracker.getGameTimeDeltaTicks());
|
||||
}
|
||||
this.minecraft.getMainRenderTarget().bindWrite(true);
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderItemInHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;getPlayerMode()Lnet/minecraft/world/level/GameType;"))
|
||||
public GameType getPlayerMode(MultiPlayerGameMode instance, Operation<GameType> original) {
|
||||
if (Flashback.getSpectatingPlayer() != null) {
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.moulberry.flashback.mixin.replay_server;
|
||||
|
||||
import com.moulberry.flashback.ext.ServerLevelExt;
|
||||
import com.moulberry.flashback.playback.ReplayPlayer;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerLevel.class)
|
||||
public abstract class MixinServerLevel implements ServerLevelExt {
|
||||
@@ -38,4 +44,19 @@ public abstract class MixinServerLevel implements ServerLevelExt {
|
||||
this.validChunks.add(pos);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean canSpawnEntities = true;
|
||||
|
||||
@Override
|
||||
public void flashback$setCanSpawnEntities(boolean canSpawnEntities) {
|
||||
this.canSpawnEntities = canSpawnEntities;
|
||||
}
|
||||
|
||||
@Inject(method = "addFreshEntity", at = @At("HEAD"), cancellable = true)
|
||||
public void addFreshEntity(Entity entity, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!(entity instanceof Player) && !this.canSpawnEntities) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -1,8 +1,11 @@
|
||||
package com.moulberry.flashback.mixin.replay_server;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.protocol.login.ClientboundGameProfilePacket;
|
||||
import net.minecraft.network.protocol.login.ServerboundHelloPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
||||
@@ -43,4 +46,13 @@ public abstract class MixinServerLoginPacketListenerImpl {
|
||||
}
|
||||
}
|
||||
|
||||
// Disable strict error handling
|
||||
@WrapOperation(method = "finishLoginAndWaitForClient", at = @At(value = "NEW", target = "net/minecraft/network/protocol/login/ClientboundGameProfilePacket"))
|
||||
public ClientboundGameProfilePacket wrapCreateClientboundGameProfilePacket(GameProfile gameProfile, boolean strict, Operation<ClientboundGameProfilePacket> original) {
|
||||
if (this.server instanceof ReplayServer) {
|
||||
strict = false;
|
||||
}
|
||||
return original.call(gameProfile, strict);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -50,6 +51,15 @@ public class MixinGui {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderVignette", at = @At("HEAD"), cancellable = true)
|
||||
public void renderVignette(GuiGraphics guiGraphics, Entity entity, CallbackInfo ci) {
|
||||
// The vignette ruins the transparency when trying to export with alpha
|
||||
// The vignette is also probably unwanted in general when trying to record, so lets just get rid of it
|
||||
if (Flashback.isInReplay()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "canRenderCrosshairForSpectator", at = @At("HEAD"), cancellable = true)
|
||||
public void canRenderCrosshairForSpectator(HitResult hitResult, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Flashback.isExporting()) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(RenderStateShard.class)
|
||||
public class MixinRenderStateShard {
|
||||
|
||||
@WrapOperation(method = "setupGlintTexturing", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;getMillis()J"))
|
||||
private static long setupGlintTexturing(Operation<Long> original) {
|
||||
if (Flashback.isExporting()) {
|
||||
double currentTick = Flashback.EXPORT_JOB.getCurrentTickDouble();
|
||||
return (long)(currentTick / 20 * 1000);
|
||||
}
|
||||
return original.call();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user