3737public class DefaultFluidRendererMixin
3838{
3939 /**
40- * Hides and shows fluids when using X-Ray with Sodium installed.
40+ * Hides and shows the top side of fluids when using X-Ray with Sodium
41+ * installed.
4142 */
4243 @ Inject (at = @ At ("HEAD" ),
4344 method = "isFullBlockFluidOccluded(Lnet/minecraft/class_1920;Lnet/minecraft/class_2338;Lnet/minecraft/class_2350;Lnet/minecraft/class_2680;Lnet/minecraft/class_3610;)Z" ,
@@ -48,21 +49,51 @@ private void onIsFullBlockFluidOccluded(BlockAndTintGetter world,
4849 BlockPos pos , Direction dir , BlockState state , FluidState fluid ,
4950 CallbackInfoReturnable <Boolean > cir )
5051 {
51- ShouldDrawSideEvent event = new ShouldDrawSideEvent (state , pos );
52+ // Note: the null BlockPos is here to skip the "exposed only" check
53+ ShouldDrawSideEvent event = new ShouldDrawSideEvent (state , null );
5254 EventManager .fire (event );
5355
5456 if (event .isRendered () != null )
5557 cir .setReturnValue (!event .isRendered ());
5658 }
5759
60+ /**
61+ * Hides and shows all other sides of fluids when using X-Ray with Sodium
62+ * installed.
63+ */
64+ @ Inject (at = @ At ("HEAD" ),
65+ method = "isSideExposed(Lnet/minecraft/class_1920;IIILnet/minecraft/class_2350;F)Z" ,
66+ cancellable = true ,
67+ remap = false ,
68+ require = 0 )
69+ private void onIsSideExposed (BlockAndTintGetter world , int x , int y , int z ,
70+ Direction dir , float height , CallbackInfoReturnable <Boolean > cir )
71+ {
72+ BlockPos pos = new BlockPos (x , y , z );
73+ BlockState state = world .getBlockState (pos );
74+
75+ // Note: the null BlockPos is here to skip the "exposed only" check
76+ ShouldDrawSideEvent event = new ShouldDrawSideEvent (state , null );
77+ EventManager .fire (event );
78+
79+ if (event .isRendered () == null )
80+ return ;
81+
82+ BlockPos nPos = pos .offset (dir .getUnitVec3i ());
83+ BlockState neighborState = world .getBlockState (nPos );
84+
85+ cir .setReturnValue (!neighborState .getFluidState ().getType ()
86+ .isSame (state .getFluidState ().getType ()) && event .isRendered ());
87+ }
88+
5889 /**
5990 * Modifies opacity of fluids when using X-Ray with Sodium installed.
6091 */
6192 @ ModifyExpressionValue (at = @ At (value = "INVOKE" ,
6293 target = "Lnet/caffeinemc/mods/sodium/api/util/ColorARGB;toABGR(I)I" ),
6394 method = "updateQuad" ,
64- require = 0 ,
65- remap = false )
95+ remap = false ,
96+ require = 0 )
6697 private int onUpdateQuad (int original , @ Local (argsOnly = true ) BlockPos pos ,
6798 @ Local (argsOnly = true ) FluidState state )
6899 {
0 commit comments