You could use a depth prepass approach but this would result in no transparency overlap within the instanced cubes at all even for distance cubes. See this thread for more information on that approach.
… I’m trying to make a minecraft-like game…
From what I can tell in Minecraft most individually interactive blocks use alpha clipping instead of partial transparency likely to avoid the issue you’re running into here. Water is partially transparent but it also seems to be a special case where a unique mesh is generated based on how the water is flowing which avoids the “seams” between blocks.