Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public static void testXRayHack(ClientGameTestContext context,
input.pressKey(GLFW.GLFW_KEY_X);
waitForChunkReloading(context, world);
assertScreenshotEquals(context, "xray_default",
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/02KZHLm.png"
: "https://i.imgur.com/Dftamqv.png");
"https://i.imgur.com/Dftamqv.png");

// Exposed only
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed on");
Expand All @@ -48,8 +47,7 @@ public static void testXRayHack(ClientGameTestContext context,
input.pressKey(GLFW.GLFW_KEY_X);
waitForChunkReloading(context, world);
assertScreenshotEquals(context, "xray_exposed_only",
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/xplrJwM.png"
: "https://i.imgur.com/QlEpQTu.png");
"https://i.imgur.com/QlEpQTu.png");

// Opacity mode
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed off");
Expand All @@ -58,8 +56,7 @@ public static void testXRayHack(ClientGameTestContext context,
input.pressKey(GLFW.GLFW_KEY_X);
waitForChunkReloading(context, world);
assertScreenshotEquals(context, "xray_opacity",
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/MFc821z.png"
: "https://i.imgur.com/0nLulJn.png");
"https://i.imgur.com/0nLulJn.png");

// Exposed only + opacity
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed on");
Expand All @@ -68,8 +65,7 @@ public static void testXRayHack(ClientGameTestContext context,
input.pressKey(GLFW.GLFW_KEY_X);
waitForChunkReloading(context, world);
assertScreenshotEquals(context, "xray_exposed_only_opacity",
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/GRHgW6P.png"
: "https://i.imgur.com/noPWDUl.png");
"https://i.imgur.com/noPWDUl.png");

// Clean up
runCommand(server, "fill ~-5 ~-2 ~5 ~5 ~5 ~7 air");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private boolean modifyShouldSkipRendering(Direction side, float height,
BlockAndTintGetter world, BlockPos pos, VertexConsumer vertexConsumer,
BlockState blockState, FluidState fluidState)
{
// Note: the null BlockPos is here to skip the "exposed only" check
ShouldDrawSideEvent event = new ShouldDrawSideEvent(blockState, null);
EventManager.fire(event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
public class DefaultFluidRendererMixin
{
/**
* Hides and shows fluids when using X-Ray with Sodium installed.
* Hides and shows the top side of fluids when using X-Ray with Sodium
* installed.
*/
@Inject(at = @At("HEAD"),
method = "isFullBlockFluidOccluded(Lnet/minecraft/class_1920;Lnet/minecraft/class_2338;Lnet/minecraft/class_2350;Lnet/minecraft/class_2680;Lnet/minecraft/class_3610;)Z",
Expand All @@ -48,21 +49,51 @@ private void onIsFullBlockFluidOccluded(BlockAndTintGetter world,
BlockPos pos, Direction dir, BlockState state, FluidState fluid,
CallbackInfoReturnable<Boolean> cir)
{
ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, pos);
// Note: the null BlockPos is here to skip the "exposed only" check
ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, null);
EventManager.fire(event);

if(event.isRendered() != null)
cir.setReturnValue(!event.isRendered());
}

/**
* Hides and shows all other sides of fluids when using X-Ray with Sodium
* installed.
*/
@Inject(at = @At("HEAD"),
method = "isSideExposed(Lnet/minecraft/class_1920;IIILnet/minecraft/class_2350;F)Z",
cancellable = true,
remap = false,
require = 0)
private void onIsSideExposed(BlockAndTintGetter world, int x, int y, int z,
Direction dir, float height, CallbackInfoReturnable<Boolean> cir)
{
BlockPos pos = new BlockPos(x, y, z);
BlockState state = world.getBlockState(pos);

// Note: the null BlockPos is here to skip the "exposed only" check
ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, null);
EventManager.fire(event);

if(event.isRendered() == null)
return;

BlockPos nPos = pos.offset(dir.getUnitVec3i());
BlockState neighborState = world.getBlockState(nPos);

cir.setReturnValue(!neighborState.getFluidState().getType()
.isSame(state.getFluidState().getType()) && event.isRendered());
}

/**
* Modifies opacity of fluids when using X-Ray with Sodium installed.
*/
@ModifyExpressionValue(at = @At(value = "INVOKE",
target = "Lnet/caffeinemc/mods/sodium/api/util/ColorARGB;toABGR(I)I"),
method = "updateQuad",
require = 0,
remap = false)
remap = false,
require = 0)
private int onUpdateQuad(int original, @Local(argsOnly = true) BlockPos pos,
@Local(argsOnly = true) FluidState state)
{
Expand Down