mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Yeetrium
- Mixin to sodium to steal block entity rendering duties - Fixes z-fighting and inconsistent BE rendering
This commit is contained in:
parent
bc5084b2d8
commit
377c729355
4 changed files with 63 additions and 29 deletions
|
@ -112,7 +112,7 @@ dependencies {
|
|||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
// switch to implementation for debugging
|
||||
compileOnly fg.deobf("maven.modrinth:starlight-forge:1.0.2+1.18.2")
|
||||
compileOnly fg.deobf("maven.modrinth:starlight-forge:1.1.1+1.19")
|
||||
|
||||
compileOnly fg.deobf("maven.modrinth:rubidium:0.6.1")
|
||||
compileOnly fg.deobf("maven.modrinth:oculus:1.19-1.2.5a")
|
||||
|
|
|
@ -3,9 +3,7 @@ package com.jozufozu.flywheel.mixin;
|
|||
import org.spongepowered.asm.mixin.Final;
|
||||
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.Group;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
@ -48,33 +46,8 @@ public class LevelRendererMixin {
|
|||
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, camera, frustum));
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean flywheel$LayerRendered;
|
||||
|
||||
/**
|
||||
* This only gets injected if renderChunkLayer is not Overwritten
|
||||
*/
|
||||
@Group(name = "flywheel$renderLayer", min = 1, max = 2)
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V", ordinal = 1), method = "renderChunkLayer")
|
||||
private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) {
|
||||
flywheel$renderLayer(type, stack, camX, camY, camZ);
|
||||
flywheel$LayerRendered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This always gets injected.
|
||||
*/
|
||||
@Group(name = "flywheel$renderLayer")
|
||||
@Inject(at = @At("TAIL"), method = "renderChunkLayer")
|
||||
private void renderLayerSodium(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) {
|
||||
if (!flywheel$LayerRendered) {
|
||||
flywheel$renderLayer(type, stack, camX, camY, camZ);
|
||||
}
|
||||
flywheel$LayerRendered = false;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void flywheel$renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ) {
|
||||
private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) {
|
||||
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(level, type, stack, renderBuffers, camX, camY, camZ));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.jozufozu.flywheel.mixin.instancemanage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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 com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Mixin(targets = "me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData$Builder", remap = false)
|
||||
public class SodiumChunkRenderDataMixin {
|
||||
|
||||
@Unique
|
||||
private List<BlockEntity> flywheel$blockEntities;
|
||||
@Unique
|
||||
private Level flywheel$level;
|
||||
|
||||
@Inject(method = "addBlockEntity", at = @At("HEAD"), cancellable = true, require = 0)
|
||||
private void flywheel$onAddBlockEntity(BlockEntity be, boolean cull, CallbackInfo ci) {
|
||||
if (InstancedRenderRegistry.canInstance(be.getType())) {
|
||||
if (flywheel$blockEntities == null) {
|
||||
flywheel$blockEntities = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (flywheel$level == null) {
|
||||
flywheel$level = be.getLevel();
|
||||
}
|
||||
|
||||
// Collect BEs in a temporary list to avoid excessive synchronization in InstancedRenderDispatcher.
|
||||
flywheel$blockEntities.add(be);
|
||||
}
|
||||
|
||||
if (InstancedRenderRegistry.shouldSkipRender(be)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "build", at = @At("HEAD"))
|
||||
private void flywheel$onBuild(CallbackInfoReturnable<ChunkRenderData> cir) {
|
||||
if (flywheel$level == null || flywheel$blockEntities == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
InstancedRenderDispatcher.getBlockEntities(flywheel$level)
|
||||
.queueAddAll(flywheel$blockEntities);
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@
|
|||
"instancemanage.InstanceRemoveMixin",
|
||||
"instancemanage.RenderChunkAccessor",
|
||||
"instancemanage.RenderChunkMixin",
|
||||
"instancemanage.SodiumChunkRenderDataMixin",
|
||||
"light.LightUpdateMixin",
|
||||
"light.NetworkLightUpdateMixin",
|
||||
"matrix.Matrix3fMixin",
|
||||
|
|
Loading…
Reference in a new issue