This commit is contained in:
Moulberry committed 2024-09-07 02:20:58 +08:00
1 parent d589647c36
commit 7f1d199704
20 files changed
+461 -94

No files matched your search

@@ -18,6 +18,7 @@ import com.moulberry.flashback.state.EditorState;
import com.moulberry.flashback.state.EditorStateManager;
import com.moulberry.flashback.editor.ui.ReplayUI;
import com.moulberry.flashback.exporting.PerfectFrames;
import com.moulberry.flashback.visuals.ReplayVisuals;
import com.moulberry.flashback.visuals.ShaderManager;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.client.Camera;
@@ -111,12 +112,26 @@ public abstract class MixinLevelRenderer {
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/FogRenderer;levelFogColor()V", shift = At.Shift.AFTER))
public void renderLevel_levelFogColor(DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
EditorState editorState = EditorStateManager.getCurrent();
if (editorState != null && !editorState.replayVisuals.renderSky) {
if (Flashback.isExporting() && Flashback.EXPORT_JOB.getSettings().transparent()) {
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 0.0F);
} else {
float[] skyColour = editorState.replayVisuals.skyColour;
RenderSystem.clearColor(skyColour[0], skyColour[1], skyColour[2], 0.0F);
if (editorState != null) {
ReplayVisuals visuals = editorState.replayVisuals;
if (visuals.overrideFogColour) {
float[] fogColour = visuals.fogColour;
FogRenderer.fogRed = fogColour[0];
FogRenderer.fogGreen = fogColour[1];
FogRenderer.fogBlue = fogColour[2];
RenderSystem.setShaderFogColor(fogColour[0], fogColour[1], fogColour[2]);
if (visuals.renderSky) {
RenderSystem.clearColor(fogColour[0], fogColour[1], fogColour[2], 1.0F);
}
}
if (!visuals.renderSky) {
if (Flashback.isExporting() && Flashback.EXPORT_JOB.getSettings().transparent()) {
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 0.0F);
} else {
float[] skyColour = visuals.skyColour;
RenderSystem.clearColor(skyColour[0], skyColour[1], skyColour[2], 1.0F);
}
}
}
@@ -1,17 +1,20 @@
package com.moulberry.flashback.mixin.record;
import com.moulberry.flashback.Flashback;
import com.moulberry.flashback.record.Recorder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.network.ConnectionProtocol;
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket;
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -19,6 +22,7 @@ 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(ClientLevel.class)
public class MixinClientLevel {
@@ -27,6 +31,14 @@ public class MixinClientLevel {
@Final
private Minecraft minecraft;
@Inject(method = "setBlock", at = @At("HEAD"))
public void setBlock(BlockPos blockPos, BlockState blockState, int i, int j, CallbackInfoReturnable<Boolean> cir) {
Recorder recorder = Flashback.RECORDER;
if (recorder != null && !recorder.isPaused()) {
recorder.writePacketAsync(new ClientboundBlockUpdatePacket(blockPos.immutable(), blockState), ConnectionProtocol.PLAY);
}
}
@Inject(method = "levelEvent", at = @At("HEAD"))
public void levelEvent(Player player, int type, BlockPos blockPos, int data, CallbackInfo ci) {
if (Flashback.RECORDER != null && !Flashback.RECORDER.isPaused()) {
@@ -1,21 +1,22 @@
package com.moulberry.flashback.mixin.replay_server;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
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.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
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)
@Mixin(value = ServerLevel.class, priority = 900)
public abstract class MixinServerLevel implements ServerLevelExt {
@Unique
@@ -59,4 +60,16 @@ public abstract class MixinServerLevel implements ServerLevelExt {
}
}
// Fix for worldgen mods injecting on getGeneratorState to add custom worldgen properties
// Lets just nuke the whole line
@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;getGeneratorState()Lnet/minecraft/world/level/chunk/ChunkGeneratorStructureState;"))
public ChunkGeneratorStructureState getGeneratorState(ServerChunkCache instance, Operation<ChunkGeneratorStructureState> original) {
return null;
}
@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/ChunkGeneratorStructureState;ensureStructuresGenerated()V"))
public void ensureStructuresGenerated(ChunkGeneratorStructureState instance, Operation<Void> original) {
}
}