mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 14:38:50 +00:00
Update to 1.21.3
This commit is contained in:
1 parent
bc06f67861
commit
8c02fd7430
56 files changed
+609
-573
No files matched your search
@@ -1,10 +1,13 @@
|
||||
package com.moulberry.flashback.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
|
||||
import com.mojang.blaze3d.framegraph.FramePass;
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
||||
import com.mojang.blaze3d.resource.ResourceHandle;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||
@@ -23,21 +26,18 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.CloudStatus;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.renderer.*;
|
||||
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.core.BlockPos;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -60,6 +60,8 @@ public abstract class MixinLevelRenderer {
|
||||
@Shadow
|
||||
private int ticks;
|
||||
|
||||
@Shadow @Final private LevelTargetBundle targets;
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
public void tick(CallbackInfo ci) {
|
||||
ReplayServer replayServer = Flashback.getReplayServer();
|
||||
@@ -70,7 +72,8 @@ public abstract class MixinLevelRenderer {
|
||||
}
|
||||
|
||||
@Inject(method = "renderLevel", at = @At("HEAD"))
|
||||
public void renderLevel(DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f projection, CallbackInfo ci) {
|
||||
public void renderLevel(GraphicsResourceAllocator graphicsResourceAllocator, DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer,
|
||||
LightTexture lightTexture, Matrix4f matrix4f, Matrix4f projection, CallbackInfo ci) {
|
||||
ReplayUI.lastProjectionMatrix = projection;
|
||||
ReplayUI.lastViewQuaternion = camera.rotation();
|
||||
}
|
||||
@@ -85,110 +88,90 @@ public abstract class MixinLevelRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderSectionLayer(Lnet/minecraft/client/renderer/RenderType;DDDLorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V", ordinal = 2, shift = At.Shift.AFTER), require = 0)
|
||||
public void renderLevel_renderCutoutLayer(DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
|
||||
@Inject(method = "addMainPass", at = @At("HEAD"))
|
||||
public void addMainPass(FrameGraphBuilder frameGraphBuilder, Frustum frustum, Camera camera, Matrix4f matrix4f, Matrix4f matrix4f2, FogParameters fogParameters, boolean bl, boolean bl2, DeltaTracker deltaTracker, ProfilerFiller profilerFiller, CallbackInfo ci) {
|
||||
if (Flashback.isExporting() && Flashback.EXPORT_JOB.getSettings().transparent()) {
|
||||
RenderTarget main = Minecraft.getInstance().mainRenderTarget;
|
||||
FramePass framePass = frameGraphBuilder.addPass("flashback_round_alpha");
|
||||
this.targets.main = framePass.readsAndWrites(this.targets.main);
|
||||
|
||||
RenderSystem.assertOnRenderThread();
|
||||
GlStateManager._disableDepthTest();
|
||||
GlStateManager._depthMask(false);
|
||||
GlStateManager._viewport(0, 0, main.viewWidth, main.viewHeight);
|
||||
GlStateManager._disableBlend();
|
||||
ShaderInstance shaderInstance = Objects.requireNonNull(ShaderManager.blitScreenRoundAlpha, "Blit shader not loaded");
|
||||
shaderInstance.setSampler("DiffuseSampler", main.colorTextureId);
|
||||
shaderInstance.apply();
|
||||
BufferBuilder bufferBuilder = RenderSystem.renderThreadTesselator().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLIT_SCREEN);
|
||||
bufferBuilder.addVertex(0.0f, 0.0f, 0.0f);
|
||||
bufferBuilder.addVertex(1.0f, 0.0f, 0.0f);
|
||||
bufferBuilder.addVertex(1.0f, 1.0f, 0.0f);
|
||||
bufferBuilder.addVertex(0.0f, 1.0f, 0.0f);
|
||||
BufferUploader.draw(bufferBuilder.buildOrThrow());
|
||||
shaderInstance.clear();
|
||||
GlStateManager._enableBlend();
|
||||
GlStateManager._depthMask(true);
|
||||
GlStateManager._enableDepthTest();
|
||||
ResourceHandle<RenderTarget> resourceHandle = this.targets.main;
|
||||
framePass.executes(() -> {
|
||||
RenderTarget main = resourceHandle.get();
|
||||
|
||||
RenderSystem.assertOnRenderThread();
|
||||
GlStateManager._disableDepthTest();
|
||||
GlStateManager._depthMask(false);
|
||||
GlStateManager._viewport(0, 0, main.viewWidth, main.viewHeight);
|
||||
GlStateManager._disableBlend();
|
||||
CompiledShaderProgram shaderInstance = Objects.requireNonNull(
|
||||
RenderSystem.setShader(ShaderManager.blitScreenRoundAlpha), "Blit shader not loaded"
|
||||
);
|
||||
shaderInstance.bindSampler("InSampler", main.colorTextureId);
|
||||
shaderInstance.apply();
|
||||
BufferBuilder bufferBuilder = RenderSystem.renderThreadTesselator().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLIT_SCREEN);
|
||||
bufferBuilder.addVertex(0.0f, 0.0f, 0.0f);
|
||||
bufferBuilder.addVertex(1.0f, 0.0f, 0.0f);
|
||||
bufferBuilder.addVertex(1.0f, 1.0f, 0.0f);
|
||||
bufferBuilder.addVertex(0.0f, 1.0f, 0.0f);
|
||||
BufferUploader.draw(bufferBuilder.buildOrThrow());
|
||||
shaderInstance.clear();
|
||||
GlStateManager._enableBlend();
|
||||
GlStateManager._depthMask(true);
|
||||
GlStateManager._enableDepthTest();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/FogRenderer;levelFogColor()V", shift = At.Shift.AFTER), require = 0)
|
||||
public void renderLevel_levelFogColor(DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/FogRenderer;setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;Lorg/joml/Vector4f;FZF)Lnet/minecraft/client/renderer/FogParameters;"))
|
||||
public FogParameters setupFog(Camera camera, FogRenderer.FogMode fogMode, Vector4f colour, float distance, boolean foggy, float partialTick, Operation<FogParameters> original) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
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);
|
||||
}
|
||||
colour = new Vector4f(fogColour[0], fogColour[1], fogColour[2], 1.0F);
|
||||
}
|
||||
if (!visuals.renderSky) {
|
||||
if (fogMode == FogRenderer.FogMode.FOG_SKY && !visuals.renderSky) {
|
||||
if (Flashback.isExporting() && Flashback.EXPORT_JOB.getSettings().transparent()) {
|
||||
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 0.0F);
|
||||
Vector4f originalColour = colour;
|
||||
colour = new Vector4f(colour);
|
||||
originalColour.set(0, 0, 0, 0);
|
||||
} else {
|
||||
float[] skyColour = visuals.skyColour;
|
||||
RenderSystem.clearColor(skyColour[0], skyColour[1], skyColour[2], 1.0F);
|
||||
colour.set(skyColour[0], skyColour[1], skyColour[2], 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
return original.call(camera, fogMode, colour, distance, foggy, partialTick);
|
||||
}
|
||||
|
||||
@Inject(method = "renderBlockEntities", at = @At("HEAD"), cancellable = true)
|
||||
public void renderBlockEntities(PoseStack poseStack, MultiBufferSource.BufferSource bufferSource, MultiBufferSource.BufferSource bufferSource2, Camera camera, float f, CallbackInfo ci) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && !editorState.replayVisuals.renderBlocks) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;render(Lnet/minecraft/world/level/block/entity/BlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;)V"), require = 0)
|
||||
public boolean renderLevel_renderBlockEntity(BlockEntityRenderDispatcher instance, BlockEntity blockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
return editorState == null || editorState.replayVisuals.renderBlocks;
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderEntity(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;)V"), require = 0)
|
||||
public boolean renderLevel_renderEntity(LevelRenderer instance, Entity entity, double d, double e, double f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource) {
|
||||
@Inject(method = "renderEntity", at = @At("HEAD"), cancellable = true)
|
||||
public void renderEntity(Entity entity, double d, double e, double f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, CallbackInfo ci) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (entity instanceof Player) {
|
||||
return editorState == null || editorState.replayVisuals.renderPlayers;
|
||||
if (editorState != null && !editorState.replayVisuals.renderPlayers) {
|
||||
ci.cancel();
|
||||
}
|
||||
} else {
|
||||
return editorState == null || editorState.replayVisuals.renderEntities;
|
||||
if (editorState != null && !editorState.replayVisuals.renderEntities) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private Biome.Precipitation forcePrecipitation = null;
|
||||
|
||||
@Inject(method = "renderSnowAndRain", at = @At("HEAD"))
|
||||
public void renderSnowAndRain(LightTexture lightTexture, float f, double d, double e, double g, CallbackInfo ci) {
|
||||
this.forcePrecipitation = null;
|
||||
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null) {
|
||||
switch (editorState.replayVisuals.overrideWeatherMode) {
|
||||
case CLEAR, OVERCAST -> forcePrecipitation = Biome.Precipitation.NONE;
|
||||
case RAINING, THUNDERING -> forcePrecipitation = Biome.Precipitation.RAIN;
|
||||
case SNOWING -> forcePrecipitation = Biome.Precipitation.SNOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderSnowAndRain", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;hasPrecipitation()Z"))
|
||||
public boolean renderSnowAndRain_hasPrecipitation(Biome instance, Operation<Boolean> original) {
|
||||
if (this.forcePrecipitation != null) {
|
||||
return this.forcePrecipitation != Biome.Precipitation.NONE;
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderSnowAndRain", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;getPrecipitationAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/biome/Biome$Precipitation;"))
|
||||
public Biome.Precipitation renderSnowAndRain_getPrecipitationAt(Biome instance, BlockPos blockPos, Operation<Biome.Precipitation> original) {
|
||||
if (this.forcePrecipitation != null) {
|
||||
return this.forcePrecipitation;
|
||||
} else {
|
||||
return original.call(instance, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Options;getCloudsType()Lnet/minecraft/client/CloudStatus;"), require = 0)
|
||||
public CloudStatus renderLevel_getCloudsType(Options instance, Operation<CloudStatus> original) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
@@ -199,16 +182,20 @@ public abstract class MixinLevelRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;F)V"), require = 0)
|
||||
public boolean renderLevel_renderParticles(ParticleEngine instance, LightTexture lightTexture, Camera camera, float f) {
|
||||
@Inject(method = "addParticlesPass", at = @At("HEAD"), cancellable = true)
|
||||
public void addParticlesPass(FrameGraphBuilder frameGraphBuilder, Camera camera, LightTexture lightTexture, float f, FogParameters fogParameters, CallbackInfo ci) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
return editorState == null || editorState.replayVisuals.renderParticles;
|
||||
if (editorState != null && !editorState.replayVisuals.renderParticles) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderSky(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;FLnet/minecraft/client/Camera;ZLjava/lang/Runnable;)V"), require = 0)
|
||||
public boolean renderLevel_renderSky(LevelRenderer instance, Matrix4f matrix4f, Matrix4f matrix4f2, float f, Camera camera, boolean bl, Runnable runnable) {
|
||||
@Inject(method = "addSkyPass", at = @At("HEAD"), cancellable = true)
|
||||
public void addSkyPass(FrameGraphBuilder frameGraphBuilder, Camera camera, float f, FogParameters fogParameters, CallbackInfo ci) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
return editorState == null || editorState.replayVisuals.renderSky;
|
||||
if (editorState != null && !editorState.replayVisuals.renderSky) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;setupRender(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/culling/Frustum;ZZ)V"), require = 0)
|
||||
|
||||
@@ -100,9 +100,6 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
@Shadow
|
||||
public abstract void setScreen(@Nullable Screen screen);
|
||||
|
||||
@Shadow
|
||||
private ProfilerFiller profiler;
|
||||
|
||||
@Shadow
|
||||
private @Nullable Overlay overlay;
|
||||
|
||||
@@ -130,18 +127,10 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
@Nullable
|
||||
public LocalPlayer player;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public ParticleEngine particleEngine;
|
||||
|
||||
@Shadow
|
||||
@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();
|
||||
@@ -337,7 +326,6 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
}
|
||||
LevelLoadingScreen levelLoadingScreen = new LevelLoadingScreen(this.progressListener.get());
|
||||
this.setScreen(levelLoadingScreen);
|
||||
this.profiler.push("waitForServer");
|
||||
while (!this.singleplayerServer.isReady() || this.overlay != null) {
|
||||
levelLoadingScreen.tick();
|
||||
this.runTick(false);
|
||||
@@ -348,7 +336,6 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
}
|
||||
this.handleDelayedCrash();
|
||||
}
|
||||
this.profiler.pop();
|
||||
Duration duration = Duration.between(instant, Instant.now());
|
||||
SocketAddress socketAddress = this.singleplayerServer.getConnection().startMemoryChannel();
|
||||
Connection connection = Connection.connectToLocalServer(socketAddress);
|
||||
|
||||
@@ -8,15 +8,12 @@ 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.VertexFormat;
|
||||
import com.moulberry.flashback.WindowSizeTracker;
|
||||
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;
|
||||
import net.minecraft.client.renderer.CompiledShaderProgram;
|
||||
import net.minecraft.client.renderer.CoreShaders;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -31,8 +28,8 @@ public abstract class MixinRenderTarget {
|
||||
@Shadow
|
||||
public int colorTextureId;
|
||||
|
||||
@Inject(method = "blitToScreen(IIZ)V", at = @At("HEAD"), cancellable = true)
|
||||
public void blitToScreenSodium(int width, int height, boolean noBlend, CallbackInfo ci) {
|
||||
@Inject(method = "blitToScreen(II)V", at = @At("HEAD"), cancellable = true)
|
||||
public void blitToScreen(int width, int height, CallbackInfo ci) {
|
||||
if ((Object)this == Minecraft.getInstance().getMainRenderTarget() && ReplayUI.isActive()) {
|
||||
var window = Minecraft.getInstance().getWindow();
|
||||
float frameLeft = (float) ReplayUI.frameX / ReplayUI.viewportSizeX;
|
||||
@@ -49,12 +46,11 @@ public abstract class MixinRenderTarget {
|
||||
GlStateManager._depthMask(false);
|
||||
GlStateManager._viewport((int)(realWidth * frameLeft), (int)(realHeight * (1 - (frameTop+frameHeight))),
|
||||
Math.max(1, (int)(realWidth * frameWidth)), Math.max(1, (int)(realHeight * frameHeight)));
|
||||
if (noBlend) {
|
||||
GlStateManager._disableBlend();
|
||||
}
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
ShaderInstance shaderInstance = Objects.requireNonNull(minecraft.gameRenderer.blitShader, "Blit shader not loaded");
|
||||
shaderInstance.setSampler("DiffuseSampler", this.colorTextureId);
|
||||
GlStateManager._disableBlend();
|
||||
CompiledShaderProgram shaderInstance = Objects.requireNonNull(
|
||||
RenderSystem.setShader(CoreShaders.BLIT_SCREEN), "Blit shader not loaded"
|
||||
);
|
||||
shaderInstance.bindSampler("InSampler", this.colorTextureId);
|
||||
shaderInstance.apply();
|
||||
BufferBuilder bufferBuilder = RenderSystem.renderThreadTesselator().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLIT_SCREEN);
|
||||
bufferBuilder.addVertex(0.0f, 0.0f, 0.0f);
|
||||
|
||||
+9
-12
@@ -1,8 +1,8 @@
|
||||
package com.moulberry.flashback.mixin.compat.fabric;
|
||||
|
||||
import com.bawnorton.mixinsquared.TargetHandler;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.fabricmc.fabric.impl.biome.modification.BiomeModificationImpl;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -15,15 +15,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* these server-only registries is bound to error
|
||||
*/
|
||||
|
||||
@Mixin(value = MinecraftServer.class, priority = 1500)
|
||||
public class MixinFabricMinecraftServer {
|
||||
@TargetHandler(
|
||||
mixin = "net.fabricmc.fabric.mixin.biome.modification.MinecraftServerMixin",
|
||||
name = "finalizeWorldGen"
|
||||
)
|
||||
@Inject(method = "@MixinSquared:Handler", at = @At("HEAD"), cancellable = true, require = 0)
|
||||
private void preventWorldGenChanges(CallbackInfo ci) {
|
||||
if ((Object) this instanceof ReplayServer) {
|
||||
@Mixin(BiomeModificationImpl.class)
|
||||
public class MixinFabricBiomeModificationImpl {
|
||||
|
||||
@Inject(method = "finalizeWorldGen", at = @At("HEAD"), cancellable = true)
|
||||
public void finalizeWorldGen(RegistryAccess impl, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.client.renderer.entity.ArmorStandRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.ArmorStandRenderState;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -18,8 +19,8 @@ public class MixinArmorStandRenderer {
|
||||
* If the game time isn't updated, it'll just keep on playing it (even if it wasn't hit)
|
||||
*/
|
||||
|
||||
@Inject(method = "setupRotations(Lnet/minecraft/world/entity/decoration/ArmorStand;Lcom/mojang/blaze3d/vertex/PoseStack;FFFF)V", at = @At("HEAD"), cancellable = true)
|
||||
public void setupRotations(ArmorStand armorStand, PoseStack poseStack, float f, float g, float h, float i, CallbackInfo ci) {
|
||||
@Inject(method = "setupRotations(Lnet/minecraft/client/renderer/entity/state/ArmorStandRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;FF)V", at = @At("HEAD"), cancellable = true)
|
||||
public void setupRotations(ArmorStandRenderState armorStandRenderState, PoseStack poseStack, float f, float g, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(180.0F - g));
|
||||
ci.cancel();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.world.entity.vehicle.AbstractBoat;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -8,7 +9,7 @@ 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)
|
||||
@Mixin(AbstractBoat.class)
|
||||
public class MixinBoat {
|
||||
|
||||
@Shadow
|
||||
|
||||
@@ -44,11 +44,7 @@ public abstract class MixinEntity {
|
||||
|
||||
int localId = replayServer.getLocalPlayerId();
|
||||
if (this.level.getEntity(localId) instanceof Player localPlayer) {
|
||||
if ((Object)this == localPlayer) {
|
||||
cir.setReturnValue(false);
|
||||
} else {
|
||||
cir.setReturnValue(this.isInvisibleTo(localPlayer));
|
||||
}
|
||||
cir.setReturnValue(this.isInvisibleTo(localPlayer));
|
||||
} else {
|
||||
cir.setReturnValue(this.isInvisible());
|
||||
}
|
||||
|
||||
@@ -24,13 +24,10 @@ import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.PostChain;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Quaternionf;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -72,7 +69,7 @@ public abstract class MixinGameRenderer {
|
||||
AccurateEntityPositionHandler.apply(Minecraft.getInstance().level, deltaTracker);
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(IZ)V", remap = false, ordinal = 0), cancellable = true)
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(I)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();
|
||||
@@ -128,18 +125,18 @@ public abstract class MixinGameRenderer {
|
||||
}
|
||||
|
||||
@Inject(method = "getFov", at = @At("HEAD"), cancellable = true)
|
||||
public void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Double> cir) {
|
||||
public void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Float> cir) {
|
||||
if (Flashback.isInReplay()) {
|
||||
if (!bl) {
|
||||
cir.setReturnValue(70.0);
|
||||
cir.setReturnValue(70.0f);
|
||||
return;
|
||||
}
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.replayVisuals.overrideFov) {
|
||||
cir.setReturnValue((double) editorState.replayVisuals.overrideFovAmount);
|
||||
cir.setReturnValue(editorState.replayVisuals.overrideFovAmount);
|
||||
} else {
|
||||
int fov = this.minecraft.options.fov().get().intValue();
|
||||
cir.setReturnValue((double) fov);
|
||||
cir.setReturnValue((float) fov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
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.Minecraft;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
@@ -112,32 +114,7 @@ public abstract class MixinItemInHandRenderer implements ItemInHandRendererExt {
|
||||
bufferSource.endBatch();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
// todo: render player arm
|
||||
|
||||
@Unique
|
||||
private UUID lastSpectatingPlayer = null;
|
||||
|
||||
@@ -43,6 +43,8 @@ public abstract class MixinLevelChunk extends ChunkAccess implements LevelChunkE
|
||||
@Shadow
|
||||
public abstract @Nullable BlockEntity getBlockEntity(BlockPos blockPos, LevelChunk.EntityCreationType entityCreationType);
|
||||
|
||||
@Shadow public abstract void markUnsaved();
|
||||
|
||||
public MixinLevelChunk(ChunkPos chunkPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry<Biome> registry, long l, @Nullable LevelChunkSection[] levelChunkSections, @Nullable BlendingData blendingData) {
|
||||
super(chunkPos, upgradeData, levelHeightAccessor, registry, l, levelChunkSections, blendingData);
|
||||
}
|
||||
@@ -98,7 +100,7 @@ public abstract class MixinLevelChunk extends ChunkAccess implements LevelChunkE
|
||||
}
|
||||
|
||||
// Update light
|
||||
if (LightEngine.hasDifferentLightProperties(this, blockPos, oldBlockState, blockState)) {
|
||||
if (LightEngine.hasDifferentLightProperties(oldBlockState, blockState)) {
|
||||
if (this.skyLightSources != null) {
|
||||
this.skyLightSources.update(this, localX, y, localZ);
|
||||
}
|
||||
@@ -126,7 +128,7 @@ public abstract class MixinLevelChunk extends ChunkAccess implements LevelChunkE
|
||||
}
|
||||
}
|
||||
|
||||
this.unsaved = true;
|
||||
this.markUnsaved();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class MixinLocalPlayer {
|
||||
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());
|
||||
Optional<Holder.Reference<SoundEvent>> builtinSoundEvent = BuiltInRegistries.SOUND_EVENT.get(soundEvent.location());
|
||||
Holder<SoundEvent> holder;
|
||||
if (builtinSoundEvent.isEmpty()) {
|
||||
holder = Holder.direct(soundEvent);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MixinMultiPlayerGameMode {
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<Holder.Reference<SoundEvent>> builtinSoundEvent = BuiltInRegistries.SOUND_EVENT.getHolder(soundInstance.getLocation());
|
||||
Optional<Holder.Reference<SoundEvent>> builtinSoundEvent = BuiltInRegistries.SOUND_EVENT.get(soundInstance.getLocation());
|
||||
Holder<SoundEvent> holder;
|
||||
if (builtinSoundEvent.isEmpty()) {
|
||||
holder = Holder.direct(SoundEvent.createVariableRangeEvent(soundInstance.getLocation()));
|
||||
|
||||
-12
@@ -1,11 +1,8 @@
|
||||
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;
|
||||
@@ -46,13 +43,4 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -125,7 +126,7 @@ public class MixinTitleScreen extends Screen {
|
||||
}
|
||||
|
||||
@Inject(method = "createNormalMenuOptions", at = @At("HEAD"))
|
||||
public void createNormalMenuOptions(int y, int buttonHeight, CallbackInfo ci) {
|
||||
public void createNormalMenuOptions(int i, int j, CallbackInfoReturnable<Integer> cir) {
|
||||
this.normalMenuWidgets.clear();
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -1,11 +1,8 @@
|
||||
package com.moulberry.flashback.mixin;
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.ProfileResult;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.resources.PlayerSkin;
|
||||
@@ -32,7 +29,7 @@ public abstract class MixinAbstractClientPlayer extends Player {
|
||||
public void getSkin(CallbackInfoReturnable<PlayerSkin> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null) {
|
||||
GameProfile skinOverride = editorState.skinOverride.get(this.uuid);
|
||||
GameProfile skinOverride = editorState.skinOverride.get(this.getUUID());
|
||||
if (skinOverride != null) {
|
||||
if (skinOverridePlayerInfo == null || skinOverridePlayerInfo.getProfile() != skinOverride) {
|
||||
skinOverridePlayerInfo = new PlayerInfo(skinOverride, false);
|
||||
+10
-8
@@ -10,6 +10,8 @@ import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -25,8 +27,8 @@ public abstract class MixinEntityRenderDispatcher {
|
||||
private static void renderHitbox(PoseStack poseStack, VertexConsumer vertexConsumer, Entity entity, float f, float g, float h, float i) {
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
|
||||
public void renderBefore(Entity entity, double d, double e, double f, float g, float h, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
|
||||
@Inject(method = "render(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/EntityRenderer;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void renderBefore(Entity entity, double d, double e, double f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, EntityRenderer entityRenderer, CallbackInfo ci) {
|
||||
if (Flashback.isExporting()) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.hideDuringExport.contains(entity.getUUID())) {
|
||||
@@ -36,23 +38,23 @@ public abstract class MixinEntityRenderDispatcher {
|
||||
}
|
||||
|
||||
// Add a yellow outline to selected entity
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;popPose()V", shift = At.Shift.BEFORE), require = 0)
|
||||
public void renderAfter(Entity entity, double d, double e, double f, float g, float h, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
|
||||
@Inject(method = "render(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/EntityRenderer;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;popPose()V", shift = At.Shift.BEFORE), require = 0)
|
||||
public void renderAfter(Entity entity, double d, double e, double f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, EntityRenderer entityRenderer, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
if (ReplayUI.isEntitySelected(entity.getUUID())) {
|
||||
renderHitbox(poseStack, multiBufferSource.getBuffer(RenderType.lines()), entity, h, 1.0f, 1.0f, 0.0f);
|
||||
renderHitbox(poseStack, multiBufferSource.getBuffer(RenderType.lines()), entity, g, 1.0f, 1.0f, 0.0f);
|
||||
} else if (!Flashback.isExporting()) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && entity.getUUID().equals(editorState.audioSourceEntity)) {
|
||||
renderHitbox(poseStack, multiBufferSource.getBuffer(RenderType.lines()), entity, h, 0.0f, 1.0f, 0.0f);
|
||||
renderHitbox(poseStack, multiBufferSource.getBuffer(RenderType.lines()), entity, g, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent rendering shadows when blocks are turned off
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;renderShadow(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/entity/Entity;FFLnet/minecraft/world/level/LevelReader;F)V"), require = 0)
|
||||
public boolean renderShadow(PoseStack poseStack, MultiBufferSource multiBufferSource, Entity entity, float f, float g, LevelReader levelReader, float h) {
|
||||
@WrapWithCondition(method = "render(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/renderer/entity/EntityRenderer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;renderShadow(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/renderer/entity/state/EntityRenderState;FFLnet/minecraft/world/level/LevelReader;F)V"), require = 0)
|
||||
public boolean renderShadow(PoseStack poseStack, MultiBufferSource multiBufferSource, EntityRenderState entityRenderState, float f, float g, LevelReader levelReader, float h) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
return editorState == null || editorState.replayVisuals.renderBlocks;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,38 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
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 net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public class MixinEntityRenderer {
|
||||
|
||||
@Inject(method = "renderNameTag", at = @At("HEAD"), cancellable = true, require = 0)
|
||||
public void renderNameTag(Entity entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, float f, CallbackInfo ci) {
|
||||
@WrapOperation(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isInvisible()Z"))
|
||||
public boolean isInvisible(Entity instance, Operation<Boolean> original) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.hideDuringExport.contains(instance.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@Inject(method = "shouldShowName", at = @At("HEAD"), cancellable = true)
|
||||
public void shouldShowName(Entity entity, double d, CallbackInfoReturnable<Boolean> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null) {
|
||||
if (!editorState.replayVisuals.renderNametags) {
|
||||
ci.cancel();
|
||||
cir.setReturnValue(false);
|
||||
} else if (editorState.hideNametags.contains(entity.getUUID())) {
|
||||
ci.cancel();
|
||||
cir.setReturnValue(false);
|
||||
} else if (editorState.hideDuringExport.contains(entity.getUUID())) {
|
||||
ci.cancel();
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,23 +5,28 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.FogParameters;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import org.joml.Vector4f;
|
||||
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;
|
||||
|
||||
@Mixin(FogRenderer.class)
|
||||
public class MixinFogRenderer {
|
||||
|
||||
@Inject(method = "setupFog", at = @At("HEAD"), cancellable = true, require = 0)
|
||||
private static void setupFog(Camera camera, FogRenderer.FogMode fogMode, float f, boolean bl, float g, CallbackInfo ci) {
|
||||
@Inject(method = "setupFog", at = @At("RETURN"), cancellable = true, require = 0)
|
||||
private static void setupFog(Camera camera, FogRenderer.FogMode fogMode, Vector4f vector4f, float f, boolean bl, float g, CallbackInfoReturnable<FogParameters> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.replayVisuals.overrideFog) {
|
||||
RenderSystem.setShaderFogStart(editorState.replayVisuals.overrideFogStart);
|
||||
RenderSystem.setShaderFogEnd(editorState.replayVisuals.overrideFogEnd);
|
||||
RenderSystem.setShaderFogShape(FogShape.SPHERE);
|
||||
ci.cancel();
|
||||
FogParameters returnParameters = cir.getReturnValue();
|
||||
if (returnParameters != null) {
|
||||
cir.setReturnValue(new FogParameters(editorState.replayVisuals.overrideFogStart,
|
||||
editorState.replayVisuals.overrideFogEnd, FogShape.SPHERE, returnParameters.red(),
|
||||
returnParameters.green(), returnParameters.blue(), returnParameters.alpha()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
|
||||
import com.mojang.blaze3d.framegraph.FramePass;
|
||||
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.visuals.WorldRenderHook;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.RenderBuffers;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -24,37 +25,41 @@ public class MixinLevelRenderer {
|
||||
@Final
|
||||
private RenderBuffers renderBuffers;
|
||||
|
||||
@Shadow @Final private LevelTargetBundle targets;
|
||||
|
||||
@Inject(method="renderLevel", at=@At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/Options;getCloudsType()Lnet/minecraft/client/CloudStatus;",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
public void renderLevelPost(net.minecraft.client.DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture,
|
||||
Matrix4f matrix4f, Matrix4f projection, CallbackInfo ci) {
|
||||
public void renderLevelPost(GraphicsResourceAllocator graphicsResourceAllocator, net.minecraft.client.DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture,
|
||||
Matrix4f matrix4f, Matrix4f projection, CallbackInfo ci, @Local FrameGraphBuilder frameGraphBuilder) {
|
||||
|
||||
if (!Flashback.isInReplay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.renderBuffers.bufferSource().endBatch();
|
||||
FramePass framePass = frameGraphBuilder.addPass("flashback_mod_pass");
|
||||
this.targets.main = framePass.readsAndWrites(this.targets.main);
|
||||
framePass.executes(() -> {
|
||||
this.renderBuffers.bufferSource().endBatch();
|
||||
|
||||
PoseStack poseStack = new PoseStack();
|
||||
poseStack.mulPose(matrix4f);
|
||||
PoseStack poseStack = new PoseStack();
|
||||
poseStack.mulPose(matrix4f);
|
||||
|
||||
// Set model view stack to identity
|
||||
var modelViewStack = RenderSystem.getModelViewStack();
|
||||
modelViewStack.pushMatrix();
|
||||
modelViewStack.identity();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
// Set model view stack to identity
|
||||
var modelViewStack = RenderSystem.getModelViewStack();
|
||||
modelViewStack.pushMatrix();
|
||||
modelViewStack.identity();
|
||||
|
||||
float tickDelta = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||
WorldRenderHook.renderHook(poseStack, tickDelta, renderBlockOutline, camera, gameRenderer, lightTexture, projection);
|
||||
float tickDelta = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||
WorldRenderHook.renderHook(poseStack, tickDelta, renderBlockOutline, camera, gameRenderer, lightTexture, projection);
|
||||
|
||||
this.renderBuffers.bufferSource().endBatch();
|
||||
this.renderBuffers.bufferSource().endBatch();
|
||||
|
||||
// Pop model view stack
|
||||
modelViewStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
// Pop model view stack
|
||||
modelViewStack.popMatrix();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
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;
|
||||
|
||||
@Mixin(LivingEntityRenderer.class)
|
||||
public class MixinLivingEntityRenderer {
|
||||
|
||||
@Inject(method = "isBodyVisible", at = @At("HEAD"), cancellable = true, require = 0)
|
||||
public void isBodyVisible(LivingEntity livingEntity, CallbackInfoReturnable<Boolean> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.hideDuringExport.contains(livingEntity.getUUID())) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.PlayerModelPart;
|
||||
import net.minecraft.world.level.Level;
|
||||
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;
|
||||
|
||||
@Mixin(Player.class)
|
||||
public abstract class MixinPlayer extends LivingEntity {
|
||||
|
||||
protected MixinPlayer(EntityType<? extends LivingEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
@Inject(method = "isModelPartShown", at = @At("HEAD"), cancellable = true)
|
||||
public void isModelPartShown(PlayerModelPart playerModelPart, CallbackInfoReturnable<Boolean> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null) {
|
||||
GameProfile skinOverride = editorState.skinOverride.get(this.uuid);
|
||||
if (skinOverride != null) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import net.minecraft.client.renderer.WeatherEffectRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
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;
|
||||
|
||||
@Mixin(WeatherEffectRenderer.class)
|
||||
public class MixinWeatherEffectRenderer {
|
||||
|
||||
@Inject(method = "getPrecipitationAt", at = @At("HEAD"), cancellable = true)
|
||||
public void getPrecipitationAt(Level level, BlockPos blockPos, CallbackInfoReturnable<Biome.Precipitation> cir) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null) {
|
||||
switch (editorState.replayVisuals.overrideWeatherMode) {
|
||||
case CLEAR, OVERCAST -> cir.setReturnValue(Biome.Precipitation.NONE);
|
||||
case RAINING, THUNDERING -> cir.setReturnValue(Biome.Precipitation.RAIN);
|
||||
case SNOWING -> cir.setReturnValue(Biome.Precipitation.SNOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user