mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 14:38:50 +00:00
Stuff
This commit is contained in:
1 parent
9c4a30d224
commit
666398e480
174 files changed
+8694
-2942
No files matched your search
@@ -0,0 +1,125 @@
|
||||
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.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.moulberry.flashback.ReplayVisuals;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import com.moulberry.flashback.exporting.PerfectFrames;
|
||||
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.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.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = LevelRenderer.class, priority = 1100)
|
||||
public abstract class MixinLevelRenderer {
|
||||
|
||||
@Shadow @Final public ObjectArrayList<SectionRenderDispatcher.RenderSection> visibleSections;
|
||||
|
||||
@Shadow private @Nullable SectionRenderDispatcher sectionRenderDispatcher;
|
||||
|
||||
@Shadow @Final public SectionOcclusionGraph sectionOcclusionGraph;
|
||||
|
||||
@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) {
|
||||
ReplayUI.lastProjectionMatrix = projection;
|
||||
ReplayUI.lastViewQuaternion = camera.rotation();
|
||||
}
|
||||
|
||||
@Inject(method = "renderSectionLayer", at = @At("HEAD"), cancellable = true)
|
||||
public void renderSectionLayer(RenderType renderType, double d, double e, double f, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
|
||||
if (!ReplayVisuals.renderBlocks) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!ReplayVisuals.renderSky) {
|
||||
RenderSystem.clearColor(0.0f, 1.0f, 0.0f, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@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"))
|
||||
public boolean renderLevel_renderBlockEntity(BlockEntityRenderDispatcher instance, BlockEntity blockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource) {
|
||||
return 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"))
|
||||
public boolean renderLevel_renderEntity(LevelRenderer instance, Entity entity, double d, double e, double f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource) {
|
||||
if (entity instanceof Player) {
|
||||
return ReplayVisuals.renderPlayers;
|
||||
} else {
|
||||
return ReplayVisuals.renderEntities;
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Options;getCloudsType()Lnet/minecraft/client/CloudStatus;"))
|
||||
public CloudStatus renderLevel_getCloudsType(Options instance, Operation<CloudStatus> original) {
|
||||
if (ReplayVisuals.renderSky) {
|
||||
return original.call(instance);
|
||||
} else {
|
||||
return CloudStatus.OFF;
|
||||
}
|
||||
}
|
||||
|
||||
@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"))
|
||||
public boolean renderLevel_renderParticles(ParticleEngine instance, LightTexture lightTexture, Camera camera, float f) {
|
||||
return ReplayVisuals.renderParticles;
|
||||
}
|
||||
|
||||
@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"))
|
||||
public boolean renderLevel_renderSky(LevelRenderer instance, Matrix4f matrix4f, Matrix4f matrix4f2, float f, Camera camera, boolean bl, Runnable runnable) {
|
||||
return ReplayVisuals.renderSky;
|
||||
}
|
||||
|
||||
@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"))
|
||||
public void setupRender(LevelRenderer instance, Camera camera, Frustum frustum, boolean capturedFrustum, boolean isSpectator, Operation<Void> original) {
|
||||
if (PerfectFrames.isEnabled()) {
|
||||
boolean doCompile = true;
|
||||
while (doCompile) {
|
||||
doCompile = false;
|
||||
|
||||
int before = this.visibleSections.size();
|
||||
original.call(instance, camera, frustum, capturedFrustum, isSpectator);
|
||||
if (this.visibleSections.size() != before) {
|
||||
doCompile = true;
|
||||
}
|
||||
|
||||
RenderRegionCache renderRegionCache = new RenderRegionCache();
|
||||
for (SectionRenderDispatcher.RenderSection renderSection : this.visibleSections) {
|
||||
if (renderSection.isDirty()) {
|
||||
this.sectionRenderDispatcher.rebuildSectionSync(renderSection, renderRegionCache);
|
||||
renderSection.setNotDirty();
|
||||
doCompile = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.sectionRenderDispatcher.uploadAllPendingUploads();
|
||||
}
|
||||
} else {
|
||||
original.call(instance, camera, frustum, capturedFrustum, isSpectator);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user