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
  • Loading branch information
XFactHD committed Oct 18, 2024
1 parent f08da3e commit 212f9bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
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
Expand Up @@ -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 212f9bb

Please sign in to comment.