Skip to content

Commit

Permalink
fix rubidium mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Yefancy committed Nov 26, 2023
1 parent b8db12d commit e7d46e2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

Expand All @@ -40,25 +41,29 @@ public abstract class ChunkBuilderMeshingTaskMixin {
@Unique
ImmutableList.Builder<ColorPointLight> shimmer$lights;

@Unique
private static final String INJECT_SIGNATURE = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;";

@Inject(method = INJECT_SIGNATURE, at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos$MutableBlockPos;set(III)Lnet/minecraft/core/BlockPos$MutableBlockPos;", ordinal = 1), locals = LocalCapture.CAPTURE_FAILHARD)
private void injectChunkCompileAddLight(ChunkBuildContext buildContext, CancellationToken cancellationToken, CallbackInfoReturnable<ChunkBuildOutput> cir, BuiltSectionInfo.Builder renderData, VisGraph occluder, ChunkBuildBuffers buffers, BlockRenderCache cache, WorldSlice slice, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, BlockPos.MutableBlockPos blockPos, BlockPos.MutableBlockPos modelOffset, BlockRenderContext context, int y, int z, int x, BlockState blockState) {
var fluidState = blockState.getFluidState();
if (LightManager.INSTANCE.isBlockHasLight(blockState.getBlock(), fluidState)) {
var light = LightManager.INSTANCE.getBlockStateLight(slice, blockPos.immutable(), blockState, fluidState);
if (light != null) shimmer$lights.add(light);
@Redirect(method = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
at = @At(value = "INVOKE",
target = "Lme/jellysquid/mods/sodium/client/world/WorldSlice;getBlockState(III)Lnet/minecraft/world/level/block/state/BlockState;"),
remap = false)
private BlockState injectChunkCompileAddLight(WorldSlice slice, int x, int y, int z) {
var blockState = slice.getBlockState(x, y, z);
if (!blockState.isAir()) {
var fluidState = blockState.getFluidState();
if (LightManager.INSTANCE.isBlockHasLight(blockState.getBlock(), fluidState)) {
var light = LightManager.INSTANCE.getBlockStateLight(slice, new BlockPos(x, y, z), blockState, fluidState);
if (light != null) shimmer$lights.add(light);
}
PostProcessing.setupBloom(blockState, fluidState);
}
PostProcessing.setupBloom(blockState, fluidState);
return blockState;
}

@Inject(method = INJECT_SIGNATURE, at = @At("HEAD"), remap = false)
@Inject(method = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", at = @At("HEAD"), remap = false)
private void injectChunkCompilePre(ChunkBuildContext buildContext, CancellationToken cancellationToken, CallbackInfoReturnable<ChunkBuildOutput> cir) {
shimmer$lights = ImmutableList.builder();
}

@Inject(method = INJECT_SIGNATURE, at = @At("RETURN"), remap = false)
@Inject(method = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", at = @At("RETURN"), remap = false)
private void injectChunkCompilePost(ChunkBuildContext buildContext, CancellationToken cancellationToken, CallbackInfoReturnable<ChunkBuildOutput> cir) {
if (this.render instanceof IRenderChunk shimmerRenderChunk) {
shimmerRenderChunk.setShimmerLights(shimmer$lights.build());
Expand Down
4 changes: 2 additions & 2 deletions Forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ dependencies {
forgeRuntimeLibrary("icyllis.modernui:ModernUI-Core:$modernui_core_version")
modCompileOnly("icyllis.modernui:ModernUI-Forge:${minecraft_version}-${modernui_version}")

modCompileOnly("maven.modrinth:embeddium:0.2.10+mc1.20.1")
modCompileOnly("maven.modrinth:oculus:1.20.1-1.6.9")
modImplementation("maven.modrinth:embeddium:0.2.10+mc1.20.1")
modImplementation("maven.modrinth:oculus:1.20.1-1.6.9")

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
import com.lowdragmc.shimmer.client.postprocessing.PostProcessing;
import com.lowdragmc.shimmer.core.IRenderChunk;
import me.jellysquid.mods.sodium.client.render.chunk.RenderSection;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildContext;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildOutput;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderCache;
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext;
import me.jellysquid.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
import me.jellysquid.mods.sodium.client.render.chunk.data.BuiltSectionInfo;
import me.jellysquid.mods.sodium.client.util.task.CancellationToken;
import me.jellysquid.mods.sodium.client.world.WorldSlice;
import net.minecraft.client.renderer.chunk.VisGraph;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -24,8 +19,8 @@
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

/**
* @author KilaBash
Expand All @@ -40,25 +35,29 @@ public abstract class ChunkBuilderMeshingTaskMixin {
@Unique
ImmutableList.Builder<ColorPointLight> shimmer$lights;

@Unique
private static final String INJECT_SIGNATURE = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;";

@Inject(method = INJECT_SIGNATURE, at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos$MutableBlockPos;set(III)Lnet/minecraft/core/BlockPos$MutableBlockPos;", ordinal = 1), locals = LocalCapture.CAPTURE_FAILHARD, remap = false)
private void injectChunkCompileAddLight(ChunkBuildContext buildContext, CancellationToken cancellationToken, CallbackInfoReturnable<ChunkBuildOutput> cir, BuiltSectionInfo.Builder renderData, VisGraph occluder, ChunkBuildBuffers buffers, BlockRenderCache cache, WorldSlice slice, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, BlockPos.MutableBlockPos blockPos, BlockPos.MutableBlockPos modelOffset, BlockRenderContext context, int y, int z, int x, BlockState blockState) {
var fluidState = blockState.getFluidState();
if (LightManager.INSTANCE.isBlockHasLight(blockState.getBlock(), fluidState)) {
var light = LightManager.INSTANCE.getBlockStateLight(slice, blockPos.immutable(), blockState, fluidState);
if (light != null) shimmer$lights.add(light);
@Redirect(method = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
at = @At(value = "INVOKE",
target = "Lme/jellysquid/mods/sodium/client/world/WorldSlice;getBlockState(III)Lnet/minecraft/world/level/block/state/BlockState;"),
remap = false)
private BlockState injectChunkCompileAddLight(WorldSlice slice, int x, int y, int z) {
var blockState = slice.getBlockState(x, y, z);
if (!blockState.isAir()) {
var fluidState = blockState.getFluidState();
if (LightManager.INSTANCE.isBlockHasLight(blockState.getBlock(), fluidState)) {
var light = LightManager.INSTANCE.getBlockStateLight(slice, new BlockPos(x, y, z), blockState, fluidState);
if (light != null) shimmer$lights.add(light);
}
PostProcessing.setupBloom(blockState, fluidState);
}
PostProcessing.setupBloom(blockState, fluidState);
return blockState;
}

@Inject(method = INJECT_SIGNATURE, at = @At("HEAD"), remap = false)
@Inject(method = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", at = @At("HEAD"), remap = false)
private void injectChunkCompilePre(ChunkBuildContext buildContext, CancellationToken cancellationToken, CallbackInfoReturnable<ChunkBuildOutput> cir) {
shimmer$lights = ImmutableList.builder();
}

@Inject(method = INJECT_SIGNATURE, at = @At("RETURN"), remap = false)
@Inject(method = "execute(Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lme/jellysquid/mods/sodium/client/util/task/CancellationToken;)Lme/jellysquid/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", at = @At("RETURN"), remap = false)
private void injectChunkCompilePost(ChunkBuildContext buildContext, CancellationToken cancellationToken, CallbackInfoReturnable<ChunkBuildOutput> cir) {
if (this.render instanceof IRenderChunk shimmerRenderChunk) {
shimmerRenderChunk.setShimmerLights(shimmer$lights.build());
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Constant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const val modernui_version = "3.7.1.3"

//Project
const val version_major = 0.2
const val version_patch = 0
const val version_patch = 1
const val semantics_version = "$minecraft_version-$version_major.$version_patch"
const val maven_path = "snapshots"
const val maven_group = "com.lowdragmc.shimmer"
Expand Down

0 comments on commit e7d46e2

Please sign in to comment.