@@ -36,7 +36,6 @@ public class FabricRendererRenderAPI implements RenderAPI {
3636 private final Predicate <@ Nullable Direction > cullTest ;
3737 private final BlockStateModel unwrapped ;
3838
39-
4039 public FabricRendererRenderAPI (
4140 QuadEmitter emitter ,
4241 BlockAndTintGetter level ,
@@ -98,24 +97,41 @@ public boolean render(BlockState blockState, BlockStateModel model, double yOffs
9897 if (blockState == selfState && model != ClientHooks .cachedOverlayModel ) {
9998 model = unwrapped ;
10099 }
101- if (context instanceof AbstractBlockRenderContextAccess blockRenderContext ) {
102- BlockRenderInfo blockInfo = blockRenderContext .getBlockInfo ();
103- boolean generalOverlay = part == ModelPart .SNOW_OVERLAY && offset .y <= -1.0 ;
104- blockInfo .prepareForBlock (pos , generalOverlay ? TOP_SLAB : blockState );
105- if (generalOverlay ) {
106- ((BlockRenderInfoAccess ) blockInfo ).setDefaultLayer (ChunkSectionLayer .CUTOUT );
107- blockInfo .blockPos = pos .below ();
108- for (Direction direction : Direction .Plane .HORIZONTAL ) {
109- emitter .cullFace (direction );
110- }
111- blockInfo .blockPos = pos ;
112- }
113- }
100+
101+ var cullTest = newCullTest (blockState , part , offset );
102+
114103 ((FabricBlockStateModel ) model ).emitQuads (emitter , level , pos , blockState , random , cullTest );
115104 emitter .popTransform ();
116105 return true ;
117106 }
118107
108+ private Predicate <@ Nullable Direction > newCullTest (BlockState blockState , ModelPart part , Vec3 offset ) {
109+ var cullTest = this .cullTest ;
110+ BlockPos .MutableBlockPos scratchPos = new BlockPos .MutableBlockPos ();
111+ boolean generalOverlay = part == ModelPart .SNOW_OVERLAY && offset .y <= -1.0 ;
112+ if (part == ModelPart .DECORATION || part == ModelPart .SNOW_OVERLAY || part == ModelPart .SNOW_LAYER ) {
113+ cullTest = $ -> {
114+ if (this .cullTest .test ($ )) {
115+ return true ;
116+ }
117+ if ($ == null ) {
118+ return false ;
119+ }
120+ BlockPos .MutableBlockPos pos1 = scratchPos .setWithOffset (pos , $ );
121+ BlockState selfState = blockState ;
122+ if (generalOverlay ) {
123+ pos1 .move (Direction .DOWN );
124+ selfState = TOP_SLAB ;
125+ } else if (part == ModelPart .SNOW_LAYER && CoreModule .SLAB .is (this .selfState )) {
126+ selfState = this .selfState ;
127+ }
128+ BlockState neighborState = level .getBlockState (pos1 );
129+ return !Block .shouldRenderFace (selfState , neighborState , $ );
130+ };
131+ }
132+ return cullTest ;
133+ }
134+
119135 private static float expandModel (float f ) {
120136 if (Mth .equal (f , 0f )) {
121137 return f - 0.001f ;
0 commit comments