Skip to content

Commit

Permalink
Make block outline passes respect render types specified by the model
Browse files Browse the repository at this point in the history
XFactHD committed Oct 16, 2024

Verified

This commit was signed with the committer’s verified signature.
XFactHD Dennis C
1 parent b8a868a commit a33ba40
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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();
9 changes: 9 additions & 0 deletions src/main/java/net/neoforged/neoforge/client/ClientHooks.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit a33ba40

Please sign in to comment.