forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to render type handling (#529)
* Move to neo 47.1.84 * Separate pixelmon compat from main mixins * Register config factory * Fix error message * Update mods.toml * Use Forge delegates as map keys instead of blocks themselves Theoretically fixes issues around registry replacement * Redirect getRenderTypes calls from the Sodium & vanilla chunk meshers Fixes glass not being translucent with mods like XyCraft, as they override these methods --------- Co-authored-by: dima_dencep <[email protected]>
- Loading branch information
1 parent
c37a355
commit b613f2e
Showing
18 changed files
with
160 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
.../compat/pixelmon/MixinNormalizedFace.java → ...t/pixelmon/mixin/MixinNormalizedFace.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
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
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); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/net/coderbot/iris/mixin/MixinClientPacketListener.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,31 @@ | ||
package net.coderbot.iris.mixin; | ||
|
||
import net.coderbot.iris.Iris; | ||
import net.coderbot.iris.gl.shader.ShaderCompileException; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientPacketListener; | ||
import net.minecraft.network.chat.ClickEvent; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.protocol.game.ClientboundLoginPacket; | ||
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(ClientPacketListener.class) | ||
public class MixinClientPacketListener { | ||
@Shadow | ||
private Minecraft minecraft; | ||
|
||
@Inject(method = "handleLogin", at = @At("TAIL")) | ||
private void iris$showUpdateMessage(ClientboundLoginPacket a, CallbackInfo ci) { | ||
if (this.minecraft.player == null) { | ||
return; | ||
} | ||
|
||
Iris.getStoredError().ifPresent(e -> | ||
this.minecraft.player.displayClientMessage(Component.translatable(e instanceof ShaderCompileException ? "iris.load.failure.shader" : "iris.load.failure.generic").append(Component.literal("Copy Info").withStyle(arg -> arg.withUnderlined(true).withColor(ChatFormatting.BLUE).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, e.getMessage())))), false)); | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"plugin": "net.coderbot.iris.compat.pixelmon.mixin.OculusPixelmonCompatMixinPlugin", | ||
"package": "net.coderbot.iris.compat.pixelmon.mixin", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": [ | ||
"MixinNormalizedFace" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
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