Actually it didn't quite work in the nether, but now it does.
The reason I am posting this is, that if someone has the same problem in the future, they will find this.
I searched for this on google for a good hour, but didn't find anything.
New code:
@SubscribeEvent
public void render(RenderWorldLastEvent event) {
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
IVertexBuilder builder = buffer.getBuffer(RenderType.LINES);
MatrixStack matrixStack = event.getMatrixStack();
PlayerEntity player = Minecraft.getInstance().player;
double x = player.lastTickPosX + (player.getPosX() - player.lastTickPosX) * event.getPartialTicks();
double y = player.lastTickPosY + (player.getPosY() - player.lastTickPosY) * event.getPartialTicks();
double z = player.lastTickPosZ + (player.getPosZ() - player.lastTickPosZ) * event.getPartialTicks();
matrixStack.push();
matrixStack.translate(-x, -y, -z);
Matrix4f matrix = matrixStack.getLast().getMatrix();
builder.pos(matrix, 0, 0, 0).color(1f, 0, 0, 1f).endVertex();
builder.pos(matrix, 0, 256, 0).color(1f, 0, 0, 1f).endVertex();
matrixStack.pop();
RenderSystem.disableDepthTest();
buffer.finish(RenderType.LINES);
}