forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect getRenderTypes calls from the Sodium & vanilla chunk meshers
Fixes glass not being translucent with mods like XyCraft, as they override these methods
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/net/coderbot/iris/mixin/MixinChunkRenderDispatcherRebuildTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.coderbot.iris.mixin; | ||
|
||
import net.coderbot.iris.block_rendering.BlockRenderingSettings; | ||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraftforge.client.ChunkRenderTypeSet; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(ChunkRenderDispatcher.RenderChunk.RebuildTask.class) | ||
public class MixinChunkRenderDispatcherRebuildTask { | ||
@Redirect(method = "compile", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/BakedModel;getRenderTypes(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/util/RandomSource;Lnet/minecraftforge/client/model/data/ModelData;)Lnet/minecraftforge/client/ChunkRenderTypeSet;")) | ||
private ChunkRenderTypeSet oculus$overrideRenderTypes(BakedModel instance, BlockState blockState, RandomSource randomSource, ModelData modelData) { | ||
Map<Holder.Reference<Block>, ChunkRenderTypeSet> idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds(); | ||
if (idMap != null) { | ||
ChunkRenderTypeSet type = idMap.get(ForgeRegistries.BLOCKS.getDelegateOrThrow(blockState.getBlock())); | ||
if (type != null) { | ||
return type; | ||
} | ||
} | ||
|
||
return instance.getRenderTypes(blockState, randomSource, modelData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../net/coderbot/iris/compat/sodium/mixin/shader_overrides/MixinChunkBuilderMeshingTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.coderbot.iris.compat.sodium.mixin.shader_overrides; | ||
|
||
import me.jellysquid.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask; | ||
import net.coderbot.iris.block_rendering.BlockRenderingSettings; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraftforge.client.ChunkRenderTypeSet; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(ChunkBuilderMeshingTask.class) | ||
public class MixinChunkBuilderMeshingTask { | ||
/** | ||
* @author embeddedt | ||
* @reason On Forge, render types are not intended to be driven by a central registry like in vanilla; instead, they | ||
* get queried from the block model during meshing. Only the default baked models defer to the vanilla registry; | ||
* specifying a render type in the model JSON or using a custom model will return its own value. Thus, we need | ||
* to redirect the access at a higher level. | ||
*/ | ||
@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 = "Lnet/minecraft/client/resources/model/BakedModel;getRenderTypes(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/util/RandomSource;Lnet/minecraftforge/client/model/data/ModelData;)Lnet/minecraftforge/client/ChunkRenderTypeSet;"), | ||
remap = false) | ||
private ChunkRenderTypeSet oculus$overrideRenderTypes(BakedModel instance, BlockState blockState, RandomSource randomSource, ModelData modelData) { | ||
Map<Holder.Reference<Block>, ChunkRenderTypeSet> idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds(); | ||
if (idMap != null) { | ||
ChunkRenderTypeSet type = idMap.get(ForgeRegistries.BLOCKS.getDelegateOrThrow(blockState.getBlock())); | ||
if (type != null) { | ||
return type; | ||
} | ||
} | ||
|
||
return instance.getRenderTypes(blockState, randomSource, modelData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters