From a33ba4079310121aa9368f64c03ad015a7e3b7fb Mon Sep 17 00:00:00 2001 From: XFactHD Date: Thu, 17 Oct 2024 01:04:10 +0200 Subject: [PATCH] Make block outline passes respect render types specified by the model --- .../minecraft/client/renderer/LevelRenderer.java.patch | 7 +++++-- .../java/net/neoforged/neoforge/client/ClientHooks.java | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/patches/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/net/minecraft/client/renderer/LevelRenderer.java.patch index bb8448e40dc..f5f9a14c0d7 100644 --- a/patches/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -169,14 +169,17 @@ p_363901_.popPose(); } } -@@ -897,6 +_,7 @@ +@@ -897,8 +_,9 @@ if (blockhitresult.getType() != HitResult.Type.MISS) { BlockPos blockpos = blockhitresult.getBlockPos(); BlockState blockstate = this.level.getBlockState(blockpos); + if (!net.neoforged.neoforge.client.ClientHooks.onDrawHighlight(this, p_363911_, blockhitresult, this.minecraft.getDeltaTracker(), p_361893_, p_362782_, p_361698_)) if (!blockstate.isAir() && this.level.getWorldBorder().isWithinBounds(blockpos)) { - boolean flag = ItemBlockRenderTypes.getChunkRenderType(blockstate).sortOnUpload(); +- boolean flag = ItemBlockRenderTypes.getChunkRenderType(blockstate).sortOnUpload(); ++ boolean flag = net.neoforged.neoforge.client.ClientHooks.isInTranslucentBlockOutlinePass(this.level, blockpos, blockstate); if (flag != p_361698_) { + return; + } @@ -1026,6 +_,7 @@ compiledshaderprogram.clear(); VertexBuffer.unbind(); diff --git a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java index 66c1e266d40..a1b1166a578 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java @@ -1088,4 +1088,13 @@ public static RecipeBookType[] getFilteredRecipeBookTypeValues() { } return RECIPE_BOOK_TYPES; } + + private static final RandomSource OUTLINE_PASS_RANDOM = RandomSource.create(); + + public static boolean isInTranslucentBlockOutlinePass(Level level, BlockPos pos, BlockState state) { + BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state); + OUTLINE_PASS_RANDOM.setSeed(42); + ChunkRenderTypeSet renderTypes = model.getRenderTypes(state, OUTLINE_PASS_RANDOM, level.getModelData(pos)); + return renderTypes.contains(RenderType.TRANSLUCENT) || renderTypes.contains(RenderType.TRIPWIRE); + } }